Emacs 编辑器

The Emacs Editor

Emacs 是先进的、可扩展的、可定制的、自记录的编辑器。本手册介绍了如何使用 Emacs 进行编辑以及一些自定义它的方法;它对应于 GNU Emacs 版本 29.2。

Emacs is the advanced, extensible, customizable, self-documenting editor. This manual describes how to edit with Emacs and some of the ways to customize it; it corresponds to GNU Emacs version 29.2.

GNU Emacs 网站位于 https://www.gnu.org/software/emacs/
要以其他格式查看本手册,请单击 此处。您还可以从FSF 商店
购买印刷版 。

有关扩展 Emacs 的信息,请参阅Emacs Lisp 参考手册中的Emacs Lisp

For information on extending Emacs, see Emacs Lisp in The Emacs Lisp Reference Manual.

这是GNU Emacs 手册,针对 Emacs 版本 29.2 进行了更新。

This is the GNU Emacs Manual, updated for Emacs version 29.2.

版权所有 © 1985–2024 自由软件基金会, Inc.

Copyright © 1985–2024 Free Software Foundation, Inc.

根据 GNU 自由文档许可证 1.3 版或自由软件基金会发布的任何更高版本的条款,授予复制、分发和/或修改本文档的许可;不变部分为“GNU 宣言”、“分发”和“GNU 通用公共许可证”,封面文本为“GNU 手册”,封底文本如下 (a) 所示。该许可证的副本包含在标题为“GNU 自由文档许可证”的部分中。

(a) FSF 的封底文字是:“您可以自由复制和修改本 GNU 手册。从 FSF 购买副本可以支持其开发 GNU 并促进软件自由。”

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with the Invariant Sections being “The GNU Manifesto,” “Distribution” and “GNU GENERAL PUBLIC LICENSE,” with the Front-Cover Texts being “A GNU Manual,” and with the Back-Cover Texts as in (a) below. A copy of the license is included in the section entitled “GNU Free Documentation License.”

(a) The FSF’s Back-Cover Text is: “You have the freedom to copy and modify this GNU manual. Buying copies from the FSF supports it in developing GNU and promoting software freedom.”

目录

Table of Contents

简短的目录

Short Table of Contents


分配

Distribution

GNU Emacs 是免费软件;这意味着每个人都可以自由使用它,并在某些条件下自由重新分发它。 GNU Emacs 不属于公共领域;它受版权保护,并且对其分发有限制,但这些限制旨在允许良好合作的公民想做的一切。不允许的是试图阻止其他人进一步共享他们可能从您那里获得的任何版本的 GNU Emacs。确切的条件可以在 Emacs 附带的 GNU 通用公共许可证中找到,并且也出现在本手册1中。请参阅GNU 通用公共许可证

GNU Emacs is free software; this means that everyone is free to use it and free to redistribute it under certain conditions. GNU Emacs is not in the public domain; it is copyrighted and there are restrictions on its distribution, but these restrictions are designed to permit everything that a good cooperating citizen would want to do. What is not allowed is to try to prevent others from further sharing any version of GNU Emacs that they might get from you. The precise conditions are found in the GNU General Public License that comes with Emacs and also appears in this manual1. See GNU GENERAL PUBLIC LICENSE.

获取 GNU Emacs 副本的一种方法是从拥有它的其他人那里获取。您无需征求我们的许可即可这样做,也无需告诉其他任何人;只需复制它即可。如果您可以访问互联网,您可以通过匿名 FTP 获取 GNU Emacs 的最新发行版;有关更多信息, 请参阅 我们网站上的https://www.gnu.org/software/emacs 。

One way to get a copy of GNU Emacs is from someone else who has it. You need not ask for our permission to do so, or tell anyone else; just copy it. If you have access to the Internet, you can get the latest distribution version of GNU Emacs by anonymous FTP; see https://www.gnu.org/software/emacs on our website for more information.

当您购买计算机时,您还可能会收到 GNU Emacs。计算机制造商可以按照适用于其他所有人的相同条款自由分发副本。这些条款要求他们向您提供完整的源代码,包括他们可能所做的任何更改,并允许您根据通用公共许可证的通常条款重新分发从他们那里收到的 GNU Emacs。换句话说,当您获得该程序时,该程序必须对您免费,而不仅仅是对制造商免费。

You may also receive GNU Emacs when you buy a computer. Computer manufacturers are free to distribute copies on the same terms that apply to everyone else. These terms require them to give you the full sources, including whatever changes they may have made, and to permit you to redistribute the GNU Emacs received from them under the usual terms of the General Public License. In other words, the program must be free for you when you get it, not just free for the manufacturer.

如果您发现 GNU Emacs 有用,请向自由软件基金会捐款以支持我们的工作。在美国,向自由软件基金会的捐赠可以免税。如果您在工作场所使用 GNU Emacs,请建议公司捐款。要捐赠,请参阅https://my.fsf.org/donate/。有关您可以提供帮助的其他方式,请参阅 https://www.gnu.org/help/help.html

If you find GNU Emacs useful, please send a donation to the Free Software Foundation to support our work. Donations to the Free Software Foundation are tax-deductible in the US. If you use GNU Emacs at your workplace, please suggest that the company make a donation. To donate, see https://my.fsf.org/donate/. For other ways in which you can help, see https://www.gnu.org/help/help.html.

我们还出售本手册的硬拷贝版本以及Robert J. Chassel 所著的《Emacs Lisp 编程简介》 。您可以访问我们的在线商店https://shop.fsf.org/。销售收入将用于支持基金会的宗旨:开发新的自由软件以及改进包括 GNU Emacs 在内的现有程序。

We also sell hardcopy versions of this manual and An Introduction to Programming in Emacs Lisp, by Robert J. Chassell. You can visit our online store at https://shop.fsf.org/. The income from sales goes to support the foundation’s purpose: the development of new free software, and improvements to our existing programs including GNU Emacs.

如果您需要联系自由软件基金会,请参阅 https://www.fsf.org/about/contact/,或写信至

If you need to contact the Free Software Foundation, see https://www.fsf.org/about/contact/, or write to

自由软件基金会
富兰克林街 51 号,五楼
马萨诸塞州波士顿 02110-1301
美国
Free Software Foundation
51 Franklin Street, Fifth Floor
Boston, MA 02110-1301
USA

介绍

Introduction

您正在阅读有关 GNU Emacs 的内容,它是高级、自记录、可定制、可扩展编辑器 Emacs 的 GNU 化身。 (这 'G' 在 GNU(GNU's Not Unix)中并不是沉默的。)

You are reading about GNU Emacs, the GNU incarnation of the advanced, self-documenting, customizable, extensible editor Emacs. (The ‘G’ in GNU (GNU’s Not Unix) is not silent.)

我们称 Emacs为高级,因为它能做的不仅仅是简单的插入和删除文本。它可以控制子进程、自动缩进程序、一次显示多个文件、像编辑本地文件一样编辑远程文件等等。 Emacs 编辑命令以字符、单词、行、句子、段落和页面以及各种编程语言中的表达式和注释进行操作。

We call Emacs advanced because it can do much more than simple insertion and deletion of text. It can control subprocesses, indent programs automatically, show multiple files at once, edit remote files like they were local files, and more. Emacs editing commands operate in terms of characters, words, lines, sentences, paragraphs, and pages, as well as expressions and comments in various programming languages.

自记录意味着您可以随时使用特殊命令(称为帮助命令)来查找您的选项是什么,或者查找任何命令的作用,或者查找与给定主题相关的所有命令。请参阅帮助

Self-documenting means that at any time you can use special commands, known as help commands, to find out what your options are, or to find out what any command does, or to find all the commands that pertain to a given topic. See Help.

可定制意味着您可以通过简单的方式轻松更改 Emacs 命令的行为。例如,如果您使用注释以 ' 开头的编程语言<**' 并以 ' 结尾**>',您可以告诉 Emacs 注释操作命令使用这些字符串(请参阅操作注释)。再举一个例子,您可以将基本光标移动命令(上、下、左、右)重新绑定到键盘上您觉得舒服的任何键。请参阅定制

Customizable means that you can easily alter the behavior of Emacs commands in simple ways. For instance, if you use a programming language in which comments start with ‘<**’ and end with ‘**>’, you can tell the Emacs comment manipulation commands to use those strings (see Manipulating Comments). To take another example, you can rebind the basic cursor motion commands (up, down, left and right) to any keys on the keyboard that you find comfortable. See Customization.

可扩展意味着您可以超越简单的自定义并创建全新的命令。新命令只是用 Lisp 语言编写的程序,由 Emacs 自己的 Lisp 解释器运行。甚至可以在编辑会话中重新定义现有命令,而无需重新启动 Emacs。 Emacs 中的大部分编辑命令都是用 Lisp 编写的;少数异常本来可以用 Lisp 编写,但为了提高效率而使用 C。编写扩展就是编程,但非程序员也可以在之后使用它。如果您想学习 Emacs Lisp 编程, 请参阅Emacs Lisp 编程简介中前言。

Extensible means that you can go beyond simple customization and create entirely new commands. New commands are simply programs written in the Lisp language, which are run by Emacs’s own Lisp interpreter. Existing commands can even be redefined in the middle of an editing session, without having to restart Emacs. Most of the editing commands in Emacs are written in Lisp; the few exceptions could have been written in Lisp but use C instead for efficiency. Writing an extension is programming, but non-programmers can use it afterwards. See Preface in An Introduction to Programming in Emacs Lisp, if you want to learn Emacs Lisp programming.


1 屏幕的组织

1 The Organization of the Screen

在图形显示上,例如在使用 X Window 系统的 GNU/Linux 上,Emacs 占据一个图形窗口。在文本终端上,Emacs 占据整个终端屏幕。我们将使用术语“ 框架”来表示 Emacs 占用的图形窗口或终端屏幕。 Emacs 在两种框架上的行为非常相似。通常一开始只有一帧,但如果您愿意,您可以创建其他帧(请参阅帧和图形显示)。

On a graphical display, such as on GNU/Linux using the X Window System, Emacs occupies a graphical window. On a text terminal, Emacs occupies the entire terminal screen. We will use the term frame to mean a graphical window or terminal screen occupied by Emacs. Emacs behaves very similarly on both kinds of frames. It normally starts out with just one frame, but you can create additional frames if you wish (see Frames and Graphical Displays).

每个帧由几个不同的区域组成。框架顶部是一个菜单栏,它允许您通过一系列菜单访问命令。在图形显示器上,菜单栏的正下方是工具栏,这是一排图标,单击它们即可执行编辑命令。框架的最底部是一个回显区域,其中显示信息性消息,并且当 Emacs 要求时您可以在其中输入信息。

Each frame consists of several distinct regions. At the top of the frame is a menu bar, which allows you to access commands via a series of menus. On a graphical display, directly below the menu bar is a tool bar, a row of icons that perform editing commands when you click on them. At the very bottom of the frame is an echo area, where informative messages are displayed and where you enter information when Emacs asks for it.

框架的主要区域位于工具栏(如果存在)下方和回波区域上方,称为窗口。今后在本手册中,我们将在这个意义上使用“窗口”一词。图形显示系统通常使用具有不同含义的“窗口”一词;但是,如上所述,我们将这些图形窗口称为“框架”。

The main area of the frame, below the tool bar (if one exists) and above the echo area, is called the window. Henceforth in this manual, we will use the word “window” in this sense. Graphical display systems commonly use the word “window” with a different meaning; but, as stated above, we refer to those graphical windows as “frames”.

Emacs 窗口是显示缓冲区(您正在编辑或查看的文本或其他图形)的地方。在图形显示上,窗口的一侧有一个滚动条,可用于滚动缓冲区。窗口的最后一行是模式行。这会显示有关缓冲区中发生的情况的各种信息,例如是否有未保存的更改、正在使用的编辑模式、当前行号等等。

An Emacs window is where the buffer—the text or other graphics you are editing or viewing—is displayed. On a graphical display, the window possesses a scroll bar on one side, which can be used to scroll through the buffer. The last line of the window is a mode line. This displays various information about what is going on in the buffer, such as whether there are unsaved changes, the editing modes that are in use, the current line number, and so forth.

当您启动 Emacs 时,框架中通常只有一个窗口。但是,您可以水平或垂直细分该窗口以创建多个窗口,每个窗口可以独立显示一个缓冲区(请参阅多个窗口)。

When you start Emacs, there is normally only one window in the frame. However, you can subdivide this window horizontally or vertically to create multiple windows, each of which can independently display a buffer (see Multiple Windows).

在任何时候,一个窗口就是被选择的窗口。在图形显示上,选定的窗口显示更突出的光标(通常稳定并闪烁);其他窗口显示不太突出的光标(通常是空心框)。在文本终端上,只有一个光标,显示在所选窗口中。所选窗口中显示的缓冲区称为当前缓冲区,它是编辑发生的地方。大多数 Emacs 命令隐式应用于当前缓冲区;未选择的窗口中显示的文本大多可见以供参考。如果在图形显示上使用多个框架,则选择特定框架将选择该框架中的窗口。

At any time, one window is the selected window. On a graphical display, the selected window shows a more prominent cursor (usually solid and blinking); other windows show a less prominent cursor (usually a hollow box). On a text terminal, there is only one cursor, which is shown in the selected window. The buffer displayed in the selected window is called the current buffer, and it is where editing happens. Most Emacs commands implicitly apply to the current buffer; the text displayed in unselected windows is mostly visible for reference. If you use multiple frames on a graphical display, selecting a particular frame selects a window in that frame.


1.1 要点

1.1 Point

所选窗口中的光标显示大多数编辑命令生效的位置,称为2。许多 Emacs 命令将指针移动到缓冲区中的不同位置;例如,您可以通过单击鼠标按钮 1(通常是左键)在所需位置放置点。

The cursor in the selected window shows the location where most editing commands take effect, which is called point2. Many Emacs commands move point to different places in the buffer; for example, you can place point by clicking mouse button 1 (normally the left button) at the desired location.

默认情况下,所选窗口中的光标被绘制为实心块并显示在一个字符,但您应该将点视为两个字符之间;它位于 光标下的字符之前。例如,如果您的文本看起来像 '弗洛布' 将光标置于 '',则点位于 ' 之间' 和 ''。如果插入字符 '' 在那个位置,结果是 '来回!b',点位于 ' 之间' 和 ''。因此,光标保留在 '', 像之前一样。

By default, the cursor in the selected window is drawn as a solid block and appears to be on a character, but you should think of point as between two characters; it is situated before the character under the cursor. For example, if your text looks like ‘frob’ with the cursor over the ‘b’, then point is between the ‘o’ and the ‘b’. If you insert the character ‘!’ at that position, the result is ‘fro!b’, with point between the ‘!’ and the ‘b’. Thus, the cursor remains over the ‘b’, as before.

如果您在 Emacs 中编辑多个文件,每个文件都在自己的缓冲区中,每个缓冲区都有自己的 point 值。如果稍后再次显示当前未显示的缓冲区,它会记住其点值。此外,如果缓冲区显示在多个窗口中,则每个窗口都有自己的点值。

If you are editing several files in Emacs, each in its own buffer, each buffer has its own value of point. A buffer that is not currently displayed remembers its value of point if you later display it again. Furthermore, if a buffer is displayed in multiple windows, each of those windows has its own value of point.

有关控制 Emacs 如何显示光标的选项, 请参阅显示光标。

See Displaying the Cursor, for options that control how Emacs displays the cursor.


1.2 回声区

1.2 The Echo Area

帧最底部的线是回波区域。它用于出于各种目的显示少量文本。

The line at the very bottom of the frame is the echo area. It is used to display small amounts of text for various purposes.

回显区域之所以如此命名,是因为它的用途之一是回显,这意味着在您键入时显示多字符命令的字符。单字符命令不会被回显。如果您在命令中间暂停超过一秒,则会回显多字符命令(请参阅按键)。然后,Emacs 会回显到目前为止该命令的所有字符,以提示您执行其余操作。一旦开始回显,命令的其余部分将在您键入时立即回显。此行为旨在为自信的用户提供快速响应,同时为犹豫的用户提供最大的反馈。

The echo area is so-named because one of the things it is used for is echoing, which means displaying the characters of a multi-character command as you type. Single-character commands are not echoed. Multi-character commands (see Keys) are echoed if you pause for more than a second in the middle of a command. Emacs then echoes all the characters of the command so far, to prompt you for the rest. Once echoing has started, the rest of the command echoes immediately as you type it. This behavior is designed to give confident users fast response, while giving hesitant users maximum feedback.

当命令无法完成其工作时,回显区域还用于显示错误消息。错误消息可能会伴随蜂鸣声或屏幕闪烁。

The echo area is also used to display an error message when a command cannot do its job. Error messages may be accompanied by beeping or by flashing the screen.

某些命令会在回显区域中显示信息性消息,告诉您该命令执行了哪些操作,或者为您提供一些特定信息。与错误消息不同,这些信息性消息不会伴随蜂鸣声或闪烁。例如,C-x = (按住Ctrl并键入x,然后松开Ctrl并键入=)将显示一条消息,描述当前位置的字符、其在缓冲区中的位置以及其在窗口中的当前列。需要很长时间的命令通常会显示以 ' 结尾的消息...' 当他们工作时(有时也表明已经取得了多少进展,以百分比表示),并添加 '完毕’当他们完成时。

Some commands display informative messages in the echo area to tell you what the command has done, or to provide you with some specific information. These informative messages, unlike error messages, are not accompanied with a beep or flash. For example, C-x = (hold down Ctrl and type x, then let go of Ctrl and type =) displays a message describing the character at point, its position in the buffer, and its current column in the window. Commands that take a long time often display messages ending in ‘...’ while they are working (sometimes also indicating how much progress has been made, as a percentage), and add ‘done’ when they are finished.

信息性回显区域消息保存在名为 *留言*。 (我们还没有解释缓冲区;有关它们的更多信息,请参阅 使用多个缓冲区。)如果您错过了屏幕上短暂出现的消息,您可以切换到 *留言*缓冲以再次查看它。这*留言* 缓冲区仅限于一定数量的行,由变量指定message-log-max。 (我们也没有解释变量;有关它们的更多信息,请参阅变量。)超出此限制,每当在末尾添加新消息行时,就会从开头删除一行。

Informative echo area messages are saved in a special buffer named *Messages*. (We have not explained buffers yet; see Using Multiple Buffers, for more information about them.) If you miss a message that appeared briefly on the screen, you can switch to the *Messages* buffer to see it again. The *Messages* buffer is limited to a certain number of lines, specified by the variable message-log-max. (We have not explained variables either; see Variables, for more information about them.) Beyond this limit, one line is deleted from the beginning whenever a new message line is added at the end.

请参阅Customization of Display,了解控制 Emacs 如何使用回显区域的选项。

See Customization of Display, for options that control how Emacs uses the echo area.

回显区域还用于显示 minibuffer 这是一个特殊窗口,您可以在其中输入命令参数,例如要编辑的文件的名称。当使用迷你缓冲区时,回显区域中显示的文本以提示字符串开头,并且活动光标出现在迷你缓冲区内,暂时将其视为所选窗口。您始终可以通过输入来退出迷你缓冲区C-g。请参阅迷你缓冲区

The echo area is also used to display the minibuffer, a special window where you can input arguments to commands, such as the name of a file to be edited. When the minibuffer is in use, the text displayed in the echo area begins with a prompt string, and the active cursor appears within the minibuffer, which is temporarily considered the selected window. You can always get out of the minibuffer by typing C-g. See The Minibuffer.


1.3 模式线

1.3 The Mode Line

每个窗口的底部都有一个模式行,它描述了当前缓冲区中发生的情况。当只有一个窗口时,模式线出现在回波区域的正上方;它是帧中的倒数第二行。在图形显示上,模式线以 3D 框外观绘制。 Emacs 通常还会使用与未选定窗口不同的颜色来绘制选定窗口的模式线,以使其脱颖而出。

At the bottom of each window is a mode line, which describes what is going on in the current buffer. When there is only one window, the mode line appears right above the echo area; it is the next-to-last line in the frame. On a graphical display, the mode line is drawn with a 3D box appearance. Emacs also usually draws the mode line of the selected window with a different color from that of unselected windows, in order to make it stand out.

模式行中显示的文本具有以下格式:

The text displayed in the mode line has the following format:

 cs : ch - fr   buf       pos  line    (大调 小调)
 cs:ch-fr  buf      pos line   (major minor)

在文本终端上,该文本后跟一系列延伸到窗口右边缘的破折号。这些破折号在图形显示上被省略。

On a text terminal, this text is followed by a series of dashes extending to the right edge of the window. These dashes are omitted on a graphical display.

cs字符串及其后面冒号字符描述了当前缓冲区使用的字符集和换行符约定。通常,Emacs 会自动为您处理这些设置,但有时拥有此信息很有用。

The cs string and the colon character after it describe the character set and newline convention used for the current buffer. Normally, Emacs automatically handles these settings for you, but it is sometimes useful to have this information.

cs描述缓冲区中文本的字符集(请参阅编码系统)。如果是破折号 ('-'),表示没有特殊的字符集处理(行尾约定可能是例外,如下一段所述)。 '=' 表示不进行任何转换,通常用于包含非文本数据的文件。其他字符代表各种 编码系统- 例如,'1' 代表 ISO Latin-1。

cs describes the character set of the text in the buffer (see Coding Systems). If it is a dash (‘-’), that indicates no special character set handling (with the possible exception of end-of-line conventions, described in the next paragraph). ‘=’ means no conversion whatsoever, and is usually used for files containing non-textual data. Other characters represent various coding systems—for example, ‘1’ represents ISO Latin-1.

在文本终端上,cs前面有两个附加字符,用于描述键盘输入和终端输出的编码系统。此外,如果您使用输入法, cs前面会有一个标识输入法的字符串(请参阅输入法)。

On a text terminal, cs is preceded by two additional characters that describe the coding systems for keyboard input and terminal output. Furthermore, if you are using an input method, cs is preceded by a string that identifies the input method (see Input Methods).

cs后面的字符通常是冒号。如果显示不同的字符串,则表明对文件进行编码的重要行结束约定。通常,文件中的文本行由换行符分隔,但有时会使用其他两种约定。 MS-DOS 约定使用回车符后跟换行符;编辑此类文件时,冒号会更改为反斜杠 ('\') 或者 '(DOS)',取决于操作系统。较旧的 Macintosh 系统采用的另一种约定是使用回车符而不是换行符。编辑此类文件时,冒号会更改为正斜杠 ('/') 或者 '(苹果)'。在某些系统上,Emacs 显示 '(Unix)' 而不是使用换行符作为行分隔符的文件的冒号。

The character after cs is usually a colon. If a different string is displayed, that indicates a nontrivial end-of-line convention for encoding a file. Usually, lines of text are separated by newline characters in a file, but two other conventions are sometimes used. The MS-DOS convention uses a carriage return character followed by a linefeed character; when editing such files, the colon changes to either a backslash (‘\’) or ‘(DOS)’, depending on the operating system. Another convention, employed by older Macintosh systems, uses a carriage return character instead of a newline; when editing such files, the colon changes to either a forward slash (‘/’) or ‘(Mac)’. On some systems, Emacs displays ‘(Unix)’ instead of the colon for files that use newline as the line separator.

emacsclient在为(请参阅调用emacsclient)创建的帧上,下一个字符是 '@'。此指示对于作为守护进程运行的 Emacs 进程的框架来说是典型的(请参阅使用 Emacs 作为服务器)。

On frames created for emacsclient (see Invoking emacsclient), the next character is ‘@’. This indication is typical for frames of an Emacs process running as a daemon (see Using Emacs as a Server).

模式行上的下一个元素是ch指示的字符串 。这显示了两个破折号('--') 如果窗口中显示的缓冲区与磁盘上相应文件的内容相同;即,如果缓冲区未修改。如果缓冲区被修改,它会显示两颗星('**')。对于只读缓冲区,它显示 '%*' 如果缓冲区被修改,并且 '%%' 否则。

The next element on the mode line is the string indicated by ch. This shows two dashes (‘--’) if the buffer displayed in the window has the same contents as the corresponding file on the disk; i.e., if the buffer is unmodified. If the buffer is modified, it shows two stars (‘**’). For a read-only buffer, it shows ‘%*’ if the buffer is modified, and ‘%%’ otherwise.

ch之后的字符通常是破折号 ('-')。但是,如果default-directory(请参阅文件名)当前缓冲区位于远程计算机上,'@而是显示 '。

The character after ch is normally a dash (‘-’). However, if default-directory (see File Names) for the current buffer is on a remote machine, ‘@’ is displayed instead.

fr给出所选框架的名称(请参阅框架和图形显示)。它仅出现在文本终端上。初始框架的名称是 'F1'。

fr gives the selected frame name (see Frames and Graphical Displays). It appears only on text terminals. The initial frame’s name is ‘F1’.

buf是窗口中显示的缓冲区的名称。通常,这与您正在编辑的文件的名称相同。请参阅使用多个缓冲区

buf is the name of the buffer displayed in the window. Usually, this is the same as the name of a file you are editing. See Using Multiple Buffers.

pos告诉您窗口顶部上方或底部下方是否有其他文本。如果您的缓冲区很小并且所有缓冲区都在窗口中可见,则pos是 '全部'。否则,就是‘顶部'如果您正在查看缓冲区的开头,'机器人' 如果您正在查看缓冲区的末尾,或者 '%',其中nn是窗口顶部上方缓冲区的百分比。使用大小指示模式,您还可以显示缓冲区的大小。请参阅可选模式线功能

pos tells you whether there is additional text above the top of the window, or below the bottom. If your buffer is small and all of it is visible in the window, pos is ‘All’. Otherwise, it is ‘Top’ if you are looking at the beginning of the buffer, ‘Bot’ if you are looking at the end of the buffer, or ‘nn%’, where nn is the percentage of the buffer above the top of the window. With Size Indication mode, you can display the size of the buffer as well. See Optional Mode Line Features.

是字符 'L' 后跟该点的行号。 (您也可以通过打开列号模式来显示当前列号。请参阅可选模式行功能。)

line is the character ‘L’ followed by the line number at point. (You can display the current column number too, by turning on Column Number mode. See Optional Mode Line Features.)

Major是缓冲区中使用的主要模式的名称。主模式是缓冲区的主要编辑模式,例如Text模式、Lisp模式、C模式等。请参阅主要模式。某些主要模式会在主要模式名称后显示附加信息。例如,编译缓冲区和外壳缓冲区显示子进程的状态。

major is the name of the major mode used in the buffer. A major mode is a principal editing mode for the buffer, such as Text mode, Lisp mode, C mode, and so forth. See Major Modes. Some major modes display additional information after the major mode name. For example, Compilation buffers and Shell buffers display the status of the subprocess.

次要模式是一些已启用的次要模式的列表,这些模式是可选的编辑模式,可在主要模式之上提供附加功能。请参阅次要模式

minor is a list of some of the enabled minor modes, which are optional editing modes that provide additional features on top of the major mode. See Minor Modes.

有些功能在打开时会与次要模式一起列出,即使它们并不是真正的次要模式。 '狭窄的' 表示正在显示的缓冲区的编辑仅限于其文本的一部分(请参阅缩小范围)。 '定义' 表示当前正在定义键盘宏(请参阅键盘宏)。

Some features are listed together with the minor modes whenever they are turned on, even though they are not really minor modes. ‘Narrow’ means that the buffer being displayed has editing restricted to only a portion of its text (see Narrowing). ‘Def’ means that a keyboard macro is currently being defined (see Keyboard Macros).

此外,如果 Emacs 位于递归编辑级别内,则方括号 ('[…]') 出现在模式周围的括号周围。如果 Emacs 处于另一个递归编辑级别中,则会出现双方括号,依此类推。由于递归编辑级别会全局影响 Emacs,因此每个窗口的模式行中都会出现这样的方括号。请参阅递归编辑级别

In addition, if Emacs is inside a recursive editing level, square brackets (‘[…]’) appear around the parentheses that surround the modes. If Emacs is in one recursive editing level within another, double square brackets appear, and so on. Since recursive editing levels affect Emacs globally, such square brackets appear in the mode line of every window. See Recursive Editing Levels.

您可以更改模式行的外观及其内容的格式。请参阅可选模式线功能。另外,模式线是鼠标敏感的;单击模式行的不同部分会执行各种命令。请参阅模式行鼠标命令。此外,将鼠标指针悬停在模式行的鼠标敏感部分上方会显示工具提示(请参阅工具提示),其中包含有关可通过单击模式行调用的命令的信息。

You can change the appearance of the mode line as well as the format of its contents. See Optional Mode Line Features. In addition, the mode line is mouse-sensitive; clicking on different parts of the mode line performs various commands. See Mode Line Mouse Commands. Also, hovering the mouse pointer above mouse-sensitive portions of the mode line shows tooltips (see Tooltips) with information about commands you can invoke by clicking on the mode line.


2种用户输入

2 Kinds of User Input

GNU Emacs 主要设计用于键盘。虽然可以使用鼠标通过菜单栏和工具栏发出编辑命令,但这通常不如使用键盘有效。

GNU Emacs is primarily designed for use with the keyboard. While it is possible to use the mouse to issue editing commands through the menu bar and tool bar, that is usually not as efficient as using the keyboard.

Emacs 的键盘输入基于 ASCII的深度扩展版本。简单的字符,例如 'A','','3','=' 和空格字符(表示为SPC)通过键入相应的键来输入。 控制字符(例如RETTABDELESCF1HomeLEFT)也可以通过这种方式输入,非英语键盘上的某些字符也是如此(请参阅国际字符集支持)。

Keyboard input into Emacs is based on a heavily-extended version of ASCII. Simple characters, like ‘a’, ‘B’, ‘3’, ‘=’, and the space character (denoted as SPC), are entered by typing the corresponding key. Control characters, such as RET, TAB, DEL, ESC, F1, Home, and LEFT, are also entered this way, as are certain characters found on non-English keyboards (see International Character Set Support).

Emacs 还识别使用修饰键输入的控制字符 。两个常用的修饰键是 Control(通常标记为Ctrl) 和Meta(通常标记为Alt) 3。例如,通过按住键的同时Control-a按 来输入;我们将简称为此。同样,或 简称 是通过按住该键并按 来 输入的。修饰键也可以应用于非字母数字字符,例如或。 CtrlaC-aMeta-aM-aAltaC-F1M-LEFT

Emacs also recognizes control characters that are entered using modifier keys. Two commonly-used modifier keys are Control (usually labeled Ctrl), and Meta (usually labeled Alt)3. For example, Control-a is entered by holding down the Ctrl key while pressing a; we will refer to this as C-a for short. Similarly, Meta-a, or M-a for short, is entered by holding down the Alt key and pressing a. Modifier keys can also be applied to non-alphanumerical characters, e.g., C-F1 or M-LEFT.

您还可以使用以 开头的两个字符序列键入元字符ESC。因此,您可以M-a通过键入 来 输入ESC a。您可以通过键入 来输入C-M-a(按住 CtrlAlt,然后按) 。与 不同的是,是作为单独的字符输入的。键入下一个字符时无需按住;相反,按下并释放它,然后输入下一个字符。此功能在按键无法可靠工作 的某些文本终端上非常有用。aESC C-aMetaESCESCESCMeta

You can also type Meta characters using two-character sequences starting with ESC. Thus, you can enter M-a by typing ESC a. You can enter C-M-a (holding down both Ctrl and Alt, then pressing a) by typing ESC C-a. Unlike Meta, ESC is entered as a separate character. You don’t hold down ESC while typing the next character; instead, press ESC and release it, then enter the next character. This feature is useful on certain text terminals where the Meta key does not function reliably.

Emacs 支持 3 个附加修饰键,请参阅修饰键

Emacs supports 3 additional modifier keys, see Modifier Keys.

Emacs 广泛支持使用鼠标按钮、鼠标滚轮和其他指点设备(例如触摸板和触摸屏)。有关详细信息, 请参阅鼠标输入。

Emacs has extensive support for using mouse buttons, mouse wheels and other pointing devices like touchpads and touch screens. See Mouse Input, for details.

在图形显示上,窗口管理器可能会阻止某些键盘输入, 包括、和。如果您遇到此问题,您可以自定义窗口管理器以不阻止这些键,或重新绑定受影响的 Emacs 命令(请参阅自定义)。 M-TABM-SPCC-M-dC-M-l

On graphical displays, the window manager might block some keyboard inputs, including M-TAB, M-SPC, C-M-d and C-M-l. If you have this problem, you can either customize your window manager to not block those keys, or rebind the affected Emacs commands (see Customization).

简单字符和控制字符,以及某些非键盘输入(例如鼠标单击)统称为输入事件。有关 Emacs 内部如何处理输入事件的详细信息,请参阅Emacs Lisp 参考手册中的输入事件

Simple characters and control characters, as well as certain non-keyboard inputs such as mouse clicks, are collectively referred to as input events. For details about how Emacs internally handles input events, see Input Events in The Emacs Lisp Reference Manual.


3键

3 Keys

一些 Emacs 命令仅由一个输入事件调用;例如,C-f在缓冲区中向前移动一个字符。其他命令需要两个或多个输入事件来调用,例如C-x C-fC-x 4 C-f

Some Emacs commands are invoked by just one input event; for example, C-f moves forward one character in the buffer. Other commands take two or more input events to invoke, such as C-x C-f and C-x 4 C-f.

键序列(或简称)是作为一个单元有意义的一个或多个输入事件的序列。如果一个按键序列调用一个命令,我们称其为完整按键;例如 、 C-fC-x C-f都是C-x 4 C-f完整的键。如果按键序列的长度不足以调用命令,我们将其称为 前缀键;从前面的示例中,我们看到C-xC-x 4是前缀键。每个键序列要么是完整键,要么是前缀键。

A key sequence, or key for short, is a sequence of one or more input events that is meaningful as a unit. If a key sequence invokes a command, we call it a complete key; for example, C-f, C-x C-f and C-x 4 C-f are all complete keys. If a key sequence isn’t long enough to invoke a command, we call it a prefix key; from the preceding example, we see that C-x and C-x 4 are prefix keys. Every key sequence is either a complete key or a prefix key.

前缀键与后续输入事件组合以形成更长的键序列。例如,C-x是前缀键,因此C-x单独键入不会调用命令;相反,Emacs 会等待进一步的输入(如果您暂停超过一秒,它会回显按键C-x以提示输入;请参阅回显区域)。 C-x与下一个输入事件组合以形成双事件键序列,该序列本身可以是前缀键(例如C-x 4),也可以是完整键(例如C-x C-f)。键序列的长度没有限制,但实际上它们很少长于三个或四个输入事件。

A prefix key combines with the following input event to make a longer key sequence. For example, C-x is a prefix key, so typing C-x alone does not invoke a command; instead, Emacs waits for further input (if you pause for longer than a second, it echoes the C-x key to prompt for that input; see The Echo Area). C-x combines with the next input event to make a two-event key sequence, which could itself be a prefix key (such as C-x 4), or a complete key (such as C-x C-f). There is no limit to the length of key sequences, but in practice they are seldom longer than three or four input events.

您无法将输入事件添加到完整的按键上。例如,因为C-f是一个完整的按键,所以双事件序列C-f C-k是两个按键序列,而不是一个。

You can’t add input events onto a complete key. For example, because C-f is a complete key, the two-event sequence C-f C-k is two key sequences, not one.

默认情况下,Emacs 中的前缀键为C-c, C-h, C-x, , , , , , , , , , , , 和。 (和 是和的别名。)这个列表并不是一成不变的;如果您自定义 Emacs,则可以创建新的前缀键。您甚至可以消除一些标准的,尽管不建议大多数用户这样做;例如,如果删除 的前缀定义,则变为无效的键序列。请参阅自定义键绑定C-x RETC-x @C-x aC-x nC-x rC-x tC-x vC-x 4C-x 5C-x 6ESCM-gF1F2C-hC-x 6C-x 4C-x 4 C-f

By default, the prefix keys in Emacs are C-c, C-h, C-x, C-x RET, C-x @, C-x a, C-x n, C-x r, C-x t, C-x v, C-x 4, C-x 5, C-x 6, ESC, and M-g. (F1 and F2 are aliases for C-h and C-x 6.) This list is not cast in stone; if you customize Emacs, you can make new prefix keys. You could even eliminate some of the standard ones, though this is not recommended for most users; for example, if you remove the prefix definition of C-x 4, then C-x 4 C-f becomes an invalid key sequence. See Customizing Key Bindings.

在前缀键后键入帮助字符(C-hF1)会显示以该前缀开头的命令列表。此规则的唯一例外是ESCESC C-h相当于C-M-h,它完全执行其他操作。但是,您可以使用F1显示以 开头的命令列表ESC

Typing the help character (C-h or F1) after a prefix key displays a list of the commands starting with that prefix. The sole exception to this rule is ESC: ESC C-h is equivalent to C-M-h, which does something else entirely. You can, however, use F1 to display a list of commands starting with ESC.


4 鼠标输入

4 Mouse Input

默认情况下,Emacs 支持所有正常的鼠标操作,例如通过单击鼠标左键设置光标,以及通过拖动鼠标指针选择区域。所有鼠标操作都可用于绑定命令,就像将它们绑定到键盘事件一样(请参阅按键)。本节提供了在 Emacs 中使用鼠标的总体概述;有关 Emacs 中鼠标命令的更多详细信息,请参阅用于编辑的鼠标命令及其后面的部分。

By default, Emacs supports all the normal mouse actions like setting the cursor by clicking on the left mouse button, and selecting an area by dragging the mouse pointer. All mouse actions can be used to bind commands in the same way you bind them to keyboard events (see Keys). This section provides a general overview of using the mouse in Emacs; see Mouse Commands for Editing, and the sections that follow it, for more details about mouse commands in Emacs.

当您单击鼠标左键时,Emacs 会收到一个 mouse-1事件。要查看与该事件绑定的命令,您可以键入C-h c然后按鼠标左键。同样,鼠标中键为mouse-2,鼠标右键为 mouse-3。如果您的鼠标带有滚轮,则滚轮事件通常绑定到 或wheel-downwheel-upmouse-4mouse-5,但这取决于操作系统配置。

When you click the left mouse button, Emacs receives a mouse-1 event. To see what command is bound to that event, you can type C-h c and then press the left mouse button. Similarly, the middle mouse button is mouse-2 and the right mouse button is mouse-3. If you have a mouse with a wheel, the wheel events are commonly bound to either wheel-down or wheel-up, or mouse-4 and mouse-5, but that depends on the operating system configuration.

一般来说,旧版 X 系统和终端(请参阅在文本终端中使用鼠标)将报告mouse-4mouse-5,而所有其他系统将报告wheel-downwheel-up

In general, legacy X systems and terminals (see Using a Mouse in Text Terminals) will report mouse-4 and mouse-5, while all other systems will report wheel-down and wheel-up.

有些鼠标还具有水平滚轮,触摸板通常也支持水平滚动。这些事件在除终端和遗留 X 系统之外的所有系统上报告 wheel-left为和 。 wheel-rightmouse-6mouse-7

Some mice also have a horizontal scroll wheel, and touchpads usually support scrolling horizontally as well. These events are reported as wheel-left and wheel-right on all systems other than terminals and legacy X systems, where they are mouse-6 and mouse-7.

您还可以将键盘修饰符与鼠标事件结合起来,这样您就可以绑定一个特殊的命令,该命令会在您按住 Meta 键然后使用鼠标中键时触发。在这种情况下,事件名称将为M-mouse-2

You can also combine keyboard modifiers with mouse events, so you can bind a special command that triggers when you, for instance, holds down the Meta key and then uses the middle mouse button. In that case, the event name will be M-mouse-2.

在某些系统上,您还可以绑定命令来处理触摸屏事件。在这种情况下,事件称为 touchscreen-updatetouchscreen-end

On some systems, you can also bind commands for handling touch screen events. In that case, the events are called touchscreen-update and touchscreen-end.


5 个按键和命令

5 Keys and Commands

本手册充满了告诉您特定键的用途的段落。但 Emacs 并不直接为键赋予含义。相反,Emacs 为命名命令分配含义,然后通过将键绑定到命令来赋予键其含义。

This manual is full of passages that tell you what particular keys do. But Emacs does not assign meanings to keys directly. Instead, Emacs assigns meanings to named commands, and then gives keys their meanings by binding them to commands.

每个命令都有一个由程序员选择的名称。该名称通常由几个用破折号分隔的英文单词组成;例如, next-lineforward-word。在内部,每个命令都是一种特殊类型的 Lisp函数,与命令相关的操作是通过运行该函数来执行的。请参阅Emacs Lisp 参考手册中的什么是函数

Every command has a name chosen by a programmer. The name is usually made of a few English words separated by dashes; for example, next-line or forward-word. Internally, each command is a special type of Lisp function, and the actions associated with the command are performed by running the function. See What Is a Function in The Emacs Lisp Reference Manual.

键和命令之间的绑定记录在称为 键映射的表中。请参阅键盘映射

The bindings between keys and commands are recorded in tables called keymaps. See Keymaps.

当我们说“C-n垂直向下移动一行”时,我们掩盖了一种微妙的区别,这种区别在普通使用中无关紧要,但对于 Emacs 定制至关重要。该命令next-line会垂直向下移动。 C-n具有这种效果是因为它必然是next-line.如果您重新绑定C-n到命令 forward-wordC-n则会向前移动一个单词。

When we say that “C-n moves down vertically one line” we are glossing over a subtle distinction that is irrelevant in ordinary use, but vital for Emacs customization. The command next-line does a vertical move downward. C-n has this effect because it is bound to next-line. If you rebind C-n to the command forward-word, C-n will move forward one word instead.

在本手册中,我们经常将按键视为C-n命令,尽管严格来说按键是绑定到命令的。通常,我们在提到运行该命令的键后,会在括号中声明真正起作用的命令的名称。例如,我们会说“命令C-nnext-line)将点垂直向下移动”,意思是命令next-line垂直向下移动,并且键C-n通常与其绑定。

In this manual, we will often speak of keys like C-n as commands, even though strictly speaking the key is bound to a command. Usually, we state the name of the command which really does the work in parentheses after mentioning the key that runs it. For example, we will say that “The command C-n (next-line) moves point vertically down”, meaning that the command next-line moves vertically down, and the key C-n is normally bound to it.

既然我们正在讨论定制,我们应该告诉你 变量。命令的描述通常会说:“要更改此设置,请设置变量mumble-foo。”变量是用于存储值的名称。本手册中记录的大多数变量都是为了自定义:Emacs 的某些命令或其他部分会检查变量,并根据您设置的值表现出不同的行为。您可以忽略有关变量的信息,直到您有兴趣自定义它们为止。然后阅读变量的基本信息(参见变量),特定变量的信息就会有意义。

Since we are discussing customization, we should tell you about variables. Often the description of a command will say, “To change this, set the variable mumble-foo.” A variable is a name used to store a value. Most of the variables documented in this manual are meant for customization: some command or other part of Emacs examines the variable and behaves differently according to the value that you set. You can ignore the information about variables until you are interested in customizing them. Then read the basic information on variables (see Variables) and the information about specific variables will make sense.


6 进入Emacs

6 Entering Emacs

调用 Emacs 的常用方法是使用 shell 命令 emacs。从在 GUI 终端上运行 Unix shell 的终端窗口中,您可以使用emacs &;在后台运行 Emacs 。这样,Emacs 就不会占用终端窗口,因此您可以使用它来运行其他 shell 命令。 (有关在 MS-Windows 上启动 Emacs 的类似方法,请参阅如何在 MS-Windows 上启动 Emacs。)

The usual way to invoke Emacs is with the shell command emacs. From a terminal window running a Unix shell on a GUI terminal, you can run Emacs in the background with emacs &; this way, Emacs won’t tie up the terminal window, so you can use it to run other shell commands. (For comparable methods of starting Emacs on MS-Windows, see How to Start Emacs on MS-Windows.)

当 Emacs 启动时,初始帧显示一个名为 '*GNU Emacs*'。此启动屏幕包含有关 Emacs 的信息以及对初学者有用的常见任务的链接。例如,激活 'Emacs教程' 链接打开 Emacs 教程;这与命令C-h t( )的作用相同help-with-tutorial。要激活链接,请将点移到其上并键入,或使用(鼠标左键) RET单击它。mouse-1

When Emacs starts up, the initial frame displays a special buffer named ‘*GNU Emacs*’. This startup screen contains information about Emacs and links to common tasks that are useful for beginning users. For instance, activating the ‘Emacs Tutorial’ link opens the Emacs tutorial; this does the same thing as the command C-h t (help-with-tutorial). To activate a link, either move point onto it and type RET, or click on it with mouse-1 (the left mouse button).

使用命令行参数,您可以告诉 Emacs 在启动时立即访问一个或多个文件。例如,emacs foo.txt启动 Emacs,并使用显示文件内容的缓冲区 'foo.txt'。此功能的存在主要是为了与其他编辑器兼容,这些编辑器旨在从 shell 启动以进行简短的编辑会话。如果您以这种方式调用 Emacs,初始框架将分为两个窗口 — 一个显示指定的文件,另一个显示启动屏幕。请参阅多个窗口

Using a command line argument, you can tell Emacs to visit one or more files as soon as it starts up. For example, emacs foo.txt starts Emacs with a buffer displaying the contents of the file ‘foo.txt’. This feature exists mainly for compatibility with other editors, which are designed to be launched from the shell for short editing sessions. If you call Emacs this way, the initial frame is split into two windows—one showing the specified file, and the other showing the startup screen. See Multiple Windows.

一般来说,每次编辑文件时都重新启动 Emacs 是不必要的,也是浪费的。使用 Emacs 的推荐方法是在登录后仅启动一次,并在同一个 Emacs 会话中进行所有编辑。有关访问多个文件的信息,请参阅文件处理。如果您以这种方式使用 Emacs,Emacs 会话会积累有价值的上下文,例如终止环、寄存器、撤消历史记录和标记环数据,这些一起使编辑更加方便。这些功能将在手册后面进行描述。

Generally, it is unnecessary and wasteful to start Emacs afresh each time you want to edit a file. The recommended way to use Emacs is to start it just once, just after you log in, and do all your editing in the same Emacs session. See File Handling, for information on visiting more than one file. If you use Emacs this way, the Emacs session accumulates valuable context, such as the kill ring, registers, undo history, and mark ring data, which together make editing more convenient. These features are described later in the manual.

要在 Emacs 运行时从另一个程序编辑文件,您可以使用emacsclient帮助程序在现有 Emacs 会话中打开文件。请参阅使用 Emacs 作为服务器

To edit a file from another program while Emacs is running, you can use the emacsclient helper program to open a file in the existing Emacs session. See Using Emacs as a Server.

Emacs 接受其他命令行参数,告诉它加载某些 Lisp 文件、在哪里放置初始框架等等。请参阅Emacs 调用的命令行参数

Emacs accepts other command line arguments that tell it to load certain Lisp files, where to put the initial frame, and so forth. See Command Line Arguments for Emacs Invocation.

如果该变量inhibit-startup-screen为非 - nil,Emacs 不会显示启动屏幕。在这种情况下,如果在命令行上指定了一个或多个文件,Emacs 只会显示这些文件;否则,它会显示一个名为*划痕*,可用于交互式地计算 Emacs Lisp 表达式。请参阅Lisp 交互缓冲区。您可以inhibit-startup-screen使用自定义工具(请参阅轻松自定义界面)或通过编辑初始化文件(请参阅Emacs 初始化文件)来设置变量 。4

If the variable inhibit-startup-screen is non-nil, Emacs does not display the startup screen. In that case, if one or more files were specified on the command line, Emacs simply displays those files; otherwise, it displays a buffer named *scratch*, which can be used to evaluate Emacs Lisp expressions interactively. See Lisp Interaction Buffers. You can set the variable inhibit-startup-screen using the Customize facility (see Easy Customization Interface), or by editing your initialization file (see The Emacs Initialization File).4

您还可以通过将变量设置initial-buffer-choice为命名该文件或目录的字符串来强制 Emacs 在启动时显示该文件或目录。的值 initial-buffer-choice也可以是一个函数(无参数),它应该返回一个随后显示的缓冲区。如果initial-buffer-choice是非- nil,那么如果您在命令行上指定任何文件,Emacs 仍然会访问它们,但最初不会显示它们。

You can also force Emacs to display a file or directory at startup by setting the variable initial-buffer-choice to a string naming that file or directory. The value of initial-buffer-choice may also be a function (of no arguments) that should return a buffer which is then displayed. If initial-buffer-choice is non-nil, then if you specify any files on the command line, Emacs still visits them, but does not display them initially.


7 退出 Emacs

7 Exiting Emacs

C-x C-c
C-x C-c

杀死 Emacs ( save-buffers-kill-terminal)。

Kill Emacs (save-buffers-kill-terminal).

C-z
C-z

在文本终端上,暂停 Emacs;在图形显示上,图标化(或“最小化”)所选框架 ( suspend-frame)。

On a text terminal, suspend Emacs; on a graphical display, iconify (or “minimize”) the selected frame (suspend-frame).

杀死Emacs 意味着终止 Emacs 程序。为此,请键入C-x C-c( save-buffers-kill-terminal)。使用两个字符的按键序列可防止意外键入。如果在您键入 时有任何修改的文件访问缓冲区C-x C-c,Emacs 首先会提议保存这些缓冲区。如果您不全部保存,则会要求再次确认,因为未保存的更改将丢失。 Emacs 还要求确认是否有任何子进程仍在运行,因为终止 Emacs 也会终止子进程(请参阅从 Emacs 运行 Shell 命令)。

Killing Emacs means terminating the Emacs program. To do this, type C-x C-c (save-buffers-kill-terminal). A two-character key sequence is used to make it harder to type by accident. If there are any modified file-visiting buffers when you type C-x C-c, Emacs first offers to save these buffers. If you do not save them all, it asks for confirmation again, since the unsaved changes will be lost. Emacs also asks for confirmation if any subprocesses are still running, since killing Emacs will also kill the subprocesses (see Running Shell Commands from Emacs).

C-x C-c如果您使用 Emacs 作为服务器,则会出现特殊行为。如果您从客户端框架键入它,它将关闭客户端连接。请参阅使用 Emacs 作为服务器

C-x C-c behaves specially if you are using Emacs as a server. If you type it from a client frame, it closes the client connection. See Using Emacs as a Server.

Emacs 可以选择在您终止它时记录某些会话信息,例如您当时正在访问的文件。下次启动 Emacs 时即可使用此信息。请参阅保存 Emacs 会话

Emacs can, optionally, record certain session information when you kill it, such as the files you were visiting at the time. This information is then available the next time you start Emacs. See Saving Emacs Sessions.

如果变量的值为confirm-kill-emacsnon- nilC-x C-c则假定其值是谓词函数,并调用该函数。如果函数调用的结果为非nil,则会话被终止,否则 Emacs 继续运行。confirm-kill-emacs函数 是一种可以方便地用作 的值的函数 yes-or-no-pconfirm-kill-emacs的默认值为nil

If the value of the variable confirm-kill-emacs is non-nil, C-x C-c assumes that its value is a predicate function, and calls that function. If the result of the function call is non-nil, the session is killed, otherwise Emacs continues to run. One convenient function to use as the value of confirm-kill-emacs is the function yes-or-no-p. The default value of confirm-kill-emacs is nil.

如果变量的值为confirm-kill-processesnilC-x C-c在终止 Emacs 启动的子进程之前不要求确认。该值为t默认值。

If the value of the variable confirm-kill-processes is nil, C-x C-c does not ask for confirmation before killing subprocesses started by Emacs. The value is t by default.

要进一步自定义 Emacs 退出时发生的情况,请参阅 《GNU Emacs Lisp 参考手册》中的终止 Emacs

To further customize what happens when Emacs is exiting, see Killing Emacs in The GNU Emacs Lisp Reference Manual.

要终止 Emacs 而不提示保存,请输入M-x kill-emacs

To kill Emacs without being prompted about saving, type M-x kill-emacs.

C-z运行命令suspend-frame。在图形显示上,此命令最小化(或图标化)选定的 Emacs 框架,以某种方式隐藏它,以便您稍后将其恢复(这种隐藏的具体方式取决于窗口系统)。在文本终端上,该C-z命令会挂起Emacs,暂时停止程序并将控制权返回给父进程(通常是 shell);在大多数 shell 中,您可以在使用 shell 命令暂停 Emacs 后恢复它%emacs

C-z runs the command suspend-frame. On a graphical display, this command minimizes (or iconifies) the selected Emacs frame, hiding it in a way that lets you bring it back later (exactly how this hiding occurs depends on the window system). On a text terminal, the C-z command suspends Emacs, stopping the program temporarily and returning control to the parent process (usually a shell); in most shells, you can resume Emacs after suspending it with the shell command %emacs.

文本终端通常侦听某些特殊字符,其含义是终止或挂起正在运行的程序。 当您使用 Emacs 时,此终端功能将被关闭。C-z Emacs 中和作为键 的含义C-x C-c受到了在多个操作系统上使用C-zC-c作为停止或终止程序的字符的启发,但这是它们与操作系统的唯一关系。您可以自定义这些键来运行您选择的任何命令(请参阅键盘映射)。

Text terminals usually listen for certain special characters whose meaning is to kill or suspend the program you are running. This terminal feature is turned off while you are in Emacs. The meanings of C-z and C-x C-c as keys in Emacs were inspired by the use of C-z and C-c on several operating systems as the characters for stopping or killing a program, but that is their only relationship with the operating system. You can customize these keys to run any commands of your choice (see Keymaps).


8 个基本编辑命令

8 Basic Editing Commands

在这里,我们解释如何输入文本、进行更正以及将文本保存在文件中的基础知识。如果您对本材料不熟悉,我们建议您首先通过输入C-h t( )来运行 Emacs 边做边学教程 help-with-tutorial

Here we explain the basics of how to enter text, make corrections, and save the text in a file. If this material is new to you, we suggest you first run the Emacs learn-by-doing tutorial, by typing C-h t (help-with-tutorial).


8.1 插入文本

8.1 Inserting Text

您可以插入普通图形字符(例如,'A','','3', 和 '=') 通过键入关联的键。这会将字符添加到缓冲区中的点。插入将点向前移动,以便该点保留在插入的文本后面。参见

You can insert an ordinary graphic character (e.g., ‘a’, ‘B’, ‘3’, and ‘=’) by typing the associated key. This adds the character to the buffer at point. Insertion moves point forward, so that point remains just after the inserted text. See Point.

要结束一行并开始新一行,请键入RET( newline)。 (该RET键可能在键盘上标记为Return、 或Enter,或 并带有一个看起来很滑稽的向左箭头,但我们RET在本手册中是这样称呼它的。)此命令将换行符插入到缓冲区中,然后缩进(请参阅缩进)根据主要模式。如果 point 位于行尾,则效果是在其后创建一个新的空行并缩进新行;如果点位于一条线的中间,则该线在该位置被分割。要关闭自动缩进,您可以禁用电动缩进模式(请参阅缩进的便利功能)或键入C-j,这将仅插入换行符,而无需任何自动缩进。

To end a line and start a new one, type RET (newline). (The RET key may be labeled Return, or Enter, or with a funny-looking left-pointing arrow on your keyboard, but we refer to it as RET in this manual.) This command inserts a newline character into the buffer, then indents (see Indentation) according to the major mode. If point is at the end of the line, the effect is to create a new blank line after it and indent the new line; if point is in the middle of a line, the line is split at that position. To turn off the auto-indentation, you can either disable Electric Indent mode (see Convenience Features for Indentation) or type C-j, which inserts just a newline, without any auto-indentation.

正如我们在本手册后面所解释的,您可以通过打开次要模式来更改 Emacs 处理文本插入的方式。例如,称为自动填充模式的次要模式会在行太长时自动分割行(请参阅填充文本)。称为覆盖模式的次要模式会导致插入的字符替换(覆盖)现有文本,而不是将其推到右侧。请参阅次要模式

As we explain later in this manual, you can change the way Emacs handles text insertion by turning on minor modes. For instance, the minor mode called Auto Fill mode splits lines automatically when they get too long (see Filling Text). The minor mode called Overwrite mode causes inserted characters to replace (overwrite) existing text, instead of shoving it to the right. See Minor Modes.

通过键入相关键只能插入图形字符;其他键充当编辑命令并且不会自行插入。例如, 默认DEL运行命令(某些模式将其绑定到不同的命令);delete-backward-char它不会插入文字 '德尔' 字符(ASCII字符代码 127)。

Only graphic characters can be inserted by typing the associated key; other keys act as editing commands and do not insert themselves. For instance, DEL runs the command delete-backward-char by default (some modes bind it to a different command); it does not insert a literal ‘DEL’ character (ASCII character code 127).

要插入非图形字符或键盘不支持的字符,请首先键入 ( ) 将其引用。有两种使用方法: C-qquoted-insertC-q

To insert a non-graphic character, or a character that your keyboard does not support, first quote it by typing C-q (quoted-insert). There are two ways to use C-q:

  • C-q后跟任何非图形字符(甚至C-g)插入该字符。例如,插入文字 'C-q DEL德尔' 特点。
  • C-q followed by any non-graphic character (even C-g) inserts that character. For instance, C-q DEL inserts a literal ‘DEL’ character.
  • C-q后跟八进制数字序列插入具有指定八进制字符代码的字符。您可以使用任意数量的八进制数字;任何非数字都会终止序列。如果终止字符是RET,则RET仅用于终止序列。任何其他非数字都会终止序列,然后充当正常输入 - 因此,C-q 1 0 1 B插入 'AB'。

    在普通非二进制覆盖模式下禁用八进制序列的使用,以便为您提供一种方便的方法来插入数字而不是用它进行覆盖。

  • C-q followed by a sequence of octal digits inserts the character with the specified octal character code. You can use any number of octal digits; any non-digit terminates the sequence. If the terminating character is RET, that RET serves only to terminate the sequence. Any other non-digit terminates the sequence and then acts as normal input—thus, C-q 1 0 1 B inserts ‘AB’.

    The use of octal sequences is disabled in ordinary non-binary Overwrite mode, to give you a convenient way to insert a digit instead of overwriting with it.

要使用十进制或十六进制代替八进制,请将变量设置 read-quoted-char-radix为 10 或 16。如果基数为 16,则字母af用作字符代码的一部分,就像数字一样。大小写被忽略。

To use decimal or hexadecimal instead of octal, set the variable read-quoted-char-radix to 10 or 16. If the radix is 16, the letters a to f serve as part of a character code, just like digits. Case is ignored.

可以通过以 开头的命令插入一些常见的 Unicode 字符C-x 8。例如,C-x 8 [插入 Unicode 代码点 U+2018左单引号,有时称为左单“弯引号”或“弯引号”。同样,C-x 8 ]C-x 8 {和分别C-x 8 }插入弯曲引号。此外,工作 Alt键的作用类似于C-x 8(除非后面跟着RET);例如,A-[行为类似于C-x 8 [并插入。要查看哪些字符有C-x 8简写,请输入C-x 8 C-h

A few common Unicode characters can be inserted via a command starting with C-x 8. For example, C-x 8 [ inserts which is Unicode code-point U+2018 LEFT SINGLE QUOTATION MARK, sometimes called a left single “curved quote” or “curly quote”. Similarly, C-x 8 ], C-x 8 { and C-x 8 } insert the curved quotes , and , respectively. Also, a working Alt key acts like C-x 8 (unless followed by RET); e.g., A-[ acts like C-x 8 [ and inserts . To see which characters have C-x 8 shorthands, type C-x 8 C-h.

或者,您可以使用命令 ( )。这将提示使用迷你缓冲区输入字符的 Unicode 名称或代码点。如果您输入名称,该命令会提供补全(请参阅补全)。如果输入代码点,它应该是十六进制数字(Unicode 的约定),或具有指定基数的数字,例如 (八进制);请参阅Emacs Lisp 参考手册中的整数基础知识。然后该命令将相应的字符插入到缓冲区中。 C-x 8 RETinsert-char#o23072

Alternatively, you can use the command C-x 8 RET (insert-char). This prompts for the Unicode name or code-point of a character, using the minibuffer. If you enter a name, the command provides completion (see Completion). If you enter a code-point, it should be as a hexadecimal number (the convention for Unicode), or a number with a specified radix, e.g., #o23072 (octal); See Integer Basics in The Emacs Lisp Reference Manual. The command then inserts the corresponding character into the buffer.

例如,以下都插入相同的字符:

For example, the following all insert the same character:

C-x 8 RET left single quotation mark RET
C-x 8 RET left sin TAB RET
C-x 8 RET 2018 RET
C-x 8 [
A-[  (如果 Alt 键有效)
`    (在电子报价模式下)
C-x 8 RET left single quotation mark RET
C-x 8 RET left sin TAB RET
C-x 8 RET 2018 RET
C-x 8 [
A-[  (if the Alt key works)
`    (in Electric Quote mode)

C-q或的数字参数C-x 8 ...指定要插入的字符的数量(请参阅数字参数)。

A numeric argument to C-q or C-x 8 ... specifies how many copies of the character to insert (see Numeric Arguments).

作为 的替代方法C-x 8,您可以通过键入 来选择相应的瞬时输入法,然后通过键入暂时激活该瞬时输入法 将插入相同的字符(请参阅瞬时输入法)。 C-u C-x \ iso-transl RETC-x \ [

As an alternative to C-x 8, you can select the corresponding transient input method by typing C-u C-x \ iso-transl RET, then temporarily activating this transient input method by typing C-x \ [ will insert the same character (see transient input method).

此外,在某些上下文中,如果您使用重音符号和撇号键入引文,即使没有命令,它也会转换为使用单引号的`like this'形式 。同样,使用双重音符号和撇号键入引文会将其转换为使用双引号的形式。请参阅引号‘like this’C-x 8``like this''“like this”

In addition, in some contexts, if you type a quotation using grave accent and apostrophe `like this', it is converted to a form ‘like this’ using single quotation marks, even without C-x 8 commands. Similarly, typing a quotation ``like this'' using double grave accent and apostrophe converts it to a form “like this” using double quotation marks. See Quotation Marks.


8.2 改变点的位置

8.2 Changing the Location of Point

除了插入字符之外,您还必须知道如何移动点(请参阅Point)。键盘命令C-fC-bC-nC-p分别向右、向左、向下和向上移动光标。您还可以使用 大多数键盘上的箭头键RIGHT移动点: 、LEFTDOWNUP;然而,许多 Emacs 用户发现使用箭头键比使用控制键慢,因为您需要将手移到这些键所在的键盘区域。

To do more than insert characters, you have to know how to move point (see Point). The keyboard commands C-f, C-b, C-n, and C-p move point to the right, left, down, and up, respectively. You can also move point using the arrow keys present on most keyboards: RIGHT, LEFT, DOWN, and UP; however, many Emacs users find that it is slower to use the arrow keys than the control keys, because you need to move your hand to the area of the keyboard where those keys are located.

您也可以单击鼠标左键将点移动到单击的位置。 Emacs 还提供了各种附加的键盘命令,可以以更复杂的方式移动点。

You can also click the left mouse button to move point to the position clicked. Emacs also provides a variety of additional keyboard commands that move point in more sophisticated ways.

C-f
C-f

向前移动一个字符 ( forward-char)。

Move forward one character (forward-char).

RIGHT
RIGHT

此命令 ( right-char) 的行为类似于C-f,但点位于从右到左的段落中时除外(请参阅双向编辑)。

This command (right-char) behaves like C-f, except when point is in a right-to-left paragraph (see Bidirectional Editing).

C-b
C-b

向后移动一个字符 ( backward-char)。

Move backward one character (backward-char).

LEFT
LEFT

此命令 ( left-char) 的行为类似于C-b,除非当前段落是从右到左的(请参阅双向编辑)。

This command (left-char) behaves like C-b, except if the current paragraph is right-to-left (see Bidirectional Editing).

C-n
C-n
DOWN
DOWN

向下移动一屏行 ( next-line)。此命令尝试保持水平位置不变,因此如果您从一行的中间开始,则会移动到下一行的中间。

Move down one screen line (next-line). This command attempts to keep the horizontal position unchanged, so if you start in the middle of one line, you move to the middle of the next.

C-p
C-p
UP
UP

向上移动一屏行 ( previous-line)。此命令保留行内的位置,例如C-n.

Move up one screen line (previous-line). This command preserves position within the line, like C-n.

C-a
C-a
Home
Home

移至行首 ( move-beginning-of-line)。

Move to the beginning of the line (move-beginning-of-line).

C-e
C-e
End
End

移至行尾 ( move-end-of-line)。

Move to the end of the line (move-end-of-line).

M-f
M-f

向前移动一个字(forward-word)。见

Move forward one word (forward-word). See Words.

C-RIGHT
C-RIGHT
M-RIGHT
M-RIGHT

此命令 ( right-word) 的行为类似于M-f,但如果当前段落是从右向左排列,则该命令会向后移动一个单词。请参阅双向编辑

This command (right-word) behaves like M-f, except it moves backward by one word if the current paragraph is right-to-left. See Bidirectional Editing.

M-b
M-b

向后移动一个字(backward-word)。见

Move backward one word (backward-word). See Words.

C-LEFT
C-LEFT
M-LEFT
M-LEFT

此命令 ( left-word) 的行为类似于M-b,但如果当前段落是从右向左排列,则该命令会向前移动一个单词。请参阅双向编辑

This command (left-word) behaves like M-b, except it moves forward by one word if the current paragraph is right-to-left. See Bidirectional Editing.

M-r
M-r

不移动屏幕上的文本,将点重新定位到窗口最中心文本行的左边距;在随后的连续调用中,将点按循环顺序移动到最顶行、最底行等的左边距 ( move-to-window-line-top-bottom)。

数字参数表示将点放置在哪一行屏幕上,从窗口顶部向下计数(零表示顶行)。负参数从底部开始计算行数(-1 表示底部行)。有关数字参数的更多信息, 请参阅数字参数。

Without moving the text on the screen, reposition point on the left margin of the center-most text line of the window; on subsequent consecutive invocations, move point to the left margin of the top-most line, the bottom-most line, and so forth, in cyclic order (move-to-window-line-top-bottom).

A numeric argument says which screen line to place point on, counting downward from the top of the window (zero means the top line). A negative argument counts lines up from the bottom (−1 means the bottom line). See Numeric Arguments, for more information on numeric arguments.

M-<
M-<

移至缓冲区顶部 ( beginning-of-buffer)。使用数字参数n ,从顶部移至n /10。在图形显示上,执行相同的操作。 C-HOME

Move to the top of the buffer (beginning-of-buffer). With numeric argument n, move to n/10 of the way from the top. On graphical displays, C-HOME does the same.

M->
M->

移至缓冲区末尾 ( end-of-buffer)。在图形显示上,执行相同的操作。 C-END

Move to the end of the buffer (end-of-buffer). On graphical displays, C-END does the same.

C-v
C-v
PageDown
PageDown
next
next

将显示屏向前滚动一屏,并根据需要移动屏幕上的点 ( scroll-up-command)。请参阅滚动

Scroll the display one screen forward, and move point onscreen if necessary (scroll-up-command). See Scrolling.

M-v
M-v
PageUp
PageUp
prior
prior

向后滚动一屏幕,并根据需要移动屏幕上的点 ( scroll-down-command)。请参阅滚动

Scroll one screen backward, and move point onscreen if necessary (scroll-down-command). See Scrolling.

M-g c
M-g c

读取数字n并将指针移动到缓冲区位置n。位置 1 是缓冲区的开头。如果 point 位于缓冲区中的数字上或紧随其后,则这是n的默认值。只需输入RET迷你缓冲区即可使用它。您还可以 通过给出数字前缀参数 来指定n 。M-g c

Read a number n and move point to buffer position n. Position 1 is the beginning of the buffer. If point is on or just after a number in the buffer, that is the default for n. Just type RET in the minibuffer to use it. You can also specify n by giving M-g c a numeric prefix argument.

M-g M-g
M-g M-g
M-g g
M-g g

读取数字n并将指针移动到第n行的开头 ( goto-line)。第 1 行是缓冲区的开始。如果 point 位于缓冲区中的数字上或紧随其后,则这是n的默认值。只需输入RET迷你缓冲区即可使用它。您还可以通过给出数字前缀参数来指定nM-g M-g 。请参阅创建和选择缓冲区M-g M-g,了解当您为其提供普通前缀参数时的行为。或者,您可以使用该命令 goto-line-relative将点移动到相对于缩小缓冲区的可访问部分的行。

goto-line有自己的历史列表(参见Minibuffer History)。通过自定义用户选项,您可以在所有缓冲区之间共享一个列表(默认),也可以为每个缓冲区创建一个单独的列表goto-line-history-local

Read a number n and move point to the beginning of line number n (goto-line). Line 1 is the beginning of the buffer. If point is on or just after a number in the buffer, that is the default for n. Just type RET in the minibuffer to use it. You can also specify n by giving M-g M-g a numeric prefix argument. See Creating and Selecting Buffers, for the behavior of M-g M-g when you give it a plain prefix argument. Alternatively, you can use the command goto-line-relative to move point to the line relative to the accessible portion of the narrowed buffer.

goto-line has its own history list (see Minibuffer History). You can have either a single list shared between all buffers (the default) or a separate list for each buffer, by customizing the user option goto-line-history-local.

M-g TAB
M-g TAB

读取数字n并移至当前行中的第n列。第 0 列是最左边的列。如果使用前缀参数调用,则移动到参数数值指定的列号。

Read a number n and move to column n in the current line. Column 0 is the leftmost column. If called with a prefix argument, move to the column number specified by the argument’s numeric value.

C-x C-n
C-x C-n

使用点的当前列作为当前缓冲区中的半永久目标列 ( )。set-goal-column当半永久球门柱生效时,C-nC-p<prior><next>在垂直移动后始终尝试移至该柱,或尽可能靠近该柱。目标栏在取消之前一直有效。

Use the current column of point as the semipermanent goal column (set-goal-column) in the current buffer. When a semipermanent goal column is in effect, C-n, C-p, <prior> and <next> always try to move to this column, or as close as possible to it, after moving vertically. The goal column remains in effect until canceled.

C-u C-x C-n
C-u C-x C-n

取消目标栏。从今以后,C-nC-p往常一样,尽量保持水平位置。

Cancel the goal column. Henceforth, C-n and C-p try to preserve the horizontal position, as usual.

当缓冲区中的一行文本比窗口的宽度长时,Emacs 通常将其显示在两条或更多条屏幕线(也称为视觉线)上。为了方便起见,C-n可以C-p 按屏幕线移动点,就像等效键down 和一样up。您可以通过将变量设置为;来强制这些命令根据 逻辑行(即根据缓冲区中的文本行)移动。如果逻辑行占用多个屏幕行,则光标会跳过其他屏幕行。有关详细信息,请参阅延续线。请参阅变量,了解如何设置变量,例如 . line-move-visualnilline-move-visual

When a line of text in the buffer is longer than the width of the window, Emacs usually displays it on two or more screen lines, a.k.a. visual lines. For convenience, C-n and C-p move point by screen lines, as do the equivalent keys down and up. You can force these commands to move according to logical lines (i.e., according to the text lines in the buffer) by setting the variable line-move-visual to nil; if a logical line occupies multiple screen lines, the cursor then skips over the additional screen lines. For details, see Continuation Lines. See Variables, for how to set variables such as line-move-visual.

C-n与和不同C-p,大多数作用于行的 Emacs 命令作用于逻辑行。例如,C-a ( move-beginning-of-line) 和C-e ( move-end-of-line) 分别移动到逻辑行的开头和结尾。每当我们遇到在屏幕行上运行的命令(例如C-n和 )时C-p,我们都会指出这些命令。

Unlike C-n and C-p, most of the Emacs commands that work on lines work on logical lines. For instance, C-a (move-beginning-of-line) and C-e (move-end-of-line) respectively move to the beginning and end of the logical line. Whenever we encounter commands that work on screen lines, such as C-n and C-p, we will point these out.

line-move-visual是时nil,您还可以将变量设置track-eol为非值nil。然后C-nC-p,当从逻辑行末尾开始时,移动到下一个逻辑行末尾。通常情况下,track-eolnil.

When line-move-visual is nil, you can also set the variable track-eol to a non-nil value. Then C-n and C-p, when starting at the end of the logical line, move to the end of the next logical line. Normally, track-eol is nil.

C-n当您在缓冲区的最后一行使用它时,通常会在缓冲区的末尾停止。但是,如果将变量设置 next-line-add-newlines为非值nil,则C-n缓冲区的最后一行会在末尾创建一个附加行并向下移动到其中。

C-n normally stops at the end of the buffer when you use it on the last line in the buffer. However, if you set the variable next-line-add-newlines to a non-nil value, C-n on the last line of a buffer creates an additional line at the end and moves down into it.


8.3 擦除文本

8.3 Erasing Text

DEL
DEL
BACKSPACE
BACKSPACE

删除点之前的字符,或者如果区域处于活动状态 ( delete-backward-char),则删除该区域。

Delete the character before point, or the region if it is active (delete-backward-char).

Delete
Delete

删除点后的字符,或区域(如果其处于活动状态)( delete-forward-char)。

Delete the character after point, or the region if it is active (delete-forward-char).

C-d
C-d

删除( )点之后的字符delete-char

Delete the character after point (delete-char).

C-k
C-k

杀到行尾 ( kill-line)。

Kill to the end of the line (kill-line).

M-d
M-d

向前杀到下一个单词的末尾 ( kill-word)。

Kill forward to the end of the next word (kill-word).

M-DEL
M-DEL
M-BACKSPACE
M-BACKSPACE

杀回上一个单词的开头 ( backward-kill-word)。

Kill back to the beginning of the previous word (backward-kill-word).

DEL( )命令delete-backward-char删除 point 之前的字符,同时向后移动光标及其后面的字符。如果 point 位于一行的开头,则会删除前面的换行符,将该行连接到上一行。

The DEL (delete-backward-char) command removes the character before point, moving the cursor and the characters after it backwards. If point was at the beginning of a line, this deletes the preceding newline, joining this line to the previous one.

但是,如果该区域处于活动状态,DEL则删除该区域中的文本。有关区域的描述, 请参阅标记和区域。

If, however, the region is active, DEL instead deletes the text in the region. See The Mark and the Region, for a description of the region.

在大多数键盘上,DEL标记为,但我们在本手册中BACKSPACE引用它。 DEL(不要DELDelete键混淆;我们将Delete立即讨论。)在某些文本终端上,Emacs 可能无法DEL正确识别该键。如果您遇到此问题, 请参阅如果DEL删除失败。

On most keyboards, DEL is labeled BACKSPACE, but we refer to it as DEL in this manual. (Do not confuse DEL with the Delete key; we will discuss Delete momentarily.) On some text terminals, Emacs may not recognize the DEL key properly. See If DEL Fails to Delete, if you encounter this problem.

Delete( )命令delete-forward-char的删除方向相反:删除点之后的字符,即光标下的字符。如果点位于一行的末尾,则会将下一行连接到这一行上。与 一样DEL,如果该区域处于活动状态,它会删除该区域中的文本(请参阅标记和区域)。

The Delete (delete-forward-char) command deletes in the opposite direction: it deletes the character after point, i.e., the character under the cursor. If point was at the end of a line, this joins the following line onto this one. Like DEL, it deletes the text in the region if the region is active (see The Mark and the Region).

C-d( delete-char) 删除点之后的字符,与 类似Delete,但无论该区域是否处于活动状态。

C-d (delete-char) deletes the character after point, similar to Delete, but regardless of whether the region is active.

有关上述删除命令的更多详细信息, 请参阅删除。

See Deletion, for more detailed information about the above deletion commands.

C-k( kill-line) 一次擦除(删除)一行。如果您C-k在行首或中间键入,则会删除直到行尾的所有文本。如果您C-k在一行末尾键入,则会将该行与下一行连接起来。

C-k (kill-line) erases (kills) a line at a time. If you type C-k at the beginning or middle of a line, it kills all the text up to the end of the line. If you type C-k at the end of a line, it joins that line with the following line.

有关命令和相关命令的 更多信息,请参阅删除和移动文本。C-k

See Killing and Moving Text, for more information about C-k and related commands.


8.4 撤销更改

8.4 Undoing Changes

C-/
C-/
C-x u
C-x u
C-_
C-_

撤消撤消记录中的一项——通常一个命令值 ( undo)。 (第一个键在文本模式显示器上可能不可用。)

Undo one entry of the undo records—usually, one command worth (undo). (The first key might be unavailable on text-mode displays.)

Emacs 记录缓冲区文本中所做更改的列表,以便您可以撤消最近的更改。这是使用undo绑定到C-/(以及C-x uC-_) 的命令完成的。通常,此命令会撤消上次更改,将点移回更改前的位置。撤消命令仅适用于缓冲区中的更改;您不能使用它来撤消光标移动。

Emacs records a list of changes made in the buffer text, so you can undo recent changes. This is done using the undo command, which is bound to C-/ (as well as C-x u and C-_). Normally, this command undoes the last change, moving point back to where it was before the change. The undo command applies only to changes in the buffer; you can’t use it to undo cursor motion.

在支持所有其他键上的修饰符的终端上Control,最简单的调用方法undo是 with C-/,因为它不需要Shift修饰符。在只允许 ASCII 控制字符的终端上,C-/不存在,但对于许多终端来说C-/仍然有效,因为它实际上发送C-_ 到 Emacs,而许多其他终端允许您Shift在键入时省略修饰符C-_(实际上是按C--),这使得它成为最有效的选择。方便的调用方式undo

On a terminal that supports the Control modifier on all other keys, the easiest way to invoke undo is with C-/, since that doesn’t need the Shift modifier. On terminals which allow only the ASCII control characters, C-/ does not exist, but for many of them C-/ still works because it actually sends C-_ to Emacs, while many others allow you to omit the Shift modifier when you type C-_ (in effect pressing C--), making that the most convenient way to invoke undo.

虽然每个编辑命令通常在撤消记录中生成单独的条目,但是非常简单的命令可以组合在一起。有时,一个条目可能只涵盖复杂命令的一部分。

Although each editing command usually makes a separate entry in the undo records, very simple commands may be grouped together. Sometimes, an entry may cover just part of a complex command.

如果重复C-/(或其别名),则每次重复都会撤消另一个较早的更改,回到可用撤消信息的限制。如果所有记录的更改均已撤消,则撤消命令将显示一条错误消息并且不执行任何操作。

If you repeat C-/ (or its aliases), each repetition undoes another, earlier change, back to the limit of the undo information available. If all recorded changes have already been undone, the undo command displays an error message and does nothing.

要了解有关该undo命令的更多信息,请参阅撤消

To learn more about the undo command, see Undo.


8.5 文件

8.5 Files

您插入 Emacs 缓冲区中的文本仅持续与 Emacs 会话一样长的时间。要永久保留任何文本,您必须将其放入文件

Text that you insert in an Emacs buffer lasts only as long as the Emacs session. To keep any text permanently, you must put it in a file.

假设有一个文件名为测试.emacs在你的主目录中。要开始在 Emacs 中编辑此文件,请输入

Suppose there is a file named test.emacs in your home directory. To begin editing this file in Emacs, type

Cx Cf test.emacsRET
C-x C-f test.emacs RET

这里文件名作为命令( ) 的参数给出。该命令使用迷你缓冲区来读取参数,然后您键入以终止该参数(请参阅迷你缓冲区)。 C-x C-ffind-fileRET

Here the file name is given as an argument to the command C-x C-f (find-file). That command uses the minibuffer to read the argument, and you type RET to terminate the argument (see The Minibuffer).

Emacs 通过访问文件来遵守此命令:它创建一个缓冲区,将文件的内容复制到缓冲区中,然后显示缓冲区以进行编辑。如果更改文本,可以 通过键入 ( ) 将新文本保存在文件中。这会将更改的缓冲区内容复制回文件中C-x C-ssave-buffer测试.emacs,使它们永久化。在保存之前,更改的文本仅存在于 Emacs 内部,并且该文件 测试.emacs是不变的。

Emacs obeys this command by visiting the file: it creates a buffer, copies the contents of the file into the buffer, and then displays the buffer for editing. If you alter the text, you can save the new text in the file by typing C-x C-s (save-buffer). This copies the altered buffer contents back into the file test.emacs, making them permanent. Until you save, the changed text exists only inside Emacs, and the file test.emacs is unaltered.

要创建文件,只需访问它,C-x C-f就像它已经存在一样。这将创建一个空缓冲区,您可以在其中插入要放入文件中的文本。 Emacs 实际上会在您第一次使用C-x C-s.

To create a file, just visit it with C-x C-f as if it already existed. This creates an empty buffer, in which you can insert the text you want to put in the file. Emacs actually creates the file the first time you save this buffer with C-x C-s.

要了解有关在 Emacs 中使用文件的更多信息,请参阅文件处理

To learn more about using files in Emacs, see File Handling.


8.6 帮助

8.6 Help

C-h k如果您忘记某个键的用途,可以通过键入( describe-key),然后输入您感兴趣的键来查找;例如,C-h k C-n告诉您C-n做什么。

If you forget what a key does, you can find out by typing C-h k (describe-key), followed by the key of interest; for example, C-h k C-n tells you what C-n does.

前缀键C-h代表“帮助”。该密钥F1 用作 的别名C-h。除了 之外C-h k,还有许多其他帮助命令提供不同类型的帮助。

The prefix key C-h stands for “help”. The key F1 serves as an alias for C-h. Apart from C-h k, there are many other help commands providing different kinds of help.

有关详细信息,请参阅帮助

See Help, for details.


8.7 空行

8.7 Blank Lines

以下是插入和删除空行的特殊命令和技术。

Here are special commands and techniques for inserting and deleting blank lines.

C-o
C-o

在光标后插入一个空行 ( open-line)。

Insert a blank line after the cursor (open-line).

C-x C-o
C-x C-o

删除许多连续空白行 ( ) 中的所有空白行 ( delete-blank-lines)。

Delete all but one of many consecutive blank lines (delete-blank-lines).

我们已经了解了RET( newline) 如何开始新的一行文本。但是,如果您首先创建一个空行,然后在其中插入所需的文本,可能会更容易看到您在做什么。使用C-o( )键可以轻松完成此操作open-line,该键在 point 之后插入换行符,但在换行符前面保留 point。之后C-o,键入新行的文本。

We have seen how RET (newline) starts a new line of text. However, it may be easier to see what you are doing if you first make a blank line and then insert the desired text into it. This is easy to do using the key C-o (open-line), which inserts a newline after point but leaves point in front of the newline. After C-o, type the text for the new line.

您可以通过C-o多次键入或给它一个数字参数来指定要创建的空行数来创建多个空行。请参阅数字参数了解具体方法。如果您有填充前缀,则该C-o 命令会在新行上插入填充前缀(如果在行首键入)。请参阅填充前缀

You can make several blank lines by typing C-o several times, or by giving it a numeric argument specifying how many blank lines to make. See Numeric Arguments, for how. If you have a fill prefix, the C-o command inserts the fill prefix on the new line, if typed at the beginning of a line. See The Fill Prefix.

删除多余空行的简单方法是使用命令 C-x C-o( delete-blank-lines)。如果点位于一系列空行内,则C-x C-o删除除其中一个空行之外的所有空行。如果点位于单个空行上,C-x C-o则将其删除。如果点位于非空行上,C-x C-o则删除所有后续空行(如果存在)。

The easy way to get rid of extra blank lines is with the command C-x C-o (delete-blank-lines). If point lies within a run of several blank lines, C-x C-o deletes all but one of them. If point is on a single blank line, C-x C-o deletes it. If point is on a nonblank line, C-x C-o deletes all following blank lines, if any exists.


8.8 延续线

8.8 Continuation Lines

有时,缓冲区中的一行文本(逻辑行)太长,无法容纳在窗口中,Emacs 将其显示为两条或更多条 屏幕线,或可视线。这称为换行延续,长逻辑行称为 续行。在图形显示上,Emacs 在左右窗口边缘用小弯曲箭头指示换行。在文本终端上,Emacs 通过显示 ' 来指示换行\' 字符位于右边距。

Sometimes, a line of text in the buffer—a logical line—is too long to fit in the window, and Emacs displays it as two or more screen lines, or visual lines. This is called line wrapping or continuation, and the long logical line is called a continued line. On a graphical display, Emacs indicates line wrapping with small bent arrows in the left and right window fringes. On a text terminal, Emacs indicates line wrapping by displaying a ‘\’ character at the right margin.

大多数作用于行的命令作用于逻辑行,而不是屏幕行。例如,C-k杀死一条逻辑线。如前所述,C-n( next-line) 和C-p ( previous-line) 是特殊例外:它们分别将点向下和向上移动一行屏幕线(请参阅更改点的位置)。

Most commands that act on lines act on logical lines, not screen lines. For instance, C-k kills a logical line. As described earlier, C-n (next-line) and C-p (previous-line) are special exceptions: they move point down and up, respectively, by one screen line (see Changing the Location of Point).

Emacs 可以选择截断长逻辑行而不是继续它们。这意味着每个逻辑行占用一个屏幕行;如果它比窗口的宽度长,则不显示该行的其余部分。在图形显示上,截断线由右边缘的小直箭头指示;在文本终端上,它由 ' 表示$' 字符位于右边距。请参阅行截断

Emacs can optionally truncate long logical lines instead of continuing them. This means that every logical line occupies a single screen line; if it is longer than the width of the window, the rest of the line is not displayed. On a graphical display, a truncated line is indicated by a small straight arrow in the right fringe; on a text terminal, it is indicated by a ‘$’ character in the right margin. See Line Truncation.

默认情况下,连续的行会在窗口右边缘换行。由于换行可能发生在单词的中间,因此连续的行可能难以阅读。通常的解决方案是在行变得太长之前通过插入换行符来中断行。如果您愿意,可以使用自动填充模式让 Emacs 在行太长时自动插入换行符。请参阅填充文本

By default, continued lines are wrapped at the right window edge. Since the wrapping may occur in the middle of a word, continued lines can be difficult to read. The usual solution is to break your lines before they get too long, by inserting newlines. If you prefer, you can make Emacs insert a newline automatically when a line gets too long, by using Auto Fill mode. See Filling Text.

有时,您可能需要编辑包含许多长逻辑行的文件,并且通过添加换行符将它们全部分解可能不切实际。在这种情况下,您可以使用 Visual Line 模式,该模式启用 自动换行:Emacs 不是在窗口右边缘精确换行长行,而是在最靠近窗口右边缘的单词边界(即空格或制表符)处换行。 Visual Line 模式还重新定义了C-aC-n、 和等编辑命令,C-k以在屏幕行而不是逻辑行上进行操作。请参见视线模式

Sometimes, you may need to edit files containing many long logical lines, and it may not be practical to break them all up by adding newlines. In that case, you can use Visual Line mode, which enables word wrapping: instead of wrapping long lines exactly at the right window edge, Emacs wraps them at the word boundaries (i.e., space or tab characters) nearest to the right window edge. Visual Line mode also redefines editing commands such as C-a, C-n, and C-k to operate on screen lines rather than logical lines. See Visual Line Mode.


8.9 光标位置信息

8.9 Cursor Position Information

以下命令用于获取有关缓冲区各部分的大小和位置的信息,以及对字数和行数进行计数。

Here are commands to get information about the size and position of parts of the buffer, and to count words and lines.

M-x what-line
M-x what-line

显示点的行号。

Display the line number of point.

M-x line-number-mode
M-x line-number-mode
M-x column-number-mode
M-x column-number-mode

切换自动显示当前行号或列号。请参阅可选模式线功能。如果您希望在每行之前显示行号,请参阅显示的自定义

Toggle automatic display of the current line number or column number. See Optional Mode Line Features. If you want to have a line number displayed before each line, see Customization of Display.

M-=
M-=

显示区域 ( ) 中存在的行数、句子数、单词数和字符数count-words-region。有关该地区的信息, 请参阅“标记和地区” 。

Display the number of lines, sentences, words, and characters that are present in the region (count-words-region). See The Mark and the Region, for information about the region.

M-x count-words
M-x count-words

显示缓冲区中存在的行数、句子数、单词数和字符数。如果该区域处于活动状态(请参阅标记和区域),则显示该区域的编号。

Display the number of lines, sentences, words, and characters that are present in the buffer. If the region is active (see The Mark and the Region), display the numbers for the region instead.

C-x =
C-x =

显示点后字符的字符代码、点的字符位置、点的列(what-cursor-position)。

Display the character code of character after point, character position of point, and column of point (what-cursor-position).

M-x hl-line-mode
M-x hl-line-mode

启用或禁用当前行的突出显示。请参阅显示光标

Enable or disable highlighting of the current line. See Displaying the Cursor.

M-x size-indication-mode
M-x size-indication-mode

切换缓冲区大小的自动显示。请参阅可选模式线功能

Toggle automatic display of the size of the buffer. See Optional Mode Line Features.

M-x what-line在回显区域显示当前行号。该命令通常是多余的,因为当前行号显示在模式行中(请参阅模式行)。但是,如果缩小缓冲区,模式行将显示相对于可访问部分的行号(请参阅缩小)。相比之下, what-line显示相对于缩小区域的行号和相对于整个缓冲区的行号。

M-x what-line displays the current line number in the echo area. This command is usually redundant because the current line number is shown in the mode line (see The Mode Line). However, if you narrow the buffer, the mode line shows the line number relative to the accessible portion (see Narrowing). By contrast, what-line displays both the line number relative to the narrowed region and the line number relative to the whole buffer.

M-=( count-words-region) 显示一条消息,报告该区域中的行数、句子数、单词数和字符数(有关该区域的说明,请参阅标记和区域)。使用前缀参数 ,C-u M-=该命令显示整个缓冲区的计数。

M-= (count-words-region) displays a message reporting the number of lines, sentences, words, and characters in the region (see The Mark and the Region, for an explanation of the region). With a prefix argument, C-u M-=, the command displays a count for the entire buffer.

该命令M-x count-words执行相同的工作,但使用不同的调用约定。如果该区域处于活动状态,则显示该区域的计数,否则显示缓冲区的计数。

The command M-x count-words does the same job, but with a different calling convention. It displays a count for the region if the region is active, and for the buffer otherwise.

命令C-x =( what-cursor-position) 显示有关当前光标位置和该位置的缓冲区内容的信息。它在回显区域中显示一条线,如下所示:

The command C-x = (what-cursor-position) shows information about the current cursor position and the buffer contents at that position. It displays a line in the echo area that looks like this:

字符:c (99, #o143, #x63) 点 = 36168 (78%) 中的 28062 列 = 53
Char: c (99, #o143, #x63) point=28062 of 36168 (78%) column=53

后 '字符:',这显示了缓冲区中此时的字符。括号内的文字显示相应的十进制、八进制和十六进制字符代码;有关如何C-x = 显示字符信息的详细信息,请参阅国际字符集简介。后 '点=' 是 point 作为字符计数的位置(缓冲区中的第一个字符是位置 1,第二个字符是位置 2,依此类推)。之后的数字是缓冲区中字符的总数,括号中的数字表示位置占总数的百分比。后 '栏=' 是点的水平位置,以从窗口左边缘开始计数的列为单位。

After ‘Char:’, this shows the character in the buffer at point. The text inside the parenthesis shows the corresponding decimal, octal and hex character codes; for more information about how C-x = displays character information, see Introduction to International Character Sets. After ‘point=’ is the position of point as a character count (the first character in the buffer is position 1, the second character is position 2, and so on). The number after that is the total number of characters in the buffer, and the number in parenthesis expresses the position as a percentage of the total. After ‘column=’ is the horizontal position of point, in columns counting from the left edge of the window.

如果用户选项what-cursor-show-names为 non- nil,则还会显示由 Unicode 字符数据库定义的字符名称。括号中的部分将变为:

If the user option what-cursor-show-names is non-nil, the name of the character, as defined by the Unicode Character Database, is shown as well. The part in parentheses would then become:

(99、#o143、#x63、拉丁文小写字母 C)
(99, #o143, #x63, LATIN SMALL LETTER C)

如果缓冲区已缩小,导致开头和结尾的某些文本暂时无法访问,C-x =则会显示描述当前可访问范围的附加文本。例如,它可能会显示:

If the buffer has been narrowed, making some of the text at the beginning and the end temporarily inaccessible, C-x = displays additional text describing the currently accessible range. For example, it might display this:

字符:C (67, #o103, #x43) 点 = 889 中的 252 (28%) <231-599> 列 =0
Char: C (67, #o103, #x43) point=252 of 889 (28%) <231-599> column=0

其中两个额外的数字给出了该点允许采用的最小和最大字符位置。这两个位置之间的字符是可访问的字符。请参阅缩小范围

where the two extra numbers give the smallest and largest character position that point is allowed to assume. The characters between those two positions are the accessible ones. See Narrowing.

相关但不同的功能是display-line-numbers-mode (请参阅显示的自定义)。

Related, but different feature is display-line-numbers-mode (see Customization of Display).


8.10 数字参数

8.10 Numeric Arguments

在数学和计算术语中,参数的 意思是“提供给函数或操作的数据”。您可以为任何 Emacs 命令提供数字参数(也称为前缀参数)。某些命令将参数解释为重复计数。例如,给出C-f十个参数会导致它向前移动十个字符而不是一个。对于这些命令,没有参数相当于 1 的参数,负参数会导致它们向相反的方向移动或起作用。

In the terminology of mathematics and computing, argument means “data provided to a function or operation”. You can give any Emacs command a numeric argument (also called a prefix argument). Some commands interpret the argument as a repetition count. For example, giving C-f an argument of ten causes it to move point forward by ten characters instead of one. With these commands, no argument is equivalent to an argument of one, and negative arguments cause them to move or act in the opposite direction.

指定数字参数的最简单方法是按住 键的同时键入数字和/或减号Meta。例如,

The easiest way to specify a numeric argument is to type a digit and/or a minus sign while holding down the Meta key. For example,

M-5 CN
M-5 C-n

向下移动五行。键M-1M-2等以及M--绑定到为下一个命令设置参数 的命令 (digit-argument和 )。没有数字通常表示-1。 negative-argumentM--

moves down five lines. The keys M-1, M-2, and so on, as well as M--, are bound to commands (digit-argument and negative-argument) that set up an argument for the next command. M-- without digits normally means −1.

如果输入多于一位数字,则无需按住该 Meta键即可输入第二位及后续数字。因此,要向下移动五十行,请输入

If you enter more than one digit, you need not hold down the Meta key for the second and subsequent digits. Thus, to move down fifty lines, type

M-5 0 cn
M-5 0 C-n

请注意,这不会插入 ' 的五个副本0' 然后向下移动一行,如您所料 - '0' 被视为前缀参数的一部分。

Note that this does not insert five copies of ‘0’ and move down one line, as you might expect—the ‘0’ is treated as part of the prefix argument.

(如果您确实想插入 ' 的五个副本怎么办?0'?类型M-5 C-u 0。此处,C-u终止前缀参数,以便下一次击键开始您要执行的命令。请注意,此含义C-u仅适用于这种情况。对于 的通常作用C-u,请参见下文。)

(What if you do want to insert five copies of ‘0’? Type M-5 C-u 0. Here, C-u terminates the prefix argument, so that the next keystroke begins the command that you want to execute. Note that this meaning of C-u applies only to this case. For the usual role of C-u, see below.)

除了键入M-1M-2等之外,指定数字参数的另一种方法是键入C-u ( universal-argument) 后跟一些数字,或(对于负参数)键入减号后跟数字。不带数字的减号通常表示 -1。

Instead of typing M-1, M-2, and so on, another way to specify a numeric argument is to type C-u (universal-argument) followed by some digits, or (for a negative argument) a minus sign followed by digits. A minus sign without digits normally means −1.

C-u单独具有“四倍”的特殊含义:它将下一个命令的参数乘以四。 C-u C-u 将其乘以十六。因此,C-u C-u C-f向前移动十六个字符。其他有用的组合是C-u C-nC-u C-u C-n(向下移动屏幕的很大一部分),C-u C-u C-o(生成十六个空白行)和C-u C-k(删除四行)。

C-u alone has the special meaning of “four times”: it multiplies the argument for the next command by four. C-u C-u multiplies it by sixteen. Thus, C-u C-u C-f moves forward sixteen characters. Other useful combinations are C-u C-n, C-u C-u C-n (move down a good fraction of a screen), C-u C-u C-o (make sixteen blank lines), and C-u C-k (kill four lines).

您可以在自插入字符之前使用数字参数来插入它的多个副本。当字符不是数字时,这很简单;例如,C-u 6 4 a插入字符 ' 的 64 个副本A'。但这不适用于插入数字;C-u 6 4 1指定参数 641。您可以将参数与要插入的数字分开 C-u;例如,是否插入字符 ' 的 64 个副本C-u 6 4 C-u 11'。

You can use a numeric argument before a self-inserting character to insert multiple copies of it. This is straightforward when the character is not a digit; for example, C-u 6 4 a inserts 64 copies of the character ‘a’. But this does not work for inserting digits; C-u 6 4 1 specifies an argument of 641. You can separate the argument from the digit to insert with another C-u; for example, C-u 6 4 C-u 1 does insert 64 copies of the character ‘1’.

有些命令关心是否有参数,但忽略它的值。例如,命令M-q( fill-paragraph)填充文本;通过论证,它也证明了文本的合理性。 (有关 的更多信息,请参阅填充文本M-q。)对于这些命令,用单个 指定参数就足够了 C-u

Some commands care whether there is an argument, but ignore its value. For example, the command M-q (fill-paragraph) fills text; with an argument, it justifies the text as well. (See Filling Text, for more information on M-q.) For these commands, it is enough to specify the argument with a single C-u.

某些命令使用参数的值作为重复计数,但在没有参数时执行一些特殊操作。例如,带有参数n 的C-k命令( )会终止 n行,包括它们的终止换行符。但 没有参数是特殊的:它会杀死直到下一个换行符的文本,或者,如果点位于行尾,它会杀死换行符本身。因此,两个不带参数的命令可以杀死非空行,就像带参数 1 一样。 (有关 的更多信息,请参阅删除和移动文本。) kill-lineC-kC-kC-kC-k

Some commands use the value of the argument as a repeat count but do something special when there is no argument. For example, the command C-k (kill-line) with argument n kills n lines, including their terminating newlines. But C-k with no argument is special: it kills the text up to the next newline, or, if point is right at the end of the line, it kills the newline itself. Thus, two C-k commands with no arguments can kill a nonblank line, just like C-k with an argument of one. (See Killing and Moving Text, for more information on C-k.)

一些命令对普通参数的处理C-u与普通参数的处理不同。其他一些人可能会以不同的方式对待只有负号的参数和 -1 的参数。这些不寻常的情况一出现就会被描述;它们的存在是为了使单个命令更加方便,并且它们记录在该命令的文档字符串中。

A few commands treat a plain C-u differently from an ordinary argument. A few others may treat an argument of just a minus sign differently from an argument of −1. These unusual cases are described when they come up; they exist to make an individual command more convenient, and they are documented in that command’s documentation string.

我们使用术语前缀参数来强调您在命令之前键入此类参数,并将它们与调用命令 输入的 迷你缓冲区参数(请参阅迷你缓冲区)区分开来。

We use the term prefix argument to emphasize that you type such arguments before the command, and to distinguish them from minibuffer arguments (see The Minibuffer), which are entered after invoking the command.

在图形显示上,C-0、等的作用与、等 C-1相同 。M-0M-1

On graphical displays, C-0, C-1, etc. act the same as M-0, M-1, etc.


8.11 重复命令

8.11 Repeating a Command

许多简单的命令,例如使用单个键或使用 调用的命令,可以通过使用用作重复计数的数字参数来调用它们来重复(请参阅数字参数)。但是,如果您要重复的命令提示输入,或以其他方式使用数字参数,则该方法将不起作用。 M-x command-name RET

Many simple commands, such as those invoked with a single key or with M-x command-name RET, can be repeated by invoking them with a numeric argument that serves as a repeat count (see Numeric Arguments). However, if the command you want to repeat prompts for input, or uses a numeric argument in another way, that method won’t work.

命令C-x z( repeat) 提供了另一种多次重复 Emacs 命令的方法。该命令重复之前的 Emacs 命令,无论它是什么。重复命令使用之前使用过的相同参数;它不会每次都读取新的参数。

The command C-x z (repeat) provides another way to repeat an Emacs command many times. This command repeats the previous Emacs command, whatever that was. Repeating a command uses the same arguments that were used before; it does not read new arguments each time.

要多次重复该命令,请键入additional z's:每个 z都会重复该命令一次。当您键入非字符z或按下鼠标按钮时,重复就会结束。

To repeat the command more than once, type additional z’s: each z repeats the command one more time. Repetition ends when you type a character other than z or press a mouse button.

例如,假设您键入C-u 2 0 C-d要删除 20 个字符。您可以通过键入 重复该命令(包括其参数)三次,总共删除 80 个字符C-x z z z。第一个C-x z命令重复一次,随后的每个z命令再次重复一次。

For example, suppose you type C-u 2 0 C-d to delete 20 characters. You can repeat that command (including its argument) three additional times, to delete a total of 80 characters, by typing C-x z z z. The first C-x z repeats the command once, and each subsequent z repeats it once again.

您还可以激活repeat-mode它,允许通过键入单个字符来重复绑定到两个或多个键序列的命令。例如,在键入C-x uundo,请参阅撤消)撤消最近的编辑后,您可以通过键入 撤消更多编辑u u u…。同样,键入C-x o o o…而不是切换到几个窗口之外的窗口。这是通过在键入调用命令的完整按键序列后进入瞬态重复模式来实现的;单键快捷键显示在回显区域中。 C-x o C-x o C-x o…

You can also activate repeat-mode which allows repeating commands bound to sequences of two or more keys by typing a single character. For example, after typing C-x u (undo, see Undo) to undo the most recent edits, you can undo many more edits by typing u u u…. Similarly, type C-x o o o… instead of C-x o C-x o C-x o… to switch to the window several windows away. This works by entering a transient repeating mode after you type the full key sequence that invokes the command; the single-key shortcuts are shown in the echo area.

只有部分命令支持重复repeat-mode;键入 以查看哪些。 M-x describe-repeat-maps RET

Only some commands support repetition in repeat-mode; type M-x describe-repeat-maps RET to see which ones.

瞬态重复模式启用的单字符快捷方式不需要相同:例如,键入C-x {、 或{}^v以任何顺序混合这些字符的任何系列后,将以各自的方式调整所选窗口的大小。类似地,在M-g n或 之后,在任何组合中M-g p键入任何序列n和/或将重复并在pnext-errorprevious-error*汇编*或者*grep*缓冲区(请参阅编译模式)。

The single-character shortcuts enabled by the transient repeating mode do not need to be identical: for example, after typing C-x {, either { or } or ^ or v, or any series that mixes these characters in any order, will resize the selected window in respective ways. Similarly, after M-g n or M-g p, typing any sequence of n and/or p in any mix will repeat next-error and previous-error to navigate in a *compilation* or *grep* buffer (see Compilation Mode).

键入除定义为重复上一命令之外的任何键都会退出瞬态重复模式,然后正常执行您键入的键。您还可以定义一个键,该键将退出瞬态重复模式,而不执行导致退出的键。为此,自定义用户选项 repeat-exit-key来命名一个键;一个自然值是RET.最后,可以在一定的空闲时间后自动中断重复链:自定义用户选项 repeat-exit-timeout以指定空闲时间(以秒为单位),之后此瞬态重复模式将自动关闭。

Typing any key other than those defined to repeat the previous command exits the transient repeating mode, and then the key you typed is executed normally. You can also define a key which will exit the transient repeating mode without executing the key which caused the exit. To this end, customize the user option repeat-exit-key to name a key; one natural value is RET. Finally, it’s possible to break the repetition chain automatically after some amount of idle time: customize the user option repeat-exit-timeout to specify the idle time in seconds after which this transient repetition mode will be turned off automatically.


9 迷你缓冲区

9 The Minibuffer

迷你缓冲区是Emacs 命令读取复杂参数的地方,例如文件名、缓冲区名称、Emacs 命令名称或 Lisp 表达式。我们称其为“迷你缓冲区”,因为它是一个具有少量屏幕空间的专用缓冲区。您可以在迷你缓冲区中使用常用的 Emacs 编辑命令来编辑参数文本。

The minibuffer is where Emacs commands read complicated arguments, such as file names, buffer names, Emacs command names, or Lisp expressions. We call it the “minibuffer” because it’s a special-purpose buffer with a small amount of screen space. You can use the usual Emacs editing commands in the minibuffer to edit the argument text.


9.1 使用迷你缓冲区

9.1 Using the Minibuffer

当使用迷你缓冲区时,它会出现在回显区域中,并带有光标。迷你缓冲区以提示符开头,通常以冒号结尾。提示说明了预期的输入类型以及如何使用它。使用脸部突出显示提示 minibuffer-prompt(请参阅文本脸部)。

When the minibuffer is in use, it appears in the echo area, with a cursor. The minibuffer starts with a prompt, usually ending with a colon. The prompt states what kind of input is expected, and how it will be used. The prompt is highlighted using the minibuffer-prompt face (see Text Faces).

输入迷你缓冲区参数的最简单方法是键入文本,然后RET提交参数并退出迷你缓冲区。或者,您可以C-g通过取消要求参数的命令来键入退出迷你缓冲区(请参阅退出和中止)。

The simplest way to enter a minibuffer argument is to type the text, then RET to submit the argument and exit the minibuffer. Alternatively, you can type C-g to exit the minibuffer by canceling the command asking for the argument (see Quitting and Aborting).

有时,提示符会在冒号之前的括号内显示默认参数。如果您只键入 ,则此默认值将用作参数RET。例如,读取缓冲区名称的命令通常显示缓冲区名称作为默认值;您可以键入 RET以对该默认缓冲区进行操作。您可以使用用户选项自定义默认参数的显示方式 minibuffer-default-prompt-format

Sometimes, the prompt shows a default argument, inside parentheses before the colon. This default will be used as the argument if you just type RET. For example, commands that read buffer names usually show a buffer name as the default; you can type RET to operate on that default buffer. You can customize how the default argument is shown with the user option minibuffer-default-prompt-format.

如果您启用 Minibuffer Electric Default 模式(一种全局次要模式),则一旦您修改了 minibuffer 的内容,Emacs 就会隐藏默认参数(因为键入RET将不再提交该默认值)。如果您恢复原始的迷你缓冲区文本,提示将再次显示默认值。要启用此次要模式,请键入 M-x minibuffer-electric-default-mode

If you enable Minibuffer Electric Default mode, a global minor mode, Emacs hides the default argument as soon as you modify the contents of the minibuffer (since typing RET would no longer submit that default). If you ever bring back the original minibuffer text, the prompt again shows the default. To enable this minor mode, type M-x minibuffer-electric-default-mode.

由于迷你缓冲区出现在​​回显区域中,因此它可能与回显区域的其他用途发生冲突。如果在迷你缓冲区处于活动状态时发出错误消息或信息性消息,则该消息将在迷你缓冲区文本后面的括号中显示几秒钟,或者直到您键入某些内容;然后该消息消失。当使用迷你缓冲区时,Emacs 不会回显击键。

Since the minibuffer appears in the echo area, it can conflict with other uses of the echo area. If an error message or an informative message is emitted while the minibuffer is active, the message is displayed in brackets after the minibuffer text for a few seconds, or until you type something; then the message disappears. While the minibuffer is in use, Emacs does not echo keystrokes.

使用迷你缓冲区时,您可以切换到不同的框架,也许是为了记下需要输入的文本(请参阅框架命令)。默认情况下,活动迷你缓冲区会移动到这个新帧。如果将用户选项设置minibuffer-follows-selected-framenil,则微型缓冲区将保留在打开它的帧中,并且您必须切换回该帧才能完成(或中止)当前命令。如果将该选项设置为既不是nil也不是 的值t,则仅在当前命令中打开递归迷你缓冲区后,迷你缓冲区才会移动帧(请参阅(elisp)Recursive Mini)。该选项主要是为了(大约)保留 Emacs 28.1 之前的行为。请注意,当您最终完成使用迷你缓冲区时,该命令的效果始终发生在您首次打开它的帧中。唯一的例外是,当该帧不再存在时,操作将在当前选定的帧中发生。

While using the minibuffer, you can switch to a different frame, perhaps to note text you need to enter (see Frame Commands). By default, the active minibuffer moves to this new frame. If you set the user option minibuffer-follows-selected-frame to nil, then the minibuffer stays in the frame where you opened it, and you must switch back to that frame in order to complete (or abort) the current command. If you set that option to a value which is neither nil nor t, the minibuffer moves frame only after a recursive minibuffer has been opened in the current command (see (elisp)Recursive Mini). This option is mainly to retain (approximately) the behavior prior to Emacs 28.1. Note that the effect of the command, when you finally finish using the minibuffer, always takes place in the frame where you first opened it. The sole exception is that when that frame no longer exists, the action takes place in the currently selected frame.


9.2 文件名的迷你缓冲区

9.2 Minibuffers for File Names

C-x C-f( )等命令find-file使用迷你缓冲区来读取文件名参数(请参阅文件)。当使用迷你缓冲区读取文件名时,它通常以一些以斜杠结尾的初始文本开始。这是默认目录。例如,它可能是这样开始的:

Commands such as C-x C-f (find-file) use the minibuffer to read a file name argument (see Files). When the minibuffer is used to read a file name, it typically starts out with some initial text ending in a slash. This is the default directory. For example, it may start out like this:

查找文件:/u2/emacs/src/
Find file: /u2/emacs/src/

这里, '查找文件:' 是提示符并且 '/u2/emacs/src/' 是默认目录。如果您现在键入buffer.c作为输入,则指定文件/u2/emacs/src/buffer.c。有关默认目录的信息, 请参阅文件名。

Here, ‘Find file: ’ is the prompt and ‘/u2/emacs/src/’ is the default directory. If you now type buffer.c as input, that specifies the file /u2/emacs/src/buffer.c. See File Names, for information about the default directory.

您可以通过键入获得您可能需要的文件名的替代默认值M-n,请参阅迷你缓冲区历史记录

Alternative defaults for the file name you may want are available by typing M-n, see Minibuffer History.

您可以使用以下命令指定父目录中的文件..: /a/b/../foo.el相当于/a/foo.el。或者,您可以使用向后删除目录名称(请参阅Words)。 M-DEL

You can specify a file in the parent directory with ..: /a/b/../foo.el is equivalent to /a/foo.el. Alternatively, you can use M-DEL to kill directory names backwards (see Words).

要指定完全不同的目录中的文件,您可以使用C-a C-k(请参阅在迷你缓冲区中编辑)来终止整个默认目录。或者,您可以忽略默认值,并在默认目录后输入以斜线或波形符开头的绝对文件名。例如,您可以指定/etc/termcap如下:

To specify a file in a completely different directory, you can kill the entire default with C-a C-k (see Editing in the Minibuffer). Alternatively, you can ignore the default, and enter an absolute file name starting with a slash or a tilde after the default directory. For example, you can specify /etc/termcap as follows:

查找文件:/u2/emacs/src//etc/termcap
Find file: /u2/emacs/src//etc/termcap

双斜杠会导致 Emacs 忽略该对中第二个斜杠之前的所有内容。在上面的例子中, /u2/emacs/src/被忽略,所以您提供的参数是 /etc/termcap。如果终端允许,文件名中被忽略的部分会变暗。 (要禁用此调暗功能,请使用命令关闭文件名阴影模式。) M-x file-name-shadow-mode

A double slash causes Emacs to ignore everything before the second slash in the pair. In the example above, /u2/emacs/src/ is ignored, so the argument you supplied is /etc/termcap. The ignored part of the file name is dimmed if the terminal allows it. (To disable this dimming, turn off File Name Shadow mode with the command M-x file-name-shadow-mode.)

当完成远程文件名时(请参阅远程文件),双斜杠的行为略有不同:它导致 Emacs 仅忽略文件名部分,而其余部分(方法、主机和用户名等)保持不变。连续输入三个斜杠会忽略远程文件名中的所有内容。请参阅The Tramp Manual中的文件名完成

When completing remote file names (see Remote Files), a double slash behaves slightly differently: it causes Emacs to ignore only the file-name part, leaving the rest (method, host and username, etc.) intact. Typing three slashes in a row ignores everything in remote file names. See File name completion in The Tramp Manual.

Emacs 解释〜/作为您的主目录。因此, 〜/foo/bar.txt指定一个名为栏.txt,在名为的目录中,它又位于您的主目录中。此外,~用户 ID /表示登录名为user-id的用户的主目录。前面的任何前导目录名称被忽略:因此, /u2/emacs/~/foo/bar.txt相当于〜/foo/bar.txt

Emacs interprets ~/ as your home directory. Thus, ~/foo/bar.txt specifies a file named bar.txt, inside a directory named foo, which is in turn located in your home directory. In addition, ~user-id/ means the home directory of a user whose login name is user-id. Any leading directory name in front of the ~ is ignored: thus, /u2/emacs/~/foo/bar.txt is equivalent to ~/foo/bar.txt.

在 MS-Windows 和 MS-DOS 系统上,用户并不总是有主目录,Emacs 使用多种替代方法。对于 MS-Windows,请参阅 MS-Windows 上的主目录和启动目录;对于 MS-DOS,请参阅 MS-DOS 上的文件名。在这些系统上,~用户 ID /仅当前用户支持构造,即仅当user-id是当前用户的登录名时。

On MS-Windows and MS-DOS systems, where a user doesn’t always have a home directory, Emacs uses several alternatives. For MS-Windows, see HOME and Startup Directories on MS-Windows; for MS-DOS, see File Names on MS-DOS. On these systems, the ~user-id/ construct is supported only for the current user, i.e., only if user-id is the current user’s login name.

要防止 Emacs 在读取文件名时插入默认目录,请将变量更改insert-default-directorynil.在这种情况下,迷你缓冲区一开始是空的。尽管如此,相对文件名参数仍然基于相同的默认目录进行解释。

To prevent Emacs from inserting the default directory when reading file names, change the variable insert-default-directory to nil. In that case, the minibuffer starts out empty. Nonetheless, relative file name arguments are still interpreted based on the same default directory.

您还可以在迷你缓冲区中输入远程文件名。请参阅远程文件

You can also enter remote file names in the minibuffer. See Remote Files.


9.3 在迷你缓冲区中编辑

9.3 Editing in the Minibuffer

迷你缓冲区是一种 Emacs 缓冲区,尽管是一种特殊的缓冲区,并且常用的 Emacs 命令可用于编辑参数文本。 (但是,该提示是只读的,无法更改。)

The minibuffer is an Emacs buffer, albeit a peculiar one, and the usual Emacs commands are available for editing the argument text. (The prompt, however, is read-only, and cannot be changed.)

由于RET在迷你缓冲区中提交了参数,因此您不能使用它来插入换行符。您可以使用 来执行此操作C-q C-j,它会插入一个C-j控制字符,该字符在形式上相当于换行符(请参阅插入文本)。或者,您可以使用C-o( open-line) 命令(请参阅空行)。

Since RET in the minibuffer submits the argument, you can’t use it to insert a newline. You can do that with C-q C-j, which inserts a C-j control character, which is formally equivalent to a newline character (see Inserting Text). Alternatively, you can use the C-o (open-line) command (see Blank Lines).

在迷你缓冲区内,键TABSPC、 和?通常绑定到完成命令,这使您可以轻松填写​​所需的文本,而无需键入全部内容。请参阅完成。与 一样RET,您可以使用C-q插入TAB, SPC, 或 '' 特点。如果你想正常地 makeSPC?insert 而不是开始完成,你可以将以下内容放入你的 init 文件中:

Inside a minibuffer, the keys TAB, SPC, and ? are often bound to completion commands, which allow you to easily fill in the desired text without typing all of it. See Completion. As with RET, you can use C-q to insert a TAB, SPC, or ‘?’ character. If you want to make SPC and ? insert normally instead of starting completion, you can put the following in your init file:

(keymap-unset minibuffer-local-completion-map "SPC")
(键盘映射未设置迷你缓冲区本地完成映射“?”)
(keymap-unset minibuffer-local-completion-map "SPC")
(keymap-unset minibuffer-local-completion-map "?")

为了方便起见,迷你缓冲区中的C-a( move-beginning-of-line) 移动指向参数文本的开头,而不是提示的开头。例如,这允许您使用 删除整个参数C-a C-k

For convenience, C-a (move-beginning-of-line) in a minibuffer moves point to the beginning of the argument text, not the beginning of the prompt. For example, this allows you to erase the entire argument with C-a C-k.

当迷你缓冲区处于活动状态时,回显区域的处理方式与普通 Emacs 窗口非常相似。例如,您可以切换到另一个窗口(使用C-x o),在那里编辑文本,然后返回到迷你缓冲区窗口以完成参数。您甚至可以删除另一个窗口中的文本,返回到迷你缓冲区窗口,然后将文本拉入参数中。但是,迷你缓冲区窗口有一些限制:例如,您不能拆分它。请参阅多个窗口

When the minibuffer is active, the echo area is treated much like an ordinary Emacs window. For instance, you can switch to another window (with C-x o), edit text there, then return to the minibuffer window to finish the argument. You can even kill text in another window, return to the minibuffer window, and yank the text into the argument. There are some restrictions on the minibuffer window, however: for instance, you cannot split it. See Multiple Windows.

通常,迷你缓冲区窗口占据单个屏幕行。但是,如果您将两行或更多行的文本添加到迷你缓冲区中,它会自动扩展以容纳文本。该变量resize-mini-windows控制迷你缓冲区的大小调整。默认值为grow-only,这意味着我们刚才描述的行为。如果值为t,则当您从迷你缓冲区中删除一些文本行时,迷你缓冲区窗口也会自动缩小,至少缩小到一个屏幕行。如果值为nil,则迷你缓冲区窗口永远不会自动更改大小,但您可以在其上使用常用的窗口大小调整命令(请参阅多个窗口)。

Normally, the minibuffer window occupies a single screen line. However, if you add two or more lines’ worth of text into the minibuffer, it expands automatically to accommodate the text. The variable resize-mini-windows controls the resizing of the minibuffer. The default value is grow-only, which means the behavior we have just described. If the value is t, the minibuffer window will also shrink automatically if you remove some lines of text from the minibuffer, down to a minimum of one screen line. If the value is nil, the minibuffer window never changes size automatically, but you can use the usual window-resizing commands on it (see Multiple Windows).

该变量max-mini-window-height控制调整迷你缓冲区窗口大小的最大高度。浮点数指定框架高度的一部分;一个整数指定最大行数;nil意味着不自动调整迷你缓冲区窗口的大小。默认值为 0.25。

The variable max-mini-window-height controls the maximum height for resizing the minibuffer window. A floating-point number specifies a fraction of the frame’s height; an integer specifies the maximum number of lines; nil means do not resize the minibuffer window automatically. The default value is 0.25.

迷你缓冲区中的命令C-M-v滚动来自在另一个窗口中显示任何类型的帮助文本的命令的帮助文本。您还可以使用和 (或者等效地,和 )滚动帮助文本。这对于可能完成的长列表特别有用。请参阅使用其他 WindowsM-PageUpM-PageDownM-priorM-next

The C-M-v command in the minibuffer scrolls the help text from commands that display help text of any sort in another window. You can also scroll the help text with M-PageUp and M-PageDown (or, equivalently, M-prior and M-next). This is especially useful with long lists of possible completions. See Using Other Windows.

当迷你缓冲区处于活动状态时,Emacs 通常不允许大多数使用迷你缓冲区的命令。要在迷你缓冲区中允许此类命令,请将变量设置enable-recursive-minibufferst。您可能还需要minibuffer-depth-indicate-mode 在递归使用迷你缓冲区时在迷你缓冲区提示中显示当前递归深度。

Emacs normally disallows most commands that use the minibuffer while the minibuffer is active. To allow such commands in the minibuffer, set the variable enable-recursive-minibuffers to t. You might need also to enable minibuffer-depth-indicate-mode to show the current recursion depth in the minibuffer prompt on recursive use of the minibuffer.

当激活时,迷你缓冲区通常位于minibuffer-mode.这是 Emacs 的内部模式,没有任何特殊功能。

When active, the minibuffer is usually in minibuffer-mode. This is an internal Emacs mode without any special features.

当不活动时,迷你缓冲区位于 中minibuffer-inactive-mode,单击mouse-1此处会显示*留言*缓冲。如果您使用迷你缓冲区的专用框架,Emacs 还会识别那里的某些键,例如,n创建一个新框架。

When not active, the minibuffer is in minibuffer-inactive-mode, and clicking mouse-1 there shows the *Messages* buffer. If you use a dedicated frame for minibuffers, Emacs also recognizes certain keys there, for example, n to make a new frame.


9.4 完成

9.4 Completion

您通常可以使用称为完成的功能来帮助输入参数。这意味着在您输入部分参数后,Emacs 可以根据目前输入的内容填写其余部分或部分内容。

You can often use a feature called completion to help enter arguments. This means that after you type part of the argument, Emacs can fill in the rest, or some of it, based on what was typed so far.

当完成可用时,某些键(通常是TABRETSPC)会在迷你缓冲区中反弹到特殊的完成命令(请参阅完成命令)。这些命令尝试根据请求参数的命令提供的一组完成替代方案来完成微型缓冲区中的文本 。您通常可以键入?以查看补全选项列表。

When completion is available, certain keys (usually TAB, RET, and SPC) are rebound in the minibuffer to special completion commands (see Completion Commands). These commands attempt to complete the text in the minibuffer, based on a set of completion alternatives provided by the command that requested the argument. You can usually type ? to see a list of completion alternatives.

尽管完成通常是在迷你缓冲区中完成的,但该功能有时也可以在普通缓冲区中使用。请参阅符号名称的完成

Although completion is usually done in the minibuffer, the feature is sometimes available in ordinary buffers too. See Completion for Symbol Names.


9.4.1 完成示例

9.4.1 Completion Example

一个简单的例子可能会有所帮助。 M-x使用迷你缓冲区来读取命令的名称,因此完成功能是通过将迷你缓冲区文本与现有 Emacs 命令的名称进行匹配来完成的。假设您希望运行该命令auto-fill-mode。您可以通过键入 来完成此操作,但使用补全更容易。 M-x auto-fill-mode RET

A simple example may help here. M-x uses the minibuffer to read the name of a command, so completion works by matching the minibuffer text against the names of existing Emacs commands. Suppose you wish to run the command auto-fill-mode. You can do that by typing M-x auto-fill-mode RET, but it is easier to use completion.

如果您键入,则会查找以 ' 开头的补全替代项(在本例中为命令名称)M-x a u TABTAB非盟'。有几个,包括auto-fill-modeautoconf-mode,但它们都以 开头auto,所以 '非盟'在迷你缓冲区中完成'汽车'。 (更多命令可以在您的 Emacs 会话中定义。例如,如果authorize-me定义了一个调用的命令,Emacs 只能完成 '自动'。)

If you type M-x a u TAB, the TAB looks for completion alternatives (in this case, command names) that start with ‘au’. There are several, including auto-fill-mode and autoconf-mode, but they all begin with auto, so the ‘au’ in the minibuffer completes to ‘auto’. (More commands may be defined in your Emacs session. For example, if a command called authorize-me was defined, Emacs could only complete as far as ‘aut’.)

如果立即再次输入TAB,则无法确定下一个字符;它可能是 '-','A', 或者 'C'。所以它不会添加任何字符;相反,TAB在另一个窗口中显示所有可能完成的列表。

If you type TAB again immediately, it cannot determine the next character; it could be ‘-’, ‘a’, or ‘c’. So it does not add any characters; instead, TAB displays a list of all possible completions in another window.

接下来,输入-f.迷你缓冲区现在包含 '自动f',唯一以此开头的命令名称是auto-fill-mode.如果您现在输入TAB,补全将填充参数的其余部分'自动填充模式' 进入迷你缓冲区。

Next, type -f. The minibuffer now contains ‘auto-f’, and the only command name that starts with this is auto-fill-mode. If you now type TAB, completion fills in the rest of the argument ‘auto-fill-mode’ into the minibuffer.

因此,键入仅允许您输入 'a u TAB - f TAB自动填充模式'。

Hence, typing just a u TAB - f TAB allows you to enter ‘auto-fill-mode’.

TAB当点不在迷你缓冲区末尾时也可以工作。在这种情况下,它将在迷你缓冲区的点和末尾填充文本。如果您键入M-x autocm,请按 C-b将点移动到 ' 之前',您可以键入 TAB插入文本'开-' 在点和 '' 在迷你缓冲区的末尾,以便迷你缓冲区包含 '自动配置模式'。

TAB also works while point is not at the end of the minibuffer. In that case, it will fill in text both at point and at the end of the minibuffer. If you type M-x autocm, then press C-b to move point before the ‘m’, you can type TAB to insert the text ‘onf-’ at point and ‘ode’ at the end of the minibuffer, so that the minibuffer contains ‘autoconf-mode’.


9.4.2 完成命令

9.4.2 Completion Commands

以下是允许完成时在迷你缓冲区中定义的完成命令的列表。

Here is a list of the completion commands defined in the minibuffer when completion is allowed.

TAB
TAB

尽可能完整地完成迷你缓冲区中的文本;如果无法完成,则显示可能完成的列表 ( minibuffer-complete)。

Complete the text in the minibuffer as much as possible; if unable to complete, display a list of possible completions (minibuffer-complete).

SPC
SPC

从 ( ) 点之前的迷你缓冲区文本中最多补充一个单词minibuffer-complete-word。此命令不适用于经常包含空格的参数,例如文件名。

Complete up to one word from the minibuffer text before point (minibuffer-complete-word). This command is not available for arguments that often include spaces, such as file names.

RET
RET

将迷你缓冲区中的文本作为参数提交,可能首先完成 ( minibuffer-complete-and-exit)。请参阅完成退出

Submit the text in the minibuffer as the argument, possibly completing first (minibuffer-complete-and-exit). See Completion Exit.

?
?

显示完成列表 ( minibuffer-completion-help)。

Display a list of completions (minibuffer-completion-help).

TAB( minibuffer-complete) 是最基本的补全命令。它搜索与现有迷你缓冲区文本匹配的所有可能的完成,并尝试尽可能多地完成。请参阅如何选择完成替代方案,了解如何选择完成替代方案。

TAB (minibuffer-complete) is the most fundamental completion command. It searches for all possible completions that match the existing minibuffer text, and attempts to complete as much as it can. See How Completion Alternatives Are Chosen, for how completion alternatives are chosen.

SPC( minibuffer-complete-word) 类似于 TAB,但仅限于下一个连字符或空格。如果你有 '自动f'在迷你缓冲区和类型中SPC,它发现完成是'自动填充模式',但它只插入 '患病的-',给予'自动填充-'。另一个SPC此时完成了所有的方式'自动填充模式'。

SPC (minibuffer-complete-word) completes like TAB, but only up to the next hyphen or space. If you have ‘auto-f’ in the minibuffer and type SPC, it finds that the completion is ‘auto-fill-mode’, but it only inserts ‘ill-’, giving ‘auto-fill-’. Another SPC at this point completes all the way to ‘auto-fill-mode’.

如果TABSPC无法完成,它会在另一个窗口中显示匹配的完成选项列表(如果有)。您可以使用? ( )显示相同的列表minibuffer-completion-help。以下命令可与完成列表一起使用:

If TAB or SPC is unable to complete, it displays a list of matching completion alternatives (if there are any) in another window. You can display the same list with ? (minibuffer-completion-help). The following commands can be used with the completion list:

M-DOWN
M-DOWN
M-UP
M-UP

在迷你缓冲区中时, (和 ( ) 浏览补全并显示在补全缓冲区中。当 为非(默认情况下)时,使用这些命令还会将当前补全候选插入到迷你缓冲区中。如果 是,您可以使用将完成候选插入到迷你缓冲区的命令( ) 默认情况下会退出迷你缓冲区,但如果使用前缀参数,则会插入当前活动的候选,而不退出迷你缓冲区。 M-DOWNminibuffer-next-completionM-UPminibuffer-previous-completionminibuffer-completion-auto-choosenilminibuffer-completion-auto-choosenilM-RETminibuffer-choose-completionC-u M-RET

While in the minibuffer, M-DOWN (minibuffer-next-completion and M-UP (minibuffer-previous-completion) navigate through the completions and displayed in the completions buffer. When minibuffer-completion-auto-choose is non-nil (which is the default), using these commands also inserts the current completion candidate into the minibuffer. If minibuffer-completion-auto-choose is nil, you can use the M-RET command (minibuffer-choose-completion) to insert the completion candidates into the minibuffer. By default, that exits the minibuffer, but with a prefix argument, C-u M-RET inserts the currently active candidate without exiting the minibuffer.

M-v
M-v
PageUp
PageUp
prior
prior

在迷你缓冲区中键入M-v,选择显示完成列表的窗口 ( switch-to-completions)。这为使用下面的命令铺平了道路。 PageUppriorM-g M-c做同样的事情。您还可以通过其他方式选择窗口(请参阅多个窗口)。

Typing M-v, while in the minibuffer, selects the window showing the completion list (switch-to-completions). This paves the way for using the commands below. PageUp, prior and M-g M-c do the same. You can also select the window in other ways (see Multiple Windows).

RET
RET
mouse-1
mouse-1
mouse-2
mouse-2

在完成列表缓冲区中时,这选择点 ( ) 处的完成choose-completion。使用前缀参数,将完成插入到迷你缓冲区中,但不退出迷你缓冲区 - 因此,您可以改变主意并选择另一个候选者。 C-u RET

While in the completion list buffer, this chooses the completion at point (choose-completion). With a prefix argument, C-u RET inserts the completion at point into the minibuffer, but doesn’t exit the minibuffer—thus, you can change your mind and choose another candidate.

TAB
TAB
RIGHT
RIGHT
n
n

在完成列表缓冲区中时,这些键移动指向以下完成选项 ( next-completion)。

While in the completion list buffer, these keys move point to the following completion alternative (next-completion).

S-TAB
S-TAB
LEFT
LEFT
p
p

在完成列表缓冲区中时,这些键移动指向前一个完成选项 ( previous-completion)。

While in the completion list buffer, these keys move point to the previous completion alternative (previous-completion).

q
q

在完成列表缓冲区中时,这将退出显示该缓冲区的窗口并选择显示迷你缓冲区 ( ) 的窗口quit-window

While in the completion list buffer, this quits the window showing it and selects the window showing the minibuffer (quit-window).

z
z

在完成列表缓冲区中时,杀死它并删除显示它的窗口 ( kill-current-buffer)。

While in the completion list buffer, kill it and delete the window showing it (kill-current-buffer).


9.4.3 完成退出

9.4.3 Completion Exit

当命令使用微型缓冲区完成读取参数时,它还控制当您键入RET ( minibuffer-complete-and-exit) 提交参数时会发生什么。行为有四种类型:

When a command reads an argument using the minibuffer with completion, it also controls what happens when you type RET (minibuffer-complete-and-exit) to submit the argument. There are four types of behavior:

  • 严格完成仅接受精确的完成匹配。RET仅当微型缓冲区文本完全匹配或完成为 1 时,键入才会退出微型缓冲区。 否则,Emacs 拒绝退出迷你缓冲区;相反,它会尝试完成,如果无法完成,它会暂时显示 '[没有匹配]' 在迷你缓冲区文本之后。 (您仍然可以通过键入C-g取消命令来保留迷你缓冲区。)

    使用此行为的命令的一个示例是M-x,因为它接受不存在的命令名称是没有意义的。

  • Strict completion accepts only exact completion matches. Typing RET exits the minibuffer only if the minibuffer text is an exact match, or completes to one. Otherwise, Emacs refuses to exit the minibuffer; instead it tries to complete, and if no completion can be done it momentarily displays ‘[No match]’ after the minibuffer text. (You can still leave the minibuffer by typing C-g to cancel the command.)

    An example of a command that uses this behavior is M-x, since it is meaningless for it to accept a non-existent command name.

  • 谨慎完成与严格完成类似,只是RET 仅当文本已经完全匹配时才退出。如果文本完全匹配,则RET执行该完成但不退出;您必须键入一秒钟RET才能退出。

    例如,谨慎完成用于读取必须已存在的文件的文件名。

  • Cautious completion is like strict completion, except RET exits only if the text is already an exact match. If the text completes to an exact match, RET performs that completion but does not exit yet; you must type a second RET to exit.

    Cautious completion is used for reading file names for files that must already exist, for example.

  • 宽容完成允许任何输入;完成候选者只是建议。键入RET并未完成,它只是提交您输入的参数。
  • Permissive completion allows any input; the completion candidates are just suggestions. Typing RET does not complete, it just submits the argument as you have entered it.
  • 带确认的许可式完成与许可式完成类似,但有一个例外:如果您键入TAB并完成了文本直到某种中间状态(即尚未完全匹配的状态),则RET随后立即键入不会提交参数。相反,Emacs 通过暂时显示 ' 来要求确认[确认]' 在正文之后;再次输入RET 以确认并提交文本。这发现了一个常见的错误,即人们RET在意识到TAB未按预期完成之前就进行了键入。

    您可以通过自定义变量来调整确认行为 confirm-nonexistent-file-or-buffer。默认值 after-completion给出了我们刚刚描述的行为。如果将其更改为nil,Emacs 不会要求确认,而是依靠允许完成。如果将其更改为任何其他非nil值,Emacs 会要求确认前面的命令是否为TAB

    C-x C-f大多数读取文件名(如)的命令和读取缓冲区名称(如 )的命令都使用此行为 C-x b

  • Permissive completion with confirmation is like permissive completion, with an exception: if you typed TAB and this completed the text up to some intermediate state (i.e., one that is not yet an exact completion match), typing RET right afterward does not submit the argument. Instead, Emacs asks for confirmation by momentarily displaying ‘[Confirm]’ after the text; type RET again to confirm and submit the text. This catches a common mistake, in which one types RET before realizing that TAB did not complete as far as desired.

    You can tweak the confirmation behavior by customizing the variable confirm-nonexistent-file-or-buffer. The default value, after-completion, gives the behavior we have just described. If you change it to nil, Emacs does not ask for confirmation, falling back on permissive completion. If you change it to any other non-nil value, Emacs asks for confirmation whether or not the preceding command was TAB.

    This behavior is used by most commands that read file names, like C-x C-f, and commands that read buffer names, like C-x b.


9.4.4 如何选择完成方案

9.4.4 How Completion Alternatives Are Chosen

完成命令的工作原理是将大量可能的完成替代项缩小为与您在迷你缓冲区中键入的内容相匹配的较小子集。在完成示例中,我们给出了此类匹配的简单示例。确定匹配的过程相当复杂。 Emacs 尝试在大多数情况下提供合理的补全。

Completion commands work by narrowing a large list of possible completion alternatives to a smaller subset that matches what you have typed in the minibuffer. In Completion Example, we gave a simple example of such matching. The procedure of determining what constitutes a match is quite intricate. Emacs attempts to offer plausible completions under most circumstances.

Emacs 使用一种或多种完成样式(用于将迷你缓冲区文本与完成替代项相匹配的一组标准)执行完成。在完成过程中,Emacs 会依次尝试每种完成样式。如果一种样式产生一个或多个匹配项,则将其用作完成替代项的列表。如果某个样式没有产生匹配项,Emacs 就会转而使用下一个样式。

Emacs performs completion using one or more completion styles—sets of criteria for matching minibuffer text to completion alternatives. During completion, Emacs tries each completion style in turn. If a style yields one or more matches, that is used as the list of completion alternatives. If a style produces no matches, Emacs falls back on the next style.

列表变量completion-styles指定要使用的完成样式。每个列表元素都是完成样式的名称(Lisp 符号)。可用的样式符号存储在变量中 completion-styles-alist(请参阅《Emacs Lisp 参考手册》中的完成变量)。默认完成样式为(按顺序):

The list variable completion-styles specifies the completion styles to use. Each list element is the name of a completion style (a Lisp symbol). The available style symbols are stored in the variable completion-styles-alist (see Completion Variables in The Emacs Lisp Reference Manual). The default completion styles are (in order):

basic
basic

匹配的补全替代项必须与点之前的迷你缓冲区中的文本具有相同的开头。此外,如果点之后的迷你缓冲区中有任何文本,则补全替代项的其余部分必须包含该文本作为子字符串。

A matching completion alternative must have the same beginning as the text in the minibuffer before point. Furthermore, if there is any text in the minibuffer after point, the rest of the completion alternative must contain that text as a substring.

partial-completion
partial-completion

这种积极的完成方式将迷你缓冲区文本划分为由连字符或空格分隔的单词,并单独完成每个单词。 (例如,当完成命令名称时,'EM-LM' 完成到 'emacs-lisp-模式'。)

此外,一个'*迷你缓冲区文本中的 ' 被视为 通配符— 它匹配完成替代中相应位置的任何字符串。

This aggressive completion style divides the minibuffer text into words separated by hyphens or spaces, and completes each word separately. (For example, when completing command names, ‘em-l-m’ completes to ‘emacs-lisp-mode’.)

Furthermore, a ‘*’ in the minibuffer text is treated as a wildcard—it matches any string of characters at the corresponding position in the completion alternative.

emacs22
emacs22

此补全样式与 类似basic,只不过它忽略了点后迷你缓冲区中的文本。之所以如此命名,是因为它对应于 Emacs 22 中的完成行为。

This completion style is similar to basic, except that it ignores the text in the minibuffer after point. It is so-named because it corresponds to the completion behavior in Emacs 22.

还定义了以下附加完成样式,您可以completion-styles根据需要添加它们(请参阅自定义):

The following additional completion styles are also defined, and you can add them to completion-styles if you wish (see Customization):

substring
substring

匹配的完成替代方案必须包含点之前的迷你缓冲区中的文本以及点之后的迷你缓冲区中的文本作为子字符串(以相同的顺序)。

因此,如果迷你缓冲区中的文本是 '富巴', 之间有点 '' 和 '酒吧',匹配'a foo b酒吧c',其中abc可以是任何字符串,包括空字符串。

A matching completion alternative must contain the text in the minibuffer before point, and the text in the minibuffer after point, as substrings (in that same order).

Thus, if the text in the minibuffer is ‘foobar’, with point between ‘foo’ and ‘bar’, that matches ‘afoobbarc’, where a, b, and c can be any string including the empty string.

flex
flex

这种激进的完成风格,也称为flxor fuzzyscatter完成,尝试使用按顺序的子字符串来完成。例如,它可以考虑'' 匹配 '弗罗多' 或者 '巴巴祖'。

This aggressive completion style, also known as flx or fuzzy or scatter completion, attempts to complete using in-order substrings. For example, it can consider ‘foo’ to match ‘frodo’ or ‘fbarbazoo’.

initials
initials

这种非常激进的完成风格试图完成首字母缩略词和首字母缩写词。例如,当完成命令名称时,它匹配 '左旋' 到 '列表命令历史记录'。

This very aggressive completion style attempts to complete acronyms and initialisms. For example, when completing command names, it matches ‘lch’ to ‘list-command-history’.

还有一种非常简单的完成样式,称为emacs21.在这种风格中,如果迷你缓冲区中的文本是 '富巴',仅匹配以 ' 开头的富巴' 被考虑。

There is also a very simple completion style called emacs21. In this style, if the text in the minibuffer is ‘foobar’, only matches starting with ‘foobar’ are considered.

您可以通过设置变量在不同情况下使用不同的完成样式completion-category-overrides。例如,默认设置表示仅使用缓冲区名称basicsubstring完成缓冲区名称。

You can use different completion styles in different situations, by setting the variable completion-category-overrides. For example, the default setting says to use only basic and substring completion for buffer names.


9.4.5 完成选项

9.4.5 Completion Options

在完成区分大小写的参数(例如命令名称)时,大小写很重要。例如,当完成命令名称时,'非盟' 未完成 '自动填充模式'。完成参数时会忽略大小写差异,此时大小写并不重要。

Case is significant when completing case-sensitive arguments, such as command names. For example, when completing command names, ‘AU’ does not complete to ‘auto-fill-mode’. Case differences are ignored when completing arguments in which case does not matter.

完成文件名时,如果变量read-file-name-completion-ignore-casenil.默认值是nil在文件名区分大小写的系统上,例如 GNU/Linux;它不适nil用于文件名不区分大小写的系统,例如 Microsoft Windows。完成缓冲区名称时,如果变量read-buffer-completion-ignore-casenil;则忽略大小写差异。默认为nil.

When completing file names, case differences are ignored if the variable read-file-name-completion-ignore-case is non-nil. The default value is nil on systems that have case-sensitive file-names, such as GNU/Linux; it is non-nil on systems that have case-insensitive file-names, such as Microsoft Windows. When completing buffer names, case differences are ignored if the variable read-buffer-completion-ignore-case is non-nil; the default is nil.

在完成文件名时,Emacs 通常会忽略某些被认为不太可能被选择的替代项,这些替代项由 list 变量确定completion-ignored-extensions。列表中的每个元素都应该是一个字符串;任何以此类字符串结尾的文件名都将被忽略作为完成替代。任何以斜线结尾的元素 (/) 代表子目录名称。的标准值 由、、 等completion-ignored-extensions几个要素组成 。例如,如果目录包含 '".o"".elc""~"foo.c' 和 'foo.elc','' 完成到 'foo.c'。但是,如果所有可能的补全都以其他方式被忽略的字符串结尾,则它们不会被忽略:在前面的示例中, 'foo.e' 完成到 'foo.elc'。completion-ignored-extensions在完成列表中显示完成选项时, Emacs 会忽略。

When completing file names, Emacs usually omits certain alternatives that are considered unlikely to be chosen, as determined by the list variable completion-ignored-extensions. Each element in the list should be a string; any file name ending in such a string is ignored as a completion alternative. Any element ending in a slash (/) represents a subdirectory name. The standard value of completion-ignored-extensions has several elements including ".o", ".elc", and "~". For example, if a directory contains ‘foo.c’ and ‘foo.elc’, ‘foo’ completes to ‘foo.c’. However, if all possible completions end in otherwise-ignored strings, they are not ignored: in the previous example, ‘foo.e’ completes to ‘foo.elc’. Emacs disregards completion-ignored-extensions when showing completion alternatives in the completion list.

Shell 补全是文件名补全的扩展版本,请参阅Shell 模式选项

Shell completion is an extended version of filename completion, see Shell Mode Options.

如果completion-auto-help设置为nil,则完成命令从不显示完成列表缓冲区;您必须键入 ?才能显示该列表。如果值为lazy,Emacs 仅在第二次尝试完成时显示完成列表缓冲区。换句话说,如果没有什么要完成的,第一个TAB 会回响'下一个字符不唯一';第二个TAB显示完成列表缓冲区。如果值为always,则在尝试完成时始终显示完成列表缓冲区。

If completion-auto-help is set to nil, the completion commands never display the completion list buffer; you must type ? to display the list. If the value is lazy, Emacs only shows the completion list buffer on the second attempt to complete. In other words, if there is nothing to complete, the first TAB echoes ‘Next char not unique’; the second TAB shows the completion list buffer. If the value is always, the completion list buffer is always shown when completion is attempted.

完成列表缓冲区首次显示后的显示也由 控制completion-auto-help。如果值为tlazy,则当 Emacs 能够完成时,显示完成情况的窗口会弹出(如果在您输入更多文本后 Emacs 再次无法完成,则可能会再次弹出);如果值为always,则只有退出补全时才会弹出窗口。该值visible是一个混合体:它的行为就像 t决定是否弹出显示完成列表缓冲区的窗口时一样,也像always决定是否将其弹出时一样。

The display of the completion list buffer after it is shown for the first time is also controlled by completion-auto-help. If the value is t or lazy, the window showing the completions pops down when Emacs is able to complete (and may pop up again if Emacs is again unable to complete after you type some more text); if the value is always, the window pops down only when you exit the completion. The value visible is a hybrid: it behaves like t when it decides whether to pop up the window showing the completion list buffer, and like always when it decides whether to pop it down.

Emacs 在显示该窗口时可以选择选择显示完成情况的窗口。要启用此行为,请将用户选项自定义completion-auto-select为,这会更改Emacs 弹出补全时 t的行为:按下将切换到补全列表缓冲区,然后您可以通过光标移动命令移动到候选者并使用 进行选择 。如果的 值为,则第一个将弹出完成列表缓冲区,第二个将切换到它。 TABTABRETcompletion-auto-selectsecond-tabTAB

Emacs can optionally select the window showing the completions when it shows that window. To enable this behavior, customize the user option completion-auto-select to t, which changes the behavior of TAB when Emacs pops up the completions: pressing TAB will switch to the completion list buffer, and you can then move to a candidate by cursor motion commands and select it with RET. If the value of completion-auto-select is second-tab, then the first TAB will pop up the completions list buffer, and the second one will switch to it.

如果completion-cycle-threshold是非nil,则完成命令可以循环选择完成选项。通常,如果微型缓冲区中的文本有多个补全替代方案,则补全命令会补全最长的公共子字符串。如果更改completion-cycle-thresholdt,则完成命令将完成到第一个完成选项;完成命令的每次后续调用都会以循环方式将其替换为下一个完成替代命令。如果您给出completion-cycle-threshold数值n,则完成命令仅在存在n或更少的替代项时才切换到此循环行为。

If completion-cycle-threshold is non-nil, completion commands can cycle through completion alternatives. Normally, if there is more than one completion alternative for the text in the minibuffer, a completion command completes up to the longest common substring. If you change completion-cycle-threshold to t, the completion command instead completes to the first of those completion alternatives; each subsequent invocation of the completion command replaces that with the next completion alternative, in a cyclic manner. If you give completion-cycle-threshold a numeric value n, completion commands switch to this cycling behavior only when there are n or fewer alternatives.

当显示补全时,Emacs 通常会弹出一个新的缓冲区来显示补全。默认情况下,完成将水平排序,使用适合窗口宽度的尽可能多的列,但这可以通过自定义completions-format 用户选项来更改。如果其值为vertical,Emacs 将垂直排序补全,如果为one-column,Emacs 将仅使用一列。

When displaying completions, Emacs will normally pop up a new buffer to display the completions. The completions will by default be sorted horizontally, using as many columns as will fit in the window-width, but this can be changed by customizing the completions-format user option. If its value is vertical, Emacs will sort the completions vertically instead, and if it’s one-column, Emacs will use just one column.

用户completions-sort选项控制完成在 ' 中的排序顺序*完工*' 缓冲。默认值为alphabetical,按字母顺序排序。该值nil禁用排序。该值也可以是一个函数,它将使用完成列表来调用,并且应该按所需的顺序返回列表。

The completions-sort user option controls the order in which the completions are sorted in the ‘*Completions*’ buffer. The default is alphabetical, which sorts in alphabetical order. The value nil disables sorting. The value can also be a function, which will be called with the list of completions, and should return the list in the desired order.

completions-max-height为非时nil,它限制完成窗口的大小。它在行中指定,并包括模式、标题行和底部分隔线(如果有)。对于完成窗口显示属性的更复杂的控制,您可以使用 display-buffer-alist(请参阅The Emacs Lisp Reference Manual中的Action Alists for Buffer Display)。

When completions-max-height is non-nil, it limits the size of the completions window. It is specified in lines and include mode, header line and a bottom divider, if any. For a more complex control of the Completion window display properties, you can use display-buffer-alist (see Action Alists for Buffer Display in The Emacs Lisp Reference Manual).

该变量completions-header-format是一个格式规范字符串,用于控制候选完成列表之前显示的信息行。如果它包含一个'%s' 构造,它被完成列表缓冲区中显示的完成数量替换。要禁止显示标题行,请将此变量自定义为 nil。作为该变量值的字符串可以具有文本属性来更改标题行的视觉外观;一些有用的属性facecursor-intangible (请参阅《Emacs Lisp 参考手册》具有特殊含义的属性)。

The variable completions-header-format is a format spec string to control the informative line shown before the completions list of candidates. If it contains a ‘%s’ construct, that get replaced by the number of completions shown in the completion list buffer. To suppress the display of the heading line, customize this variable to nil. The string that is the value of this variable can have text properties to change the visual appearance of the heading line; some useful properties face or cursor-intangible (see Properties with Special Meanings in The Emacs Lisp Reference Manual).

当命名一张脸时,当前的完成候选者(将通过键入或单击鼠标completions-highlight-face选择的那个 )将使用该脸突出显示。RET该变量的默认值为 completions-highlight;该值nil禁用此突出显示。此功能使用特殊的文本属性 cursor-face

When completions-highlight-face names a face, the current completion candidate, the one that will be selected by typing RET or clicking the mouse, will be highlighted using that face. The default value of this variable is completions-highlight; the value is nil disables this highlighting. This feature uses the special text property cursor-face.


9.5 迷你缓冲区历史

9.5 Minibuffer History

您在迷你缓冲区中输入的所有内容都会保存在迷你缓冲区历史列表中,以便您以后可以轻松地再次使用它。这包括完成候选(例如文件名、缓冲区名称、命令名称等)和任何其他类型的迷你缓冲区输入。您可以使用以下命令快速将较早的或替代的响应提取到迷你缓冲区中:

Everything you type in the minibuffer is saved in a minibuffer history list so you can easily use it again later. This includes completion candidates (such as file names, buffer names, command names, etc.) and any other kind of minibuffer input. You can use the following commands to quickly fetch an earlier or alternative response into the minibuffer:

M-p
M-p

移至迷你缓冲区历史记录中的上一项,即较早的参数 ( previous-history-element)。

Move to the previous item in the minibuffer history, an earlier argument (previous-history-element).

M-n
M-n

移至迷你缓冲区历史记录中的下一项 ( next-history-element)。

Move to the next item in the minibuffer history (next-history-element).

UP
UP
DOWN
DOWN

M-p与and类似M-n,但先移至多行项目的上一行或下一行,然后再转到上一个历史记录项目 ( previous-line-or-history-elementand next-line-or-history-element)。

Like M-p and M-n, but move to the previous or next line of a multi-line item before going to the previous history item (previous-line-or-history-element and next-line-or-history-element) .

M-r regexp RET
M-r regexp RET

移至迷你缓冲区历史记录中与regexp ( )匹配的较早项目previous-matching-history-element

Move to an earlier item in the minibuffer history that matches regexp (previous-matching-history-element).

M-s regexp RET
M-s regexp RET

移至迷你缓冲区历史记录中与 regexp ( next-matching-history-element) 匹配的后续项目。

Move to a later item in the minibuffer history that matches regexp (next-matching-history-element).

在迷你缓冲区中时,M-p( previous-history-element) 在迷你缓冲区历史列表中移动,一次一项。每个都 M-p从历史列表中提取较早的项目到迷你缓冲区中,替换其现有内容。键入M-n ( next-history-element) 以相反方向移动迷你缓冲区历史记录列表,将后面的条目提取到迷你缓冲区中。

While in the minibuffer, M-p (previous-history-element) moves through the minibuffer history list, one item at a time. Each M-p fetches an earlier item from the history list into the minibuffer, replacing its existing contents. Typing M-n (next-history-element) moves through the minibuffer history list in the opposite direction, fetching later entries into the minibuffer.

如果您M-n在迷你缓冲区历史记录中没有后续条目时输入迷你缓冲区(例如,如果您之前没有输入过M-p),Emacs 会尝试从默认参数列表中获取:您可能输入的值。你可以将其视为穿越“未来历史”。

If you type M-n in the minibuffer when there are no later entries in the minibuffer history (e.g., if you haven’t previously typed M-p), Emacs tries fetching from a list of default arguments: values that you are likely to enter. You can think of this as moving through the “future history”.

文件名的“未来历史记录”包括您可能会发现有用的几种可能的替代方案,例如当前缓冲区中的文件名或 URL。在这种情况下,放入“未来历史记录”的默认值由选项值中提到的函数控制file-name-at-point-functions。默认情况下,它的值会调用ffap包(请参阅在 Point 处查找文件和 URL),该包尝试从 point 周围的文本猜测默认文件或 URL。要禁用这种猜测,请将该选项自定义为一个nil 值,然后文件名的“未来历史记录”将仅包括当前缓冲区访问的文件(如果有)和默认目录。

The “future history” for file names includes several possible alternatives you may find useful, such as the file name or the URL at point in the current buffer. The defaults put into the “future history” in this case are controlled by the functions mentioned in the value of the option file-name-at-point-functions. By default, its value invokes the ffap package (see Finding Files and URLs at Point), which tries to guess the default file or URL from the text around point. To disable this guessing, customize the option to a nil value, then the “future history” of file names will include only the file, if any, visited by the current buffer, and the default directory.

箭头键UPDOWN的工作方式类似于 M-pM-n,但如果当前历史记录项长于单行,它们允许您在转到上一个或下一个历史记录项之前移动到当前历史记录项的上一行或下一行。

The arrow keys UP and DOWN work like M-p and M-n, but if the current history item is longer than a single line, they allow you to move to the previous or next line of the current history item before going to the previous or next history item.

M-p如果您编辑由或迷你缓冲区历史记录命令插入的文本M-n ,这不会更改其在历史记录列表中的条目。但是,当您提交时,已编辑的参数确实会出现在历史列表的末尾。

If you edit the text inserted by the M-p or M-n minibuffer history commands, this does not change its entry in the history list. However, the edited argument does go at the end of the history list when you submit it.

您可以使用M-r( previous-matching-history-element) 搜索历史列表中较旧的元素,使用M-s ( next-matching-history-element) 搜索较新的条目。这些命令中的每一个都要求一个正则表达式 作为参数,并将第一个匹配的条目提取到迷你缓冲区中。有关正则表达式的说明,请参阅正则表达式语法。数字前缀参数n表示获取第 n 个匹配条目。这些命令很不寻常,因为它们使用迷你缓冲区来读取正则表达式参数,即使它们是从迷你缓冲区调用的。正则表达式中的大写字母使搜索区分大小写(请参阅搜索期间的宽松匹配)。

You can use M-r (previous-matching-history-element) to search through older elements in the history list, and M-s (next-matching-history-element) to search through newer entries. Each of these commands asks for a regular expression as an argument, and fetches the first matching entry into the minibuffer. See Syntax of Regular Expressions, for an explanation of regular expressions. A numeric prefix argument n means to fetch the nth matching entry. These commands are unusual, in that they use the minibuffer to read the regular expression argument, even though they are invoked from the minibuffer. An upper-case letter in the regular expression makes the search case-sensitive (see Lax Matching During Searching).

您还可以使用增量搜索来搜索历史记录。请参阅搜索迷你缓冲区

You can also search through the history using an incremental search. See Searching the Minibuffer.

Emacs 为几种不同类型的参数保留单独的历史列表。例如,有一个文件名列表,由所有读取文件名的命令使用。其他历史列表包括缓冲区名称、命令名称(由M-x)和命令参数(由 等命令使用query-replace)。

Emacs keeps separate history lists for several different kinds of arguments. For example, there is a list for file names, used by all the commands that read file names. Other history lists include buffer names, command names (used by M-x), and command arguments (used by commands like query-replace).

该变量history-length指定迷你缓冲区历史列表的最大长度;如果列表太长,添加新元素会删除最旧的元素。如果值为t,则没有最大长度。

The variable history-length specifies the maximum length of a minibuffer history list; adding a new element deletes the oldest element if the list gets too long. If the value is t, there is no maximum length.

该变量history-delete-duplicates指定是否删除历史记录中的重复项。如果它不是 - nil,则添加新元素将从列表中删除与其相等的所有其他元素。默认为nil.

The variable history-delete-duplicates specifies whether to delete duplicates in history. If it is non-nil, adding a new element deletes from the list all other elements that are equal to it. The default is nil.


9.6 重复迷你缓冲区命令

9.6 Repeating Minibuffer Commands

每个使用一次迷你缓冲区的命令都会记录在一个特殊的历史记录列表中,即命令历史记录及其参数值,以便您可以重复整个命令。特别是,每次使用M-x都会记录在那里,因为M-x 使用迷你缓冲区来读取命令名称。

Every command that uses the minibuffer once is recorded on a special history list, the command history, together with the values of its arguments, so that you can repeat the entire command. In particular, every use of M-x is recorded there, since M-x uses the minibuffer to read the command name.

C-x ESC ESC
C-x ESC ESC

重新执行命令历史记录中最近的迷你缓冲区命令 ( repeat-complex-command)。

Re-execute a recent minibuffer command from the command history (repeat-complex-command).

M-x list-command-history
M-x list-command-history

显示整个命令历史记录,显示所有可以重复的命令 ,最近的命令在前。 C-x ESC ESC

Display the entire command history, showing all the commands C-x ESC ESC can repeat, most recent first.

C-x ESC ESC重新执行最近使用迷你缓冲区的命令。如果没有参数,它会重复最后一个这样的命令。数字参数指定要重复的命令; 1 表示最后一篇,2 表示上一篇,以此类推。

C-x ESC ESC re-executes a recent command that used the minibuffer. With no argument, it repeats the last such command. A numeric argument specifies which command to repeat; 1 means the last one, 2 the previous, and so on.

C-x ESC ESC工作原理是将前一个命令转换为 Lisp 表达式,然后输入一个用该表达式的文本初始化的迷你缓冲区。即使您不懂 Lisp,也可能会很明显显示哪个命令用于重复。如果您只输入RET,则会重复该命令,不会发生变化。您还可以在执行命令之前通过编辑 Lisp 表达式来更改命令。执行的命令将添加到命令历史记录的前面,除非它与最近的项目相同。

C-x ESC ESC works by turning the previous command into a Lisp expression and then entering a minibuffer initialized with the text for that expression. Even if you don’t know Lisp, it will probably be obvious which command is displayed for repetition. If you type just RET, that repeats the command unchanged. You can also change the command by editing the Lisp expression before you execute it. The executed command is added to the front of the command history unless it is identical to the most recent item.

一旦进入迷你缓冲区,您就可以使用常用的迷你缓冲区历史命令(请参阅迷你缓冲区历史记录)在历史列表中移动。找到所需的上一个命令后,您可以照常编辑其表达式,然后通过键入 执行它。 C-x ESC ESCRET

Once inside the minibuffer for C-x ESC ESC, you can use the usual minibuffer history commands (see Minibuffer History) to move through the history list. After finding the desired previous command, you can edit its expression as usual and then execute it by typing RET.

严格来说,增量搜索不使用迷你缓冲区。因此,尽管它的行为类似于复杂命令,但它通常不会出现在 的历史列表中。您可以通过设置为非值来使增量搜索命令出现在历史记录中 。请参阅增量搜索C-x ESC ESCisearch-resume-in-command-historynil

Incremental search does not, strictly speaking, use the minibuffer. Therefore, although it behaves like a complex command, it normally does not appear in the history list for C-x ESC ESC. You can make incremental search commands appear in the history by setting isearch-resume-in-command-history to a non-nil value. See Incremental Search.

之前使用迷你缓冲区的命令列表作为 Lisp 列表存储在变量 中command-history。每个元素都是一个 Lisp 表达式,描述一个命令及其参数。 Lisp 程序可以通过eval使用 元素调用来重新执行命令command-history

The list of previous minibuffer-using commands is stored as a Lisp list in the variable command-history. Each element is a Lisp expression that describes one command and its arguments. Lisp programs can re-execute a command by calling eval with the command-history element.


9.7 输入密码

9.7 Entering passwords

有时,您可能需要在 Emacs 中输入密码。例如,当您告诉 Emacs 通过网络协议(例如 FTP)访问另一台计算机上的文件时,您通常需要提供密码才能访问该计算机(请参阅远程文件)。

Sometimes, you may need to enter a password into Emacs. For instance, when you tell Emacs to visit a file on another machine via a network protocol such as FTP, you often need to supply a password to gain access to the machine (see Remote Files).

输入密码与使用迷你缓冲区类似。 Emacs 在回显区域显示提示(例如 '密码:');输入所需密码后,按RET提交。为了防止其他人看到您的密码,您键入的每个字符都会显示为星号('*') 而不是通常的形式。

Entering a password is similar to using a minibuffer. Emacs displays a prompt in the echo area (such as ‘Password: ’); after you type the required password, press RET to submit it. To prevent others from seeing your password, every character you type is displayed as an asterisk (‘*’) instead of its usual form.

输入密码时无法使用与迷你缓冲区相关的大多数功能和命令 。没有历史记录或完成情况,并且在提交密码之前您无法更改窗口或使用 Emacs 执行任何其他操作。

Most of the features and commands associated with the minibuffer cannot be used when entering a password. There is no history or completion, and you cannot change windows or perform any other action with Emacs until you have submitted the password.

在输入密码时,您可以按DEL向后删除,删除最后输入的字符。 C-u删除您迄今为止输入的所有内容。 C-g退出密码提示(请参阅退出和中止)。 C-y将当前的终止插入到密码中(请参阅终止和移动文本)。您可以键入RETESC来提交密码。任何其他自插入字符键都会将关联的字符插入到密码中,并忽略所有其他输入。

While you are typing the password, you may press DEL to delete backwards, removing the last character entered. C-u deletes everything you have typed so far. C-g quits the password prompt (see Quitting and Aborting). C-y inserts the current kill into the password (see Killing and Moving Text). You may type either RET or ESC to submit the password. Any other self-inserting character key inserts the associated character into the password, and all other input is ignored.


9.8 是或否提示

9.8 Yes or No Prompts

Emacs 命令可能要求您在执行过程中回答是或否问题。此类查询主要有两种类型。

An Emacs command may require you to answer a yes-or-no question during the course of its execution. Such queries come in two main varieties.

对于第一种是或否查询,提示以 ' 结尾(y 或 n)' 。您可以通过键入一个键来回答查询,“y' 或者 'n',它立即退出迷你缓冲区并传递响应。例如,如果您键入C-x C-w ( write-file) 来保存缓冲区,并输入现有文件的名称,Emacs 会发出如下提示:

For the first type of yes-or-no query, the prompt ends with ‘(y or n). You answer the query by typing a single key, either ‘y’ or ‘n’, which immediately exits the minibuffer and delivers the response. For example, if you type C-x C-w (write-file) to save a buffer, and enter the name of an existing file, Emacs issues a prompt like this:

文件“foo.el”存在;覆盖? (y 或 n)
File ‘foo.el’ exists; overwrite? (y or n)

如果给出错误答案会产生严重后果,通常会使用第二种是或否查询;因此它具有更长的提示符,以 ' 结尾(是还是不是)'。例如,如果您在未保存更改的文件访问缓冲区上调用C-x k( kill-buffer),Emacs 会使用如下提示激活迷你缓冲区:

The second type of yes-or-no query is typically employed if giving the wrong answer would have serious consequences; it thus features a longer prompt ending with ‘(yes or no)’. For example, if you invoke C-x k (kill-buffer) on a file-visiting buffer with unsaved changes, Emacs activates the minibuffer with a prompt like this:

缓冲区 foo.el 已修改;无论如何都要杀? (是还是不是)
Buffer foo.el modified; kill anyway? (yes or no)

要回答,您必须输入 '是的' 或者 '' 进入迷你缓冲区,然后是RET.

To answer, you must type ‘yes’ or ‘no’ into the minibuffer, followed by RET.

对于两种类型的是或否查询,迷你缓冲区的行为如前面部分所述;您可以使用 使选定的窗口居中 C-l,滚动该窗口(C-vPageDown向前滚动,M-vPageUp向后滚动),使用 切换到另一个窗口C-x o,使用历史命令M-pM-n等。键入C-g以消除查询,并退出迷你缓冲区和查询命令(请参阅退出和中止)。

With both types of yes-or-no query the minibuffer behaves as described in the previous sections; you can recenter the selected window with C-l, scroll that window (C-v or PageDown scrolls forward, M-v or PageUp scrolls backward), switch to another window with C-x o, use the history commands M-p and M-n, etc. Type C-g to dismiss the query, and quit the minibuffer and the querying command (see Quitting and Aborting).


10 按名称运行命令

10 Running Commands by Name

每个 Emacs 命令都有一个可用于运行它的名称。为了方便起见,许多命令还具有键绑定。您可以通过键入按键来运行这些命令,也可以按名称运行它们。大多数 Emacs 命令没有键绑定,因此运行它们的唯一方法是通过名称。 (有关如何设置 键绑定,请参阅自定义键绑定。)

Every Emacs command has a name that you can use to run it. For convenience, many commands also have key bindings. You can run those commands by typing the keys, or run them by name. Most Emacs commands have no key bindings, so the only way to run them is by name. (See Customizing Key Bindings, for how to set up key bindings.)

按照惯例,命令名称由一个或多个单词组成,并用连字符分隔;例如,auto-fill-modemanual-entry。命令名称大多使用完整的英文单词,以便于记忆。

By convention, a command name consists of one or more words, separated by hyphens; for example, auto-fill-mode or manual-entry. Command names mostly use complete English words to make them easier to remember.

要按名称运行命令,请以 开头M-x,键入命令名称,然后以 终止RETM-x使用迷你缓冲区读取命令名称。字符串 'MX' 出现在迷你缓冲区的开头作为提示,提醒您输入要运行的命令名称。 RET退出迷你缓冲区并运行命令。有关迷你缓冲区的更多信息, 请参阅迷你缓冲区。

To run a command by name, start with M-x, type the command name, then terminate it with RET. M-x uses the minibuffer to read the command name. The string ‘M-x’ appears at the beginning of the minibuffer as a prompt to remind you to enter a command name to be run. RET exits the minibuffer and runs the command. See The Minibuffer, for more information on the minibuffer.

您可以使用补全来输入命令名称。例如,要调用命令forward-char,您可以键入

You can use completion to enter the command name. For example, to invoke the command forward-char, you can type

Mx 前向字符RET
M-x forward-char RET

或者

or

MX 前向TABCRET
M-x forw TAB c RET

请注意,这forward-char与您使用 key 调用的命令相同C-f。键绑定的存在不会阻止您按名称运行命令。

Note that forward-char is the same command that you invoke with the key C-f. The existence of a key binding does not stop you from running the command by name.

当完成命令时,它会忽略在任何以前的 Emacs 主要版本中声明为过时M-x的命令;对于这些,您必须输入他们的全名。列出了在当前版本的 Emacs 中标记为过时的命令。 (过时的命令是那些存在更新、更好的替代命令的命令,并且计划在未来的某些 Emacs 版本中删除这些命令。)

When M-x completes on commands, it ignores the commands that were declared obsolete in any previous major version of Emacs; for these, you will have to type their full name. Commands that were marked obsolete in the current version of Emacs are listed. (Obsolete commands are those for which newer, better alternatives exist, and which are slated for removal in some future Emacs release.)

此外,完成可以排除与当前缓冲区的主要模式(请参阅主要模式)和次要模式(请参阅次要模式M-x不相关且通常无法使用的命令。默认情况下,不排除任何命令,但您可以自定义选项以从完成结果中排除那些不相关的命令。 read-extended-command-predicate

In addition, M-x completion can exclude commands that are not relevant to, and generally cannot work with, the current buffer’s major mode (see Major Modes) and minor modes (see Minor Modes). By default, no commands are excluded, but you can customize the option read-extended-command-predicate to exclude those irrelevant commands from completion results.

相反,Emacs 可以排除除那些与当前缓冲区特别相关的命令之外的所有命令。M-S-x(即“meta shift x”)命令的工作方式与 类似,M-x但它不会列出 Emacs 知道的所有(或大多数)命令,而是只会列出已标记为“属于”当前主要模式的命令,或任何启用的次要模式。

Conversely, Emacs can exclude all commands except those that are particularly relevant to the current buffer. The M-S-x (that’s “meta shift x”) command works just like M-x, but instead of listing all (or most) of the commands Emacs knows about, it will only list the commands that have been marked as “belonging” to the current major mode, or any enabled minor modes.

要取消M-x而不运行命令,请键入C-g而不是输入命令名称。这将带您回到命令级别。

To cancel the M-x and not run a command, type C-g instead of entering the command name. This takes you back to command level.

要将数字参数传递给您调用的命令 M-x,请在之前指定数字参数M-x。当读取命令名称时,参数值出现在提示中,最后M-x将参数传递给该命令。例如,要将数字参数 42 传递给命令, forward-char您可以键入。 C-u 42 M-x forward-char RET

To pass a numeric argument to the command you are invoking with M-x, specify the numeric argument before M-x. The argument value appears in the prompt while the command name is being read, and finally M-x passes the argument to that command. For example, to pass the numeric argument of 42 to the command forward-char you can type C-u 42 M-x forward-char RET.

当您运行的命令M-x具有键绑定时,Emacs 会在运行该命令后在回显区域中提及这一点。例如,如果您键入M-x forward-word,则消息表明您可以通过键入 来运行相同的命令M-f。您可以通过将变量设置suggest-key-bindings为 来 关闭这些消息nil。的值suggest-key-bindings也可以是一个数字,在这种情况下,Emacs 将在将绑定从显示中删除之前显示该绑定数秒。默认行为是显示绑定 2 秒。

When the command you run with M-x has a key binding, Emacs mentions this in the echo area after running the command. For example, if you type M-x forward-word, the message says that you can run the same command by typing M-f. You can turn off these messages by setting the variable suggest-key-bindings to nil. The value of suggest-key-bindings can also be a number, in which case Emacs will show the binding for that many seconds before removing it from display. The default behavior is to display the binding for 2 seconds.

此外,当suggest-key-bindings为非时nil, 的完成列表M-x将显示所有具有这些键绑定的命令的等效键绑定。

Additionally, when suggest-key-bindings is non-nil, the completion list of M-x shows equivalent key bindings for all commands that have them.

没有键绑定的命令,在“”处输入少于其全名后仍然可以调用MX' 迅速的。如果这些简写明显短于完整的命令名称,并且 extended-command-suggest-shorter不是nil.的设置suggest-key-bindings也会影响这些提示。

Commands that don’t have key bindings, can still be invoked after typing less than their full name at the ‘M-x’ prompt. Emacs mentions such shorthands in the echo area if they are significantly shorter than the full command name, and extended-command-suggest-shorter is non-nil. The setting of suggest-key-bindings affects these hints as well.

在本手册中,当我们谈到按名称运行命令时,我们经常省略RET终止名称的 。因此我们可以说 M-x auto-fill-mode而不是。我们提到“仅”是为了强调,例如当命令后面跟着参数时。 M-x auto-fill-mode RETRET

In this manual, when we speak of running a command by name, we often omit the RET that terminates the name. Thus we might say M-x auto-fill-mode rather than M-x auto-fill-mode RET. We mention the RET only for emphasis, such as when the command is followed by arguments.

M-x通过运行 command 来工作 execute-extended-command,该命令负责读取另一个命令的名称并调用它。

M-x works by running the command execute-extended-command, which is responsible for reading the name of another command and invoking it.


11 帮助

11 Help

Emacs 提供了各种各样的帮助命令,所有命令都可以通过前缀键C-h(或等效的功能键 F1)访问。以下各节介绍了这些帮助命令。您还可以键入C-h C-h以查看帮助命令列表 ( help-for-help)。您可以使用SPC和滚动列表 DEL,然后键入所需的帮助命令。要取消,请键入C-g

Emacs provides a wide variety of help commands, all accessible through the prefix key C-h (or, equivalently, the function key F1). These help commands are described in the following sections. You can also type C-h C-h to view a list of help commands (help-for-help). You can scroll the list with SPC and DEL, then type the help command you want. To cancel, type C-g.

许多帮助命令在特殊的帮助缓冲区中显示其信息。在此缓冲区中,您可以键入SPCDEL来滚动并键入RET以跟随超链接。请参阅帮助模式命令

Many help commands display their information in a special help buffer. In this buffer, you can type SPC and DEL to scroll and type RET to follow hyperlinks. See Help Mode Commands.

默认情况下,帮助命令在单独的窗口中显示帮助缓冲区,而无需选择该窗口。该变量 help-window-select控制这一点:它的默认值为 nil;如果自定义为 值t,则帮助命令无条件选择帮助窗口,如果其值为 other,则仅当所选帧上有两个以上窗口时才选择帮助窗口。

By default, help commands display the help buffer in a separate window without selecting that window. The variable help-window-select controls this: its default value is nil; if it’s customized to the value t, the help window is unconditionally selected by help commands, and if its value is other, the help window is selected only if there are more than two windows on the selected frame.

相反,' 中的许多命令*帮助*' buffer 会弹出一个新窗口来显示结果。例如,单击链接显示源代码,或使用命令i显示手动条目,将(默认情况下)弹出一个新窗口。如果 help-window-keep-selected更改为非nil,则窗口显示 '*帮助*' 缓冲区将被重用。

Conversely, many commands in the ‘*Help*’ buffer will pop up a new window to display the results. For instance, clicking on the link to show the source code, or using the i command to display the manual entry, will (by default) pop up a new window. If help-window-keep-selected is changed to non-nil, the window displaying the ‘*Help*’ buffer will be reused instead.

如果您正在寻找某个功能,但不知道它的名称或在哪里查找,我们推荐三种方法。首先,尝试 apropos 命令,然后尝试搜索手册索引,然后查看常见问题解答和包关键字,最后尝试列出外部包。

If you are looking for a certain feature, but don’t know what it is called or where to look, we recommend three methods. First, try an apropos command, then try searching the manual index, then look in the FAQ and the package keywords, and finally try listing external packages.

C-h a topics RET
C-h a topics RET

这将搜索名称与参数 主题匹配的命令。参数可以是关键字、关键字列表或正则表达式(请参阅正则表达式语法)。参见Apropos

This searches for commands whose names match the argument topics. The argument can be a keyword, a list of keywords, or a regular expression (see Syntax of Regular Expressions). See Apropos.

C-h i d m emacs RET i topic RET
C-h i d m emacs RET i topic RET

这将在 Emacs 信息手册的索引中搜索主题,并显示找到的第一个匹配项。按,查看后续比赛。您可以使用正则表达式作为topic

This searches for topic in the indices of the Emacs Info manual, displaying the first match found. Press , to see subsequent matches. You can use a regular expression as topic.

C-h i d m emacs RET s topic RET
C-h i d m emacs RET s topic RET

类似,但搜索手册 文本而不是索引。

Similar, but searches the text of the manual rather than the indices.

C-h C-f
C-h C-f

这将使用 Info 显示 Emacs 常见问题解答。

This displays the Emacs FAQ, using Info.

C-h p
C-h p

这会根据关键字显示可用的 Emacs 软件包。请参阅包的关键字搜索

This displays the available Emacs packages based on keywords. See Keyword Search for Packages.

M-x list-packages
M-x list-packages

这将显示外部包的列表。请参阅Emacs Lisp 包

This displays a list of external packages. See Emacs Lisp Packages.

C-hF1在其他各种情况下也表示“帮助”。例如,您可以在前缀键后键入它们,以查看可以跟随该前缀键的键的列表。 (您也可以 ?在这种情况下使用。一些前缀键不支持C-h or?以这种方式,因为它们为这些输入定义了其他含义,但它们都支持F1。)

C-h or F1 mean “help” in various other contexts as well. For instance, you can type them after a prefix key to view a list of the keys that can follow the prefix key. (You can also use ? in this context. A few prefix keys don’t support C-h or ? in this way, because they define other meanings for those inputs, but they all support F1.)


11.1 帮助摘要

11.1 Help Summary

以下是用于访问内置文档的帮助命令的摘要。其中大部分内容将在以下各节中进行更详细的描述。

Here is a summary of help commands for accessing the built-in documentation. Most of these are described in more detail in the following sections.

C-h a topics RET
C-h a topics RET

显示名称与主题 ( )匹配的命令列表apropos-command。参见Apropos

Display a list of commands whose names match topics (apropos-command). See Apropos.

C-h b
C-h b

显示所有活动的键绑定;首先是次要模式绑定,然后是主要模式绑定,最后是全局绑定 ( describe-bindings)。请参阅其他帮助命令

Display all active key bindings; minor mode bindings first, then those of the major mode, then global bindings (describe-bindings). See Other Help Commands.

C-h C-q
C-h C-q

切换显示常用命令及其键绑定的窗口。请参阅其他帮助命令

Toggle display of a window showing popular commands and their key bindings. See Other Help Commands.

C-h c key
C-h c key

显示键序列键绑定到的命令的名称( describe-key-briefly)。这里c代表“性格”。有关密钥的更广泛信息,请使用 C-h k.请参阅Key 的文档

Show the name of the command that the key sequence key is bound to (describe-key-briefly). Here c stands for “character”. For more extensive information on key, use C-h k. See Documentation for a Key.

C-h d topics RET
C-h d topics RET

显示文档与主题( )匹配的命令和变量 apropos-documentation。参见Apropos

Display the commands and variables whose documentation matches topics (apropos-documentation). See Apropos.

C-h e
C-h e

显示*留言*缓冲 (view-echo-area-messages)。请参阅其他帮助命令

Display the *Messages* buffer (view-echo-area-messages). See Other Help Commands.

C-h f function RET
C-h f function RET

显示名为function ( )的 Lisp 函数的文档describe-function。由于命令是 Lisp 函数,因此这也适用于命令,但您也可以使用C-h x.请参阅命令或变量名称的帮助

Display documentation on the Lisp function named function (describe-function). Since commands are Lisp functions, this works for commands too, but you can also use C-h x. See Help by Command or Variable Name.

C-h h
C-h h

显示你好文件,其中显示了各种字符集的示例。

Display the HELLO file, which shows examples of various character sets.

C-h i
C-h i

运行 Info,GNU 文档浏览器 ( info)。 Emacs 手册可在 Info.plist 中找到。请参阅其他帮助命令

Run Info, the GNU documentation browser (info). The Emacs manual is available in Info. See Other Help Commands.

C-h k key
C-h k key

显示该键运行的命令的名称和文档( describe-key)。请参阅Key 的文档

Display the name and documentation of the command that key runs (describe-key). See Documentation for a Key.

C-h l
C-h l

显示最近 300 次击键的描述 ( view-lossage)。请参阅其他帮助命令

Display a description of your last 300 keystrokes (view-lossage). See Other Help Commands.

C-h m
C-h m

显示当前主要模式和次要模式的文档 ( describe-mode)。请参阅其他帮助命令

Display documentation of the current major mode and minor modes (describe-mode). See Other Help Commands.

C-h n
C-h n

显示最近 Emacs 更改的新闻 ( view-emacs-news)。请参阅帮助文件

Display news of recent Emacs changes (view-emacs-news). See Help Files.

C-h o symbol
C-h o symbol

显示名为symbol ( )的 Lisp 符号的文档describe-symbol。这将显示各种符号的文档:函数、变量和面。请参阅命令或变量名称的帮助

Display documentation of the Lisp symbol named symbol (describe-symbol). This will show the documentation of all kinds of symbols: functions, variables, and faces. See Help by Command or Variable Name.

C-h p
C-h p

按主题关键字 ( finder-by-keyword) 查找包。请参阅包的关键字搜索。这列出了使用包菜单缓冲区的包。请参阅Emacs Lisp 包

Find packages by topic keyword (finder-by-keyword). See Keyword Search for Packages. This lists packages using a package menu buffer. See Emacs Lisp Packages.

C-h P package RET
C-h P package RET

显示有关指定包 ( describe-package) 的文档。请参阅包的关键字搜索

Display documentation about the specified package (describe-package). See Keyword Search for Packages.

C-h r
C-h r

在 Info ( ) 中显示 Emacs 手册info-emacs-manual

Display the Emacs manual in Info (info-emacs-manual).

C-h s
C-h s

显示当前语法表的内容 ( describe-syntax)。请参阅其他帮助命令。语法表说明哪些字符是开始分隔符,哪些是单词的一部分,等等。有关详细信息,请参阅Emacs Lisp 参考手册中的语法表

Display the contents of the current syntax table (describe-syntax). See Other Help Commands. The syntax table says which characters are opening delimiters, which are parts of words, and so on. See Syntax Tables in The Emacs Lisp Reference Manual, for details.

C-h t
C-h t

进入 Emacs 交互式教程 ( help-with-tutorial)。

Enter the Emacs interactive tutorial (help-with-tutorial).

C-h v var RET
C-h v var RET

显示 Lisp 变量var ( )的文档describe-variable。请参阅命令或变量名称的帮助

Display the documentation of the Lisp variable var (describe-variable). See Help by Command or Variable Name.

C-h w command RET
C-h w command RET

显示哪些键运行名为command ( where-is) 的命令。请参阅Key 的文档

Show which keys run the command named command (where-is). See Documentation for a Key.

C-h x command RET
C-h x command RET

显示有关指定命令 ( describe-command) 的文档。请参阅命令或变量名称的帮助

Display documentation on the named command (describe-command). See Help by Command or Variable Name.

C-h C coding RET
C-h C coding RET

描述编码系统编码describe-coding-system)。请参阅编码系统

Describe the coding system coding (describe-coding-system). See Coding Systems.

C-h C RET
C-h C RET

描述当前使用的编码系统。

Describe the coding systems currently in use.

C-h F command RET
C-h F command RET

输入 Info 并转到记录 Emacs 命令的节点 ( ) Info-goto-emacs-command-node。请参阅命令或变量名称的帮助

Enter Info and go to the node that documents the Emacs command command (Info-goto-emacs-command-node). See Help by Command or Variable Name.

C-h I method RET
C-h I method RET

描述输入法方法describe-input-method)。请参阅选择输入法

Describe the input method method (describe-input-method). See Selecting an Input Method.

C-h K key
C-h K key

输入 Info 并转到记录键序列 ( Info-goto-emacs-key-command-node) 的节点。请参阅Key 的文档

Enter Info and go to the node that documents the key sequence key (Info-goto-emacs-key-command-node). See Documentation for a Key.

C-h L language-env RET
C-h L language-env RET

显示有关语言环境language-env ( describe-language-environment)中使用的字符集、编码系统和输入法的信息。请参阅语言环境

Display information on the character sets, coding systems, and input methods used in language environment language-env (describe-language-environment). See Language Environments.

C-h S symbol RET
C-h S symbol RET

根据您正在编辑的编程语言显示符号符号的信息文档( info-lookup-symbol)。请参阅其他帮助命令

Display the Info documentation on symbol symbol according to the programming language you are editing (info-lookup-symbol). See Other Help Commands.

C-h .
C-h .

display-local-help如果点位于一 ( )中,则显示特殊文本区域的帮助消息。 (例如,这些链接包括 *帮助*缓冲区。)请参阅有关活动文本和工具提示的帮助。如果您使用前缀参数 调用此命令,C-u C-h .并且点位于按钮或小部件上,则此命令将弹出一个描述该按钮/小部件的新缓冲区。

Display the help message for a special text area, if point is in one (display-local-help). (These include, for example, links in *Help* buffers.) See Help on Active Text and Tooltips. If you invoke this command with a prefix argument, C-u C-h ., and point is on a button or a widget, this command will pop a new buffer that describes that button/widget.


11.2 密钥的文档

11.2 Documentation for a Key

用于获取有关按键序列信息的帮助命令是 C-h c( describe-key-briefly) 和C-h k ( describe-key)。

The help commands to get information about a key sequence are C-h c (describe-key-briefly) and C-h k (describe-key).

C-h c key在回显区域中显示该键所绑定的命令的名称。例如,C-h c C-f 显示 '转发字符'。

C-h c key displays in the echo area the name of the command that key is bound to. For example, C-h c C-f displays ‘forward-char’.

C-h k key类似,但提供更多信息:它显示包含命令的文档字符串的帮助缓冲区,该字符串准确描述了命令的作用。

C-h k key is similar but gives more information: it displays a help buffer containing the command’s documentation string, which describes exactly what the command does.

C-h K key显示 Emacs 手册中描述与key对应的命令的部分。

C-h K key displays the section of the Emacs manual that describes the command corresponding to key.

C-h cC-h kC-h K适用于任何类型的按键序列,包括功能键、菜单和鼠标事件(C-h c忽略鼠标移动事件除外)。例如, C-h k您可以从菜单栏中选择一个菜单项后,查看其运行的命令的文档字符串。

C-h c, C-h k and C-h K work for any sort of key sequences, including function keys, menus, and mouse events (except that C-h c ignores mouse movement events). For instance, after C-h k you can select a menu item from the menu bar, to view the documentation string of the command it runs.

C-h w command RET列出绑定到command的键 。它在回显区域中显示列表。如果它说该命令不在任何键上,则意味着您必须使用 来M-x运行它。 C-h w运行命令where-is

C-h w command RET lists the keys that are bound to command. It displays the list in the echo area. If it says the command is not on any key, that means you must use M-x to run it. C-h w runs the command where-is.

Emacs 中的某些模式使用各种按钮(请参阅Emacs Lisp 参考手册中的按钮)和小部件(请参阅Emacs Widgets中的简介),单击它们可以执行某些操作。为了找出这些按钮最终调用的功能,Emacs 提供了和 命令,应将鼠标指针放在按钮上来运行这些命令。 button-describewidget-describe

Some modes in Emacs use various buttons (see Buttons in The Emacs Lisp Reference Manual) and widgets (see Introduction in Emacs Widgets) that can be clicked to perform some action. To find out what function is ultimately invoked by these buttons, Emacs provides the button-describe and widget-describe commands, that should be run with point over the button.


11.3 通过命令或变量名提供帮助

11.3 Help by Command or Variable Name

C-h x command RET( )在窗口中显示指定命令describe-command的文档。例如,

C-h x command RET (describe-command) displays the documentation of the named command, in a window. For example,

Ch x 自动填充模式RET
C-h x auto-fill-mode RET

显示 的文档auto-fill-mode。这是您获取未绑定到任何键(通常使用 运行的命令M-x)的命令文档的方式。

displays the documentation of auto-fill-mode. This is how you would get the documentation of a command that is not bound to any key (one which you would normally run using M-x).

C-h f function RET( ) 显示 Lisp函数describe-function的文档。此命令适用于您在 Lisp 程序中使用的 Lisp 函数。例如,如果您刚刚编写了表达式 并想要检查您是否 正确使用,请键入。另外,由于所有命令都是 Lisp 函数,因此您还可以使用此命令查看任何命令的文档。 (make-vector len)make-vectorC-h f make-vector RET

C-h f function RET (describe-function) displays the documentation of Lisp function. This command is intended for Lisp functions that you use in a Lisp program. For example, if you have just written the expression (make-vector len) and want to check that you are using make-vector properly, type C-h f make-vector RET. Additionally, since all commands are Lisp functions, you can also use this command to view the documentation of any command.

如果您输入,它会描述 point 周围缓冲区中最里面的 Lisp 表达式所调用的函数, 前提是该函数名称是有效的、已定义的 Lisp 函数。 (当您输入参数时,该名称将显示为默认名称。)例如,如果点位于文本 'C-h f RET(制作向量(汽车 x)',最里面的包含点的列表是以 ' 开头的列表(使向量',如此描述该功能。 C-h f RETmake-vector

If you type C-h f RET, it describes the function called by the innermost Lisp expression in the buffer around point, provided that function name is a valid, defined Lisp function. (That name appears as the default while you enter the argument.) For example, if point is located following the text ‘(make-vector (car x)’, the innermost list containing point is the one that starts with ‘(make-vector’, so C-h f RET describes the function make-vector.

C-h f也可用于验证您是否正确拼写了函数名称。如果迷你缓冲区提示符默认C-h f 显示缓冲区中的函数名称,则意味着该名称被定义为 Lisp 函数。如果您确实不想查看文档, 请键入C-g取消该 命令。C-h f

C-h f is also useful just to verify that you spelled a function name correctly. If the minibuffer prompt for C-h f shows the function name from the buffer as the default, it means that name is defined as a Lisp function. Type C-g to cancel the C-h f command if you don’t really want to view the documentation.

如果您请求自动加载函数的帮助,而该函数的autoload 表单(请参阅《Emacs Lisp 参考手册》中的“自动加载”)不提供文档字符串,则*帮助*缓冲区不会有任何要显示的文档字符串。在这种情况下,如果 help-enable-symbol-autoload是 non- nil,Emacs 将尝试加载定义该函数的文件以查看那里是否有文档字符串。

If you request help for an autoloaded function whose autoload form (see Autoload in The Emacs Lisp Reference Manual) doesn’t provide a doc string, the *Help* buffer won’t have any doc string to display. In that case, if help-enable-symbol-autoload is non-nil, Emacs will try to load the file in which the function is defined to see whether there’s a doc string there.

您可以使用该命令获取与特定主题相关的功能的概述M-x shortdoc。这将提示您输入感兴趣的区域,例如string,并将您弹出到一个缓冲区,其中列出了许多与处理字符串相关的函数。

You can get an overview of functions relevant for a particular topic by using the M-x shortdoc command. This will prompt you for an area of interest, e.g., string, and pop you to a buffer where many of the functions relevant for handling strings are listed.

C-h v( describe-variable) 与 Lisp 类似C-h f,但描述的是 Lisp 变量而不是 Lisp 函数。它的默认值是点周围或之前的 Lisp 符号(如果这是已定义的 Lisp 变量的名称)。请参阅变量

C-h v (describe-variable) is like C-h f but describes Lisp variables instead of Lisp functions. Its default is the Lisp symbol around or before point, if that is the name of a defined Lisp variable. See Variables.

如果您安装了源文件,则描述 Emacs 变量和函数的帮助缓冲区通常具有指向相应源代码的超链接(请参阅超链接和 Web 导航功能)。

Help buffers that describe Emacs variables and functions normally have hyperlinks to the corresponding source code, if you have the source files installed (see Hyperlinking and Web Navigation Features).

要在手册中查找命令的文档,请使用C-h F ( Info-goto-emacs-command-node)。它了解各种手册,而不仅仅是 Emacs 手册,并找到合适的手册。

To find a command’s documentation in a manual, use C-h F (Info-goto-emacs-command-node). This knows about various manuals, not just the Emacs manual, and finds the right one.

C-h o( describe-symbol) 类似于C-h fand C-h v,但它描述任何符号,无论是函数、变量还是面。如果符号有多个定义,例如它同时具有函数定义和变量定义,则此命令将依次显示所有这些定义的文档。

C-h o (describe-symbol) is like C-h f and C-h v, but it describes any symbol, be it a function, a variable, or a face. If the symbol has more than one definition, like it has both definition as a function and as a variable, this command will show the documentation of all of them, one after the other.

如果completions-detailed用户选项为 non- nil,则某些命令在显示完成时会提供有关可能值的详细信息。例如,C-h o TAB然后将包含文档字符串的第一行,并且还会说明每个符号是函数还是变量(等等)。包含哪些详细信息取决于所使用的命令。

If the completions-detailed user option is non-nil, some commands provide details about the possible values when displaying completions. For instance, C-h o TAB will then include the first line of the doc string, and will also say whether each symbol is a function or a variable (and so on). Which details are included varies depending on the command used.


11.4 相应的

11.4 Apropos

apropos命令回答诸如“处理文件的命令是什么?”之类的问题。更准确地说,您将查询指定为apropos 模式,它可以是一个单词、单词列表或正则表达式。

The apropos commands answer questions like, “What are the commands for working with files?” More precisely, you specify your query as an apropos pattern, which is either a word, a list of words, or a regular expression.

以下每个 apropos 命令读取迷你缓冲区中的 apropos 模式,搜索与该模式匹配的项目,并在不同的窗口中显示结果。

Each of the following apropos commands reads an apropos pattern in the minibuffer, searches for items that match the pattern, and displays the results in a different window.

C-h a
C-h a

搜索命令 ( apropos-command)。使用前缀参数,也可以搜索非交互式函数。

Search for commands (apropos-command). With a prefix argument, search for noninteractive functions too.

M-x apropos
M-x apropos

搜索函数和变量。交互功能(命令)和非交互功能都可以通过此找到。

Search for functions and variables. Both interactive functions (commands) and noninteractive functions can be found by this.

M-x apropos-user-option
M-x apropos-user-option

搜索用户可自定义的变量。使用前缀参数,也可以搜索不可自定义的变量。

Search for user-customizable variables. With a prefix argument, search for non-customizable variables too.

M-x apropos-variable
M-x apropos-variable

搜索变量。使用前缀参数,仅搜索可自定义变量。

Search for variables. With a prefix argument, search for customizable variables only.

M-x apropos-local-variable
M-x apropos-local-variable

搜索缓冲区局部变量。

Search for buffer-local variables.

M-x apropos-value
M-x apropos-value

搜索其值与指定模式匹配的变量。使用前缀参数,还可以搜索定义与模式匹配的函数,以及属性与模式匹配的 Lisp 符号。

Search for variables whose values match the specified pattern. With a prefix argument, search also for functions with definitions matching the pattern, and Lisp symbols with properties matching the pattern.

M-x apropos-local-value
M-x apropos-local-value

搜索其值与指定模式匹配的缓冲区局部变量。

Search for buffer-local variables whose values match the specified pattern.

C-h d
C-h d

搜索文档字符串与指定模式 ( apropos-documentation) 匹配的函数和变量。

Search for functions and variables whose documentation strings match the specified pattern (apropos-documentation).

最简单的一种恰当模式是一个单词。任何包含该单词的内容都与该模式匹配。因此,要查找适用于文件的命令,请键入.这将显示包含 ' 的所有命令名称的列表C-h a file RET文件',包括 copy-filefind-file、 等。每个命令名称都带有简短的描述和当前可以用来调用它的键列表。在我们的示例中,它会说您可以 find-file通过键入来调用C-x C-f

The simplest kind of apropos pattern is one word. Anything containing that word matches the pattern. Thus, to find commands that work on files, type C-h a file RET. This displays a list of all command names that contain ‘file’, including copy-file, find-file, and so on. Each command name comes with a brief description and a list of keys you can currently invoke it with. In our example, it would say that you can invoke find-file by typing C-x C-f.

help-window-select默认情况下,不会选择显示 apropos 缓冲区以及查询结果的窗口,但您可以通过将变量自定义为任何非值来选择它nil

By default, the window showing the apropos buffer with the results of the query is not selected, but you can cause it to be selected by customizing the variable help-window-select to any non-nil value.

mouse-1有关 apropos 缓冲区中列出的函数定义、变量或符号属性的更多信息,您可以使用或单击它 mouse-2,或者移动到那里并键入RET

For more information about a function definition, variable or symbol property listed in an apropos buffer, you can click on it with mouse-1 or mouse-2, or move there and type RET.

当您在 apropos 模式中指定多个单词时,名称必须至少包含其中两个单词才能匹配。因此,如果您正在寻找命令来删除 point 之前的一大块文本,您可以尝试.真实的命令名称将与之匹配;如果有一个 command ,它也会匹配,因为它包含两个指定的单词。 C-h a kill back backward behind before RETkill-backwardkill-text-before

When you specify more than one word in the apropos pattern, a name must contain at least two of the words in order to match. Thus, if you are looking for commands to kill a chunk of text before point, you could try C-h a kill back backward behind before RET. The real command name kill-backward will match that; if there were a command kill-text-before, it would also match, since it contains two of the specified words.

为了获得更大的灵活性,您可以指定正则表达式(请参阅正则表达式的语法)。如果 apropos 模式包含任何正则表达式特殊字符 ',则它会被解释为正则表达式^$*+?.\['。

For even greater flexibility, you can specify a regular expression (see Syntax of Regular Expressions). An apropos pattern is interpreted as a regular expression if it contains any of the regular expression special characters, ‘^$*+?.\[’.

遵循命名 Emacs 命令的约定,以下是一些在 apropos 模式中有用的单词。通过在 中使用它们 C-h a,您还将了解命名约定。

Following the conventions for naming Emacs commands, here are some words that you’ll find useful in apropos patterns. By using them in C-h a, you will also get a feel for the naming conventions.

字符、行、单词、句子、段落、区域、页面、sexp、列表、defun、矩形、缓冲区、框架、窗口、面、文件、目录、寄存器、模式、开始、结束、向前、向后、下一个、上一个、向上、向下、搜索、转到、删除、删除、标记、插入、复制、填充、缩进、大小写、更改、设置、内容、列表、查找、查看、描述、默认。

char, line, word, sentence, paragraph, region, page, sexp, list, defun, rect, buffer, frame, window, face, file, dir, register, mode, beginning, end, forward, backward, next, previous, up, down, search, goto, kill, delete, mark, insert, yank, fill, indent, case, change, set, what, list, find, view, describe, default.

如果变量apropos-do-all不是 - nil,则大多数 apropos 命令的行为就好像它们已被赋予前缀参数一样。有一个例外:apropos-variable没有前缀参数将始终搜索所有变量,无论 的值是什么apropos-do-all

If the variable apropos-do-all is non-nil, most apropos commands behave as if they had been given a prefix argument. There is one exception: apropos-variable without a prefix argument will always search for all variables, no matter what the value of apropos-do-all is.

默认情况下,所有 apropos 命令除了apropos-documentation 按字母顺序列出其结果外。如果变量 apropos-sort-by-scores不是 - nil,这些命令会尝试猜测每个结果的相关性,并首先显示最相关的结果。该apropos-documentation命令默认按相关性顺序列出其结果;要按字母顺序列出它们,请将变量更改 apropos-documentation-sort-by-scoresnil

By default, all apropos commands except apropos-documentation list their results in alphabetical order. If the variable apropos-sort-by-scores is non-nil, these commands instead try to guess the relevance of each result, and display the most relevant ones first. The apropos-documentation command lists its results in order of relevance by default; to list them in alphabetical order, change the variable apropos-documentation-sort-by-scores to nil.


11.5 帮助模式命令

11.5 Help Mode Commands

帮助缓冲区将帮助模式作为其主要模式。帮助模式提供与查看模式相同的命令(请参阅查看模式);例如, SPC向前滚动,和DEL/或向后滚动。它还提供了一些特殊的命令: S-SPC

Help buffers have Help mode as their major mode. Help mode provides the same commands as View mode (see View Mode); for instance, SPC scrolls forward, and DEL or S-SPC scrolls backward. It also provides a few special commands:

RET
RET

遵循点 ( ) 处的交叉引用help-follow

Follow a cross reference at point (help-follow).

TAB
TAB

将点向前移动到下一个超链接 ( forward-button)。

Move point forward to the next hyperlink (forward-button).

S-TAB
S-TAB

将点移回到上一个超链接 ( backward-button)。

Move point back to the previous hyperlink (backward-button).

mouse-1
mouse-1
mouse-2
mouse-2

按照您单击的超链接进行操作。

Follow a hyperlink that you click on.

n
n
p
p

在帮助缓冲区中的页面之间前后移动。

Move forward and back between pages in the Help buffer.

C-c C-c
C-c C-c

显示有关 ( ) 点符号的所有文档help-follow-symbol

Show all documentation about the symbol at point (help-follow-symbol).

C-c C-f
C-c C-f
r
r

在帮助命令的历史记录中前进 ( help-go-forward)。

Go forward in history of help commands (help-go-forward).

C-c C-b
C-c C-b
l
l

返回帮助命令的历史记录 ( help-go-back)。

Go back in history of help commands (help-go-back).

s
s

查看当前帮助主题的来源(如果有)( help-view-source)。

View the source of the current help topic (if any) (help-view-source).

i
i

在手册中查找当前主题 ( help-goto-info)。

Look up the current topic in the manual(s) (help-goto-info).

I
I

在 Emacs Lisp 手册中查找当前主题 ( help-goto-lispref-info)。

Look up the current topic in the Emacs Lisp manual (help-goto-lispref-info).

c
c

自定义变量或面 ( help-customize)。

Customize the variable or the face (help-customize).

当函数名称、变量名称或界面名称(请参阅文本界面)出现在帮助缓冲区的文档中时,它通常是带下划线的超链接。要查看相关文档,请将点移至此处并键入RET( help-follow),或单击带有mouse-1或 的超链接mouse-2。这样做会替换帮助缓冲区的内容;要回溯您的步骤,请键入C-c C-bl( help-go-back)。返回步骤时,可以使用C-c C-fr ( help-go-forward) 前进。

When a function name, variable name, or face name (see Text Faces) appears in the documentation in the help buffer, it is normally an underlined hyperlink. To view the associated documentation, move point there and type RET (help-follow), or click on the hyperlink with mouse-1 or mouse-2. Doing so replaces the contents of the help buffer; to retrace your steps, type C-c C-b or l (help-go-back). While retracing your steps, you can go forward by using C-c C-f or r (help-go-forward).

要在帮助缓冲区中的超链接之间移动,请使用TAB ( forward-button) 向前移动到下一个超链接, 使用( ) 向后移动到上一个超链接。这些命令循环执行;例如,在最后一个超链接处键入将返回到第一个超链接。 S-TABbackward-buttonTAB

To move between hyperlinks in a help buffer, use TAB (forward-button) to move forward to the next hyperlink and S-TAB (backward-button) to move back to the previous hyperlink. These commands act cyclically; for instance, typing TAB at the last hyperlink moves back to the first hyperlink.

默认情况下,帮助缓冲区中的许多链接都显示在引号字符中。如果help-clean-buttons用户选项为 non- nil,则这些引号字符将从缓冲区中删除。

By default, many links in the help buffer are displayed surrounded by quote characters. If the help-clean-buttons user option is non-nil, these quote characters are removed from the buffer.

C-h b由某些帮助命令(例如,显示一长串键绑定)生成的帮助缓冲区按“^L' 特点。在此类缓冲区中,n ( help-goto-next-page) 命令将带您到下一个页面开头,而p( help-goto-previous-page) 命令将带您到上一个页面开头。这样您就可以在帮助缓冲区中的不同类型文档之间快速导航。

Help buffers produced by some Help commands (like C-h b, which shows a long list of key bindings) are divided into pages by the ‘^L’ character. In such buffers, the n (help-goto-next-page) command will take you to the next start of page, and the p (help-goto-previous-page) command will take you to the previous start of page. This way you can quickly navigate between the different kinds of documentation in a help buffer.

帮助缓冲区还可以包含信息手册、源代码定义和 URL(网页)的超链接。前两个在 Emacs 中打开,第三个通过命令使用 Web 浏览器打开browse-url (请参阅以下 URL)。

A help buffer can also contain hyperlinks to Info manuals, source code definitions, and URLs (web pages). The first two are opened in Emacs, and the third using a web browser via the browse-url command (see Following URLs).

要查看有关文本中任何符号的所有文档,请将点移至该符号并键入C-c C-c( help-follow-symbol)。这显示了该符号的所有含义的文档 - 作为变量、函数和/或面。

To view all documentation about any symbol in the text, move point to the symbol and type C-c C-c (help-follow-symbol). This shows the documentation for all the meanings of the symbol—as a variable, as a function, and/or as a face.


11.6 包的关键字搜索

11.6 Keyword Search for Packages

Emacs 中的大多数可选功能都分组到中。 Emacs 包含数百个内置软件包,并且可以通过网络安装更多软件包(请参阅Emacs Lisp 软件包)。

Most optional features in Emacs are grouped into packages. Emacs contains several hundred built-in packages, and more can be installed over the network (see Emacs Lisp Packages).

为了更轻松地查找与某一主题相关的包,大多数包都根据其用途与一个或多个关键字相关联。键入C-h p( finder-by-keyword) 以显示包关键字列表以及关键字含义的说明。要查看给定关键字的软件包列表,请RET 在该行键入;这将显示包菜单缓冲区中的包列表(请参阅包菜单缓冲区)。

To make it easier to find packages related to a topic, most packages are associated with one or more keywords based on what they do. Type C-h p (finder-by-keyword) to bring up a list of package keywords, together with a description of what the keywords mean. To view a list of packages for a given keyword, type RET on that line; this displays the list of packages in a Package Menu buffer (see The Package Menu Buffer).

C-h P( describe-package) 提示输入包的名称(请参阅Emacs Lisp Packages),并显示描述包的属性及其实现的功能的帮助缓冲区。缓冲区以按钮的形式列出与包相关的关键字。单击带有mouse-1或 的按钮mouse-2可查看与该关键字相关的其他软件包的列表。

C-h P (describe-package) prompts for the name of a package (see Emacs Lisp Packages), and displays a help buffer describing the attributes of the package and the features that it implements. The buffer lists the keywords that relate to the package in the form of buttons. Click on a button with mouse-1 or mouse-2 to see the list of other packages related to that keyword.


11.7 国际语言支持帮助

11.7 Help for International Language Support

有关特定语言环境的信息(请参阅语言环境),请键入C-h L ( describe-language-environment)。这将显示一个帮助缓冲区,描述该语言环境支持的语言,并列出关联的字符集、编码系统和输入方法,以及该语言环境的一些示例文本。

For information on a specific language environment (see Language Environments), type C-h L (describe-language-environment). This displays a help buffer describing the languages supported by the language environment, and listing the associated character sets, coding systems, and input methods, as well as some sample text for that language environment.

命令C-h h( view-hello-file) 显示文件 等/你好,它通过展示如何用多种语言说“你好”来演示各种字符集。

The command C-h h (view-hello-file) displays the file etc/HELLO, which demonstrates various character sets by showing how to say “hello” in many languages.

命令C-h I( describe-input-method) 描述了一种输入法——可以是指定的输入法,也可以是默认当前使用的输入法。请参阅输入法

The command C-h I (describe-input-method) describes an input method—either a specified input method, or by default the input method currently in use. See Input Methods.

命令C-h C( describe-coding-system) 描述编码系统 — 指定的编码系统或当前使用的编码系统。请参阅编码系统

The command C-h C (describe-coding-system) describes coding systems—either a specified coding system, or the ones currently in use. See Coding Systems.


11.8 其他帮助命令

11.8 Other Help Commands

C-h i( info) 运行 Info 程序,该程序浏览结构化文档文件。 C-h 4 i ( info-other-window) 执行相同操作,但在另一个窗口中显示信息缓冲区。整个 Emacs 手册以及 GNU 系统的许多其他手册都可以在 Info 中找到。输入 Info 后键入h以运行有关使用 Info 的教程。

C-h i (info) runs the Info program, which browses structured documentation files. C-h 4 i (info-other-window) does the same, but shows the Info buffer in another window. The entire Emacs manual is available within Info, along with many other manuals for the GNU system. Type h after entering Info to run a tutorial on using Info.

使用数字参数nC-h i选择信息缓冲区 '*信息* <n>'。如果您想同时浏览多个信息手册,这非常有用。如果您仅指定C-u作为前缀参数,C-h i则会提示输入文档文件的名称,以便您可以浏览顶级“信息”菜单中没有条目的文件。

With a numeric argument n, C-h i selects the Info buffer ‘*info*<n>’. This is useful if you want to browse multiple Info manuals simultaneously. If you specify just C-u as the prefix argument, C-h i prompts for the name of a documentation file, so you can browse a file which doesn’t have an entry in the top-level Info menu.

如上所述,帮助命令和,输入 Info 并直接转到功能的文档。 C-h F function RETC-h K key

The help commands C-h F function RET and C-h K key, described above, enter Info and go straight to the documentation of function or key.

编辑程序时,如果您有该编程语言手册的信息版本,则可以使用C-h S ( info-lookup-symbol) 在适当的手册中查找符号(关键字、函数或变量)的条目。该命令如何工作的详细信息取决于主要模式。

When editing a program, if you have an Info version of the manual for the programming language, you can use C-h S (info-lookup-symbol) to find an entry for a symbol (keyword, function or variable) in the proper manual. The details of how this command works depend on the major mode.

如果发生令人惊讶的事情,并且您不确定输入的内容,请使用C-h l( view-lossage)。 C-h l显示您上次输入的击键及其调用的命令。默认情况下,Emacs 会存储最近 300 次击键;如果您愿意,可以使用命令更改此数字lossage-size。如果您看到不熟悉的命令,可以使用C-h kC-h f来了解它们的作用。

If something surprising happens, and you are not sure what you typed, use C-h l (view-lossage). C-h l displays your last input keystrokes and the commands they invoked. By default, Emacs stores the last 300 keystrokes; if you wish, you can change this number with the command lossage-size. If you see commands that you are not familiar with, you can use C-h k or C-h f to find out what they do.

要查看最近的回波区域消息,请使用C-h e ( view-echo-area-messages)。这显示了缓冲区 *留言*,这些消息的保存位置。

To review recent echo area messages, use C-h e (view-echo-area-messages). This displays the buffer *Messages*, where those messages are kept.

每个 Emacs 主要模式通常都会重新定义一些键,并对编辑的工作方式进行其他更改。 C-h m( describe-mode) 显示有关当前主要模式的文档,该文档通常描述在此模式下更改的命令和功能及其键绑定。

Each Emacs major mode typically redefines a few keys and makes other changes in how editing works. C-h m (describe-mode) displays documentation on the current major mode, which normally describes the commands and features that are changed in this mode, and also its key bindings.

C-h b( describe-bindings) 和C-h s ( describe-syntax) 显示有关 Emacs 中当前环境的其他信息。 C-h b显示现在有效的所有键绑定的列表:首先是当前次要模式的本地绑定,然后是当前主要模式定义的本地绑定,最后是全局绑定(请参阅自定义键绑定)。 C-h s 显示语法表的内容,以及每个字符语法的解释(请参阅《Emacs Lisp 参考手册》中的语法表)。

C-h b (describe-bindings) and C-h s (describe-syntax) show other information about the current environment within Emacs. C-h b displays a list of all the key bindings now in effect: first the local bindings of the current minor modes, then the local bindings defined by the current major mode, and finally the global bindings (see Customizing Key Bindings). C-h s displays the contents of the syntax table, with explanations of each character’s syntax (see Syntax Tables in The Emacs Lisp Reference Manual).

C-h C-q( help-quick-toggle) 打开和关闭缓冲区的显示,显示最流行的 Emacs 命令及其各自的键绑定(也称为“备忘单”)。该缓冲区的内容是由命令创建的help-quick。此缓冲区中显示的每个键绑定都是一个按钮:使用 mouse-1或单击它mouse-2可显示绑定到该键序列的命令的文档。

C-h C-q (help-quick-toggle) toggles on and off the display of a buffer showing the most popular Emacs commands and their respective key bindings (a.k.a. “cheat sheet”). The contents of that buffer are created by the command help-quick. Each key binding shown in this buffer is a button: click on it with mouse-1 or mouse-2 to show the documentation of the command bound to that key sequence.

您可以通过在前缀键后键入C-h?F1 ( )来获取特定前缀键的子命令列表。 describe-prefix-bindings(有一些前缀键,并非所有这些键都适用 - 那些为该键提供自己的绑定的键。这些前缀键之一是ESC,因为ESC C-hESC ?实际上分别是C-M-h( mark-defun) 和M-? ( xref-find-references) 。但是, ESC F1工作正常。 )

You can get a list of subcommands for a particular prefix key by typing C-h, ?, or F1 (describe-prefix-bindings) after the prefix key. (There are a few prefix keys for which not all of these keys work—those that provide their own bindings for that key. One of these prefix keys is ESC, because ESC C-h and ESC ? are actually C-M-h (mark-defun) and M-? (xref-find-references), respectively. However, ESC F1 works fine.)

最后,M-x describe-keymap提示输入键盘映射的名称并完成,并显示该键盘映射中所有键绑定的列表。

Finally, M-x describe-keymap prompts for the name of a keymap, with completion, and displays a listing of all key bindings in that keymap.


11.9 帮助文件

11.9 Help Files

除了内置文档和手册之外,Emacs 还包含其他几个文件,描述复制条件、发行说明、调试和报告错误的说明等主题。您可以使用以下命令来查看这些文件。除此之外 C-h g,它们都有形态。 C-h C-char

Apart from the built-in documentation and manuals, Emacs contains several other files describing topics like copying conditions, release notes, instructions for debugging and reporting bugs, and so forth. You can use the following commands to view these files. Apart from C-h g, they all have the form C-h C-char.

C-h C-c
C-h C-c

显示可以复制和重新分发 Emacs 的规则 ( describe-copying)。

Display the rules under which you can copy and redistribute Emacs (describe-copying).

C-h C-d
C-h C-d

显示调试 Emacs 的帮助 ( view-emacs-debugging)。

Display help for debugging Emacs (view-emacs-debugging).

C-h C-e
C-h C-e

显示有关从何处获取外部包的信息 ( view-external-packages)。

Display information about where to get external packages (view-external-packages).

C-h C-f
C-h C-f

显示 Emacs 常见问题解答列表 ( view-emacs-FAQ)。

Display the Emacs frequently-answered-questions list (view-emacs-FAQ).

C-h g
C-h g

访问包含 GNU 项目信息的页面describe-gnu-project( )。

Visit the page with information about the GNU Project (describe-gnu-project).

C-h C-m
C-h C-m

显示有关订购 Emacs 手册印刷版的信息 ( view-order-manuals)。

Display information about ordering printed copies of Emacs manuals (view-order-manuals).

C-h C-n
C-h C-n

显示新闻,其中列出了此版本 Emacs 中的新功能 ( view-emacs-news)。

Display the news, which lists the new features in this version of Emacs (view-emacs-news).

C-h C-o
C-h C-o

显示如何订购或下载最新版本的 Emacs 和其他 GNU 软件 ( describe-distribution)。

Display how to order or download the latest version of Emacs and other GNU software (describe-distribution).

C-h C-p
C-h C-p

显示已知 Emacs 问题的列表,有时还提供建议的解决方法 ( view-emacs-problems)。

Display the list of known Emacs problems, sometimes with suggested workarounds (view-emacs-problems).

C-h C-t
C-h C-t

显示 Emacs 待办事项列表 ( view-emacs-todo)。

Display the Emacs to-do list (view-emacs-todo).

C-h C-w
C-h C-w

显示有关 GNU Emacs 完全没有保修的完整详细信息 ( describe-no-warranty)。

Display the full details on the complete absence of warranty for GNU Emacs (describe-no-warranty).


11.10 有关活动文本和工具提示的帮助

11.10 Help on Active Text and Tooltips

在 Emacs 中,活动文本的延伸(响应鼠标单击或 执行某些特殊操作的文本RET)通常具有关联的帮助文本。这包括 Emacs 缓冲区中的超链接以及部分模式行。在图形显示器以及一些支持鼠标跟踪的文本终端上,将鼠标移动到活动文本上会将帮助文本显示为工具提示。请参阅工具提示

In Emacs, stretches of active text (text that does something special in response to mouse clicks or RET) often have associated help text. This includes hyperlinks in Emacs buffers, as well as parts of the mode line. On graphical displays, as well as some text terminals which support mouse tracking, moving the mouse over the active text displays the help text as a tooltip. See Tooltips.

在不支持鼠标跟踪的终端上,您可以通过键入C-h . ( display-local-help) 显示当前缓冲区文本的帮助文本。这会在回显区域显示帮助文本。要在可用时自动显示帮助文本,请将变量设置help-at-pt-display-when-idlet

On terminals that don’t support mouse-tracking, you can display the help text for active buffer text at point by typing C-h . (display-local-help). This shows the help text in the echo area. To display help text automatically whenever it is available at point, set the variable help-at-pt-display-when-idle to t.


12 马克和地区

12 The Mark and the Region

Emacs 与许多其他应用程序一样,允许您选择缓冲区文本的任意部分并调用对此类 选定文本进行操作的命令。在 Emacs 中,我们将选定的文本称为区域;它的处理与其他程序中选定文本的处理非常相似,但也有重要的区别。

Emacs, like many other applications, lets you select some arbitrary part of the buffer text and invoke commands that operate on such selected text. In Emacs, we call the selected text the region; its handling is very similar to that of selected text in other programs, but there are also important differences.

该区域是标记和当前之间的缓冲区部分。您可以通过在某处设置标记(例如使用命令C-SPC)来定义区域,然后将点移动到您希望区域结束的位置。 (或者您可以使用鼠标定义区域。)

The region is the portion of the buffer between the mark and the current point. You define a region by setting the mark somewhere (with, for instance, the C-SPC command), and then moving point to where you want the region to end. (Or you can use the mouse to define a region.)

该区域始终在点和标记之间延伸,无论它们中的哪一个出现在文本中的前面;每次移动点时,区域都会发生变化。

The region always extends between point and the mark, no matter which of them comes earlier in the text; each time you move point, the region changes.

将标记设置在文本中的某个位置即可将其激活。当标记处于活动状态时,我们也说该区域处于活动状态; Emacs 通过使用面部突出显示其中的文本来指示其范围 region(请参阅自定义面部)。

Setting the mark at a position in the text activates it. When the mark is active, we say also that the region is active; Emacs indicates its extent by highlighting the text within it, using the region face (see Customizing Faces).

在某些非运动命令(包括任何更改缓冲区中文本的命令)之后,Emacs 会自动停用 该标记;这将关闭突出显示。您还可以随时通过键入来显式停用该标记C-g (请参阅退出和中止)。

After certain non-motion commands, including any command that changes the text in the buffer, Emacs automatically deactivates the mark; this turns off the highlighting. You can also explicitly deactivate the mark at any time, by typing C-g (see Quitting and Aborting).

许多命令将其操作的文本限制在活动区域​​内。例如,该M-%命令(替换匹配的文本)通常适用于缓冲区的整个可访问部分,但如果您有一个活动区域,则它将仅适用于该区域。

Many commands limit the text on which they operate to the active region. For instance, the M-% command (which replaces matching text) normally works on the entire accessible portion of the buffer, but if you have an active region, it’ll work only on that region instead.

即使该标记未激活,它也是有用的。例如,您可以使用标记环移至先前的标记位置。请参阅“标记环”。此外,某些命令甚至会对非活动区域(例如upcase-region)产生影响。您还可以使用诸如 之类的命令重新激活该区域C-x C-x

The mark is useful even if it is not active. For example, you can move to previous mark locations using the mark ring. See The Mark Ring. Additionally, some commands will have an effect even on an inactive region (for example upcase-region). You can also reactivate the region with commands like C-x C-x.

上述行为是交互式会话中的默认行为,称为瞬态标记模式。禁用瞬态标记模式会将 Emacs 切换到另一种行为,其中该区域通常不会突出显示。请参阅禁用瞬态标记模式

The above behavior, which is the default in interactive sessions, is known as Transient Mark mode. Disabling Transient Mark mode switches Emacs to an alternative behavior, in which the region is usually not highlighted. See Disabling Transient Mark Mode.

在一个缓冲区中设置标记不会影响其他缓冲区中的标记。当您返回到带有活动标记的缓冲区时,该标记位于与之前相同的位置。当多个窗口显示相同的缓冲区时,它们可以具有不同的点值,从而具有不同的区域,但它们都共享一个公共标记位置。请参阅多个窗口。通常,只有选定的窗口会突出显示其区域;但是,如果变量highlight-nonselected-windows为非nil,则每个窗口都会突出显示自己的区域。

Setting the mark in one buffer has no effect on the marks in other buffers. When you return to a buffer with an active mark, the mark is at the same place as before. When multiple windows show the same buffer, they can have different values of point, and thus different regions, but they all share one common mark position. See Multiple Windows. Ordinarily, only the selected window highlights its region; however, if the variable highlight-nonselected-windows is non-nil, each window highlights its own region.

还有另一种区域:矩形区域。请参阅矩形

There is another kind of region: the rectangular region. See Rectangles.


12.1 设置标记

12.1 Setting the Mark

以下是一些设置标记的命令:

Here are some commands for setting the mark:

C-SPC
C-SPC

将标记设置在点处,然后激活它 ( set-mark-command)。

Set the mark at point, and activate it (set-mark-command).

C-@
C-@

相同。

The same.

C-x C-x
C-x C-x

将标记设置在该点,并激活它;然后将点移动到原来标记的位置 ( exchange-point-and-mark)。

Set the mark at point, and activate it; then move point where the mark used to be (exchange-point-and-mark).

Drag-mouse-1
Drag-mouse-1

在您拖动的文本周围设置点和标记。

Set point and the mark around the text you drag across.

mouse-3
mouse-3

在点处设置标记,然后将点移动到单击 ( mouse-save-then-kill) 的位置。

Set the mark at point, then move point to where you click (mouse-save-then-kill).

Shifted cursor motion keys
Shifted cursor motion keys

如果标记处于非活动状态,则将标记设置在点处,然后移动点。请参阅班次选择

Set the mark at point if the mark is inactive, then move point. See Shift Selection.

设置标记最常用的方法是使用 ( ) 5。这会在点所在的位置设置标记并激活它。然后您可以将点移开,留下标记。 C-SPCset-mark-command

The most common way to set the mark is with C-SPC (set-mark-command)5. This sets the mark where point is, and activates it. You can then move point away, leaving the mark behind.

例如,假设您希望将缓冲区的一部分转换为大写。要完成此操作,请转到所需文本的一端,键入 ,然后移动点,直到突出显示所需的文本部分。现在输入( )。这会将区域中的文本转换为大写,然后停用该标记。 C-SPCC-x C-uupcase-region

For example, suppose you wish to convert part of the buffer to upper case. To accomplish this, go to one end of the desired text, type C-SPC, and move point until the desired portion of text is highlighted. Now type C-x C-u (upcase-region). This converts the text in the region to upper case, and then deactivates the mark.

只要标记处于活动状态,您就可以通过键入来停用它 C-g(请参阅退出和中止)。大多数对该区域进行操作的命令也会自动停用该标记,如C-x C-u上面的示例所示。

Whenever the mark is active, you can deactivate it by typing C-g (see Quitting and Aborting). Most commands that operate on the region also automatically deactivate the mark, like C-x C-u in the above example.

您还可以使用它来记住缓冲区中的位置(通过键入),然后跳回那里(通过键入 ),而不是设置标记来对区域进行操作。 有关详细信息,请参阅标记环C-SPC C-SPCC-u C-SPC

Instead of setting the mark in order to operate on a region, you can also use it to remember a position in the buffer (by typing C-SPC C-SPC), and later jump back there (by typing C-u C-SPC). See The Mark Ring, for details.

C-x C-x( )命令exchange-point-and-mark交换点和标记的位置。 C-x C-x当您对点的位置感到满意但想要移动区域的另一端(标记所在的位置)时,此选项很有用。如有必要,可以使用C-x C-x第二次,将标记放置在新位置,同时将点放回到原来的位置。通常,如果标记处于非活动状态,此命令首先会在上次设置的位置重新激活标记,以确保该区域突出显示。但是,如果您使用前缀参数调用它,它会使标记处于非活动状态并且该区域不会突出显示;您可以使用它以类似于 的方式跳转到标记。 C-u C-SPC

The command C-x C-x (exchange-point-and-mark) exchanges the positions of point and the mark. C-x C-x is useful when you are satisfied with the position of point but want to move the other end of the region (where the mark is). Using C-x C-x a second time, if necessary, puts the mark at the new position with point back at its original position. Normally, if the mark is inactive, this command first reactivates the mark wherever it was last set, to ensure that the region is left highlighted. However, if you call it with a prefix argument, it leaves the mark inactive and the region unhighlighted; you can use this to jump to the mark in a manner similar to C-u C-SPC.

您也可以用鼠标设置标记。如果按下鼠标左键 ( down-mouse-1) 并在文本范围内拖动鼠标,则会在您首次按下鼠标按钮的位置设置标记,并在您释放鼠标按钮的位置放置点。或者,单击鼠标右键 ( mouse-3) 在点处设置标记,然后将点移动到单击的位置。有关这些鼠标命令的更详细说明, 请参阅用于编辑的鼠标命令。

You can also set the mark with the mouse. If you press the left mouse button (down-mouse-1) and drag the mouse across a range of text, this sets the mark where you first pressed the mouse button and puts point where you release it. Alternatively, clicking the right mouse button (mouse-3) sets the mark at point and then moves point to where you clicked. See Mouse Commands for Editing, for a more detailed description of these mouse commands.

最后,您可以通过按住 Shift 键并输入某些光标移动命令(如、 、等)来设置标记。这称为轮班选择。它在移动点之前的点设置标记,但前提是没有通过先前的 Shift 选择或鼠标命令设置活动标记。通过鼠标命令和通过移动选择设置的标记的行为与通常的标记略有不同:任何后续未移动的光标移动命令都会自动停用它。有关详细信息,请参阅移位选择S-RIGHTS-C-fS-C-n

Finally, you can set the mark by holding down the shift key while typing certain cursor motion commands (such as S-RIGHT, S-C-f, S-C-n, etc.). This is called shift-selection. It sets the mark at point before moving point, but only if there is no active mark set via a previous shift-selection or mouse commands. The mark set by mouse commands and by shift-selection behaves slightly differently from the usual mark: any subsequent unshifted cursor motion command deactivates it automatically. For details, see Shift Selection.

许多插入文本的命令(例如C-y( yank))会在插入文本的另一端设置标记,而不激活它。这可以让您轻松返回到该位置(请参阅标记环)。当命令显示 '标记集' 在回声区域。

Many commands that insert text, such as C-y (yank), set the mark at the other end of the inserted text, without activating it. This lets you easily return to that position (see The Mark Ring). You can tell that a command does this when it shows ‘Mark set’ in the echo area.

在 X 下,每次活动区域发生更改时,Emacs 都会将该区域中的文本保存到主选择中。这使您可以通过mouse-2单击将该文本插入到其他 X 应用程序中。请参阅使用其他窗口应用程序进行剪切和粘贴

Under X, every time the active region changes, Emacs saves the text in the region to the primary selection. This lets you insert that text into other X applications with mouse-2 clicks. See Cut and Paste with Other Window Applications.


12.2 标记文本对象的命令

12.2 Commands to Mark Textual Objects

以下是用于在文本对象(例如单词、列表、段落或页面)周围放置点和标记的命令:

Here are commands for placing point and the mark around a textual object such as a word, list, paragraph or page:

M-@
M-@

在下一个单词的末尾设置标记 ( mark-word)。这不移动点。

Set mark at the end of the next word (mark-word). This does not move point.

C-M-@
C-M-@

在以下平衡表达式结束后设置标记 ( mark-sexp)。这不移动点。

Set mark after end of following balanced expression (mark-sexp). This does not move point.

M-h
M-h

将光标移动到当前段落的开头,并在末尾设置标记 ( mark-paragraph)。

Move point to the beginning of the current paragraph, and set mark at the end (mark-paragraph).

C-M-h
C-M-h

将point移动到当前defun的开头,并在结尾处设置标记(mark-defun)。

Move point to the beginning of the current defun, and set mark at the end (mark-defun).

C-x C-p
C-x C-p

将光标移动到当前页的开头,并在末尾设置标记(mark-page)。

Move point to the beginning of the current page, and set mark at the end (mark-page).

C-x h
C-x h

将point移动到缓冲区的开头,并在末尾设置标记(mark-whole-buffer)。

Move point to the beginning of the buffer, and set mark at the end (mark-whole-buffer).

M-@( mark-word) 在下一个单词的末尾设置标记(有关单词的信息,请参阅单词)。重复调用此命令可通过每次将标记前进一个字来扩展区域。作为例外,如果标记处于活动状态并且位于 point 之前,M-@则一次将标记从当前位置向后移动一个字。

M-@ (mark-word) sets the mark at the end of the next word (see Words, for information about words). Repeated invocations of this command extend the region by advancing the mark one word at a time. As an exception, if the mark is active and located before point, M-@ moves the mark backwards from its current position one word at a time.

此命令还接受一个数字参数n,它告诉它将标记前进n 个单词。负参数 - n将标记向后移动n 个单词。

This command also accepts a numeric argument n, which tells it to advance the mark by n words. A negative argument −n moves the mark back by n words.

同样,C-M-@( mark-sexp) 将标记放在下一个平衡表达式的末尾(请参阅带平衡括号的表达式)。重复调用会将区域扩展到后续表达式,而正或负数字参数则将标记向前或向后移动指定数量的表达式。

Similarly, C-M-@ (mark-sexp) puts the mark at the end of the next balanced expression (see Expressions with Balanced Parentheses). Repeated invocations extend the region to subsequent expressions, while positive or negative numeric arguments move the mark forward or backward by the specified number of expressions.

上面列表中的其他命令都设置了点和标记,以便在缓冲区中定界对象。 M-h( mark-paragraph) 标记段落(请参阅段落),C-M-h( mark-defun) 标记顶级定义(请参阅通过 Defuns 移动),C-x C-p( mark-page) 标记页面(请参阅页面)。重复调用再次发挥相同的作用,将区域扩展到连续的对象;同样,数字参数指定要移动标记的对象数量。

The other commands in the above list set both point and mark, so as to delimit an object in the buffer. M-h (mark-paragraph) marks paragraphs (see Paragraphs), C-M-h (mark-defun) marks top-level definitions (see Moving by Defuns), and C-x C-p (mark-page) marks pages (see Pages). Repeated invocations again play the same role, extending the region to consecutive objects; similarly, numeric arguments specify how many objects to move the mark by.

C-x h( mark-whole-buffer) 将整个缓冲区设置为区域,将点放在开头,将标记放在结尾。

C-x h (mark-whole-buffer) sets up the entire buffer as the region, by putting point at the beginning and the mark at the end.


12.3 区域运营

12.3 Operating on the Region

一旦您拥有了一个区域,您可以通过以下一些方式对其进行操作:

Once you have a region, here are some of the ways you can operate on it:

当标记处于非活动状态时,某些命令具有默认行为,但如果标记处于活动状态,则对区域进行操作。例如,M-$ ( ispell-word) 通常会检查点处单词的拼写,但如果标记处于活动状态,则会检查该区域中的文本(请参阅检查和更正拼写)。通常,如果区域为空(即,如果标记和点位于同一位置),此类命令将使用其默认行为。如果您希望它们在空白区域上操作,请将变量更改use-empty-active-regiont

Some commands have a default behavior when the mark is inactive, but operate on the region if the mark is active. For example, M-$ (ispell-word) normally checks the spelling of the word at point, but it checks the text in the region if the mark is active (see Checking and Correcting Spelling). Normally, such commands use their default behavior if the region is empty (i.e., if mark and point are at the same position). If you want them to operate on the empty region, change the variable use-empty-active-region to t.

如擦除文本中所述,DEL ( backward-delete-char) 和Delete ( delete-forward-char) 命令也以这种方式起作用。如果标记处于活动状态,他们会删除该区域中的文本。 (作为例外,如果您提供数字参数n,其中n不为 1,则无论标记是否处于活动状态,这些命令都会删除n个字符)。如果将变量更改delete-active-regionnil,则当标记处于活动状态时,这些命令的行为不会有所不同。如果将值更改为kill,这些命令 将终止该区域而不是删除它(请参阅终止和移动文本)。

As described in Erasing Text, the DEL (backward-delete-char) and Delete (delete-forward-char) commands also act this way. If the mark is active, they delete the text in the region. (As an exception, if you supply a numeric argument n, where n is not one, these commands delete n characters regardless of whether the mark is active). If you change the variable delete-active-region to nil, then these commands don’t act differently when the mark is active. If you change the value to kill, these commands kill the region instead of deleting it (see Killing and Moving Text).

其他命令始终在该区域上运行,并且没有默认行为。此类命令的region名称中通常包含该单词,例如C-w( kill-region) 和C-x C-u ( upcase-region)。如果标记处于非活动状态,则它们对 非活动区域进行操作,即,对点和上次设置标记的位置之间的文本进行操作(请参阅标记环)。要禁用此行为,请将变量更改 mark-even-if-inactivenil。如果标记处于非活动状态,这些命令将发出错误信号。

Other commands always operate on the region, and have no default behavior. Such commands usually have the word region in their names, like C-w (kill-region) and C-x C-u (upcase-region). If the mark is inactive, they operate on the inactive region—that is, on the text between point and the position at which the mark was last set (see The Mark Ring). To disable this behavior, change the variable mark-even-if-inactive to nil. Then these commands will instead signal an error if the mark is inactive.

默认情况下,即使标记处于活动状态,文本插入也会正常发生,例如,键入a会插入字符 'A',然后停用该标记。删除选择模式是一种次要模式,它会修改此行为:如果启用该模式,则在标记处于活动状态时插入文本会导致首先删除该区域中的文本。但是,您可以通过自定义 delete-selection-temporary-region选项来调整此行为。它的默认值为 nil,但您可以将其设置为t,在这种情况下,只会替换临时活动的区域:通过拖动鼠标(请参阅设置标记)或通过移位选择(请参阅移位选择)来设置的区域,如以及C-u C-x C-x禁用瞬态标记模式时。您可以通过设置delete-selection-temporary-region为 来进一步调整行为selection:然后临时区域将C-u C-x C-x不会被替换,只有通过拖动鼠标或 Shift 选择激活的区域才会被替换。要打开或关闭“删除选择”模式,请键入M-x delete-selection-mode

By default, text insertion occurs normally even if the mark is active—for example, typing a inserts the character ‘a’, then deactivates the mark. Delete Selection mode, a minor mode, modifies this behavior: if you enable that mode, then inserting text while the mark is active causes the text in the region to be deleted first. However, you can tune this behavior by customizing the delete-selection-temporary-region option. Its default value is nil, but you can set it to t, in which case only temporarily-active regions will be replaced: those which are set by dragging the mouse (see Setting the Mark) or by shift-selection (see Shift Selection), as well as by C-u C-x C-x when Transient Mark Mode is disabled. You can further tune the behavior by setting delete-selection-temporary-region to selection: then temporary regions by C-u C-x C-x won’t be replaced, only the ones activated by dragging the mouse or shift-selection. To toggle Delete Selection mode on or off, type M-x delete-selection-mode.


12.4 标记环

12.4 The Mark Ring

每个缓冲区都会记住标记环中标记的先前位置 。设置标记的命令也会将旧标记推送到该环上。标记环的用途之一是记住您可能想返回的地点。

Each buffer remembers previous locations of the mark, in the mark ring. Commands that set the mark also push the old mark onto this ring. One of the uses of the mark ring is to remember spots that you may want to go back to.

C-SPC C-SPC
C-SPC C-SPC

设置标记,将其推到标记环上,但不激活它。

Set the mark, pushing it onto the mark ring, without activating it.

C-u C-SPC
C-u C-SPC

将点移动到标记所在的位置,并从先前标记的环中恢复标记。

Move point to where the mark was, and restore the mark from the ring of former marks.

当您想要使用标记来记住您可能希望返回的位置时,该命令非常方便。它将当前点推到标记环上,而不激活标记(这将导致 Emacs 突出显示该区域)。这实际上是连续两次调用 ( );第一个设置标记,第二个将其停用。 (当瞬态标记模式关闭时,会暂时激活瞬态标记模式;请参阅禁用瞬态标记模式。) C-SPC C-SPCC-SPCset-mark-commandC-SPCC-SPCC-SPC C-SPC

The command C-SPC C-SPC is handy when you want to use the mark to remember a position to which you may wish to return. It pushes the current point onto the mark ring, without activating the mark (which would cause Emacs to highlight the region). This is actually two consecutive invocations of C-SPC (set-mark-command); the first C-SPC sets the mark, and the second C-SPC deactivates it. (When Transient Mark mode is off, C-SPC C-SPC instead activates Transient Mark mode temporarily; see Disabling Transient Mark Mode.)

要返回到标记位置,请set-mark-command与前缀参数一起使用:。这会将点移动到标记所在的位置,如果标记处于活动状态,则将其停用。每个后续 跳转到存储在标记环中的先前位置。通过这种方式移动的位置不会丢失;他们走到了环的尽头。 C-u C-SPCC-u C-SPC

To return to a marked position, use set-mark-command with a prefix argument: C-u C-SPC. This moves point to where the mark was, and deactivates the mark if it was active. Each subsequent C-u C-SPC jumps to a prior position stored in the mark ring. The positions you move through in this way are not lost; they go to the end of the ring.

如果设置set-mark-command-repeat-pop为非nil,则在键入后,您可以立即键入 而不是在标记环中循环。默认情况下,是 . C-u C-SPCC-SPCC-u C-SPCset-mark-command-repeat-popnil

If you set set-mark-command-repeat-pop to non-nil, then immediately after you type C-u C-SPC, you can type C-SPC instead of C-u C-SPC to cycle through the mark ring. By default, set-mark-command-repeat-pop is nil.

每个缓冲区都有自己的标记环。所有编辑命令都使用当前缓冲区的标记环。特别是, 总是停留在同一个缓冲区中。 C-u C-SPC

Each buffer has its own mark ring. All editing commands use the current buffer’s mark ring. In particular, C-u C-SPC always stays in the same buffer.

该变量mark-ring-max指定标记环中保留的最大条目数。默认为 16 个条目。如果存在这么多条目并且推送了另一条目,则列表中最早的条目将被丢弃。重复循环当前在环中的位置。 C-u C-SPC

The variable mark-ring-max specifies the maximum number of entries to keep in the mark ring. This defaults to 16 entries. If that many entries exist and another one is pushed, the earliest one in the list is discarded. Repeating C-u C-SPC cycles through the positions currently in the ring.

如果你想一次又一次地回到同一个地方,标记环可能不够方便。如果是这样,您可以在寄存器中记录该位置以供以后检索(请参阅在寄存器中保存位置)。

If you want to move back to the same place over and over, the mark ring may not be convenient enough. If so, you can record the position in a register for later retrieval (see Saving Positions in Registers).


12.5 全局标记环

12.5 The Global Mark Ring

除了属于每个缓冲区的普通标记环之外,Emacs 还有一个全局标记环。每次设置标记时,如果自上次标记设置后已切换缓冲区,则除了当前缓冲区自己的标记环之外,还会将其记录在全局标记环中。因此,全局标记环记录了您曾经所在的一系列缓冲区,以及对于每个缓冲区,您设置标记的位置。全局标记环的长度由 控制 global-mark-ring-max,默认为16。

In addition to the ordinary mark ring that belongs to each buffer, Emacs has a single global mark ring. Each time you set a mark, this is recorded in the global mark ring in addition to the current buffer’s own mark ring, if you have switched buffers since the previous mark setting. Hence, the global mark ring records a sequence of buffers that you have been in, and, for each buffer, a place where you set the mark. The length of the global mark ring is controlled by global-mark-ring-max, and is 16 by default.

命令( )跳转到全局环中最新条目的缓冲区和位置。它还会旋转环,以便连续使用将您带到较早的缓冲区并标记位置。 C-x C-SPCpop-global-markC-x C-SPC

The command C-x C-SPC (pop-global-mark) jumps to the buffer and position of the latest entry in the global ring. It also rotates the ring, so that successive uses of C-x C-SPC take you to earlier buffers and mark positions.


12.6 班次选择

12.6 Shift Selection

如果在键入光标移动命令时按住 Shift 键,则会在移动点之前设置标记,以便该区域从点的原始位置延伸到新位置。此功能称为轮班选择。它类似于在其他编辑器中选择文本的方式。

If you hold down the shift key while typing a cursor motion command, this sets the mark before moving point, so that the region extends from the original position of point to its new position. This feature is referred to as shift-selection. It is similar to the way text is selected in other editors.

通过移位选择设置的标记的行为与我们上面描述的略有不同。首先,除了停用标记的常用方法(例如更改缓冲区文本或键入 )之外,任何未移​​动的光标运动命令C-g都会停用标记。其次,任何后续的移动光标运动命令都避免重新设置标记。因此,一系列移动的光标运动命令将连续调整该区域。

The mark set via shift-selection behaves a little differently from what we have described above. Firstly, in addition to the usual ways of deactivating the mark (such as changing the buffer text or typing C-g), the mark is deactivated by any unshifted cursor motion command. Secondly, any subsequent shifted cursor motion command avoids setting the mark anew. Therefore, a series of shifted cursor motion commands will continuously adjust the region.

仅当移动的光标运动键尚未绑定到单独的命令时,Shift-selection 才起作用(请参阅自定义)。例如,如果您绑定S-C-f到另一个命令,则键入 会运行该命令,而不是执行( )S-C-f的按 Shift 选择的版本。 C-fforward-char

Shift-selection only works if the shifted cursor motion key is not already bound to a separate command (see Customization). For example, if you bind S-C-f to another command, typing S-C-f runs that command instead of performing a shift-selected version of C-f (forward-char).

通过鼠标命令设置的标记与通过 Shift 选择设置的标记的行为相同(请参阅设置标记)。例如,如果通过拖动鼠标指定区域,则可以使用移动光标运动命令继续扩展该区域。在任何一种情况下,任何未移​​动的光标移动命令都会停用该标记。

A mark set via mouse commands behaves the same as a mark set via shift-selection (see Setting the Mark). For example, if you specify a region by dragging the mouse, you can continue to extend the region using shifted cursor motion commands. In either case, any unshifted cursor motion command deactivates the mark.

要关闭班次选择,请设置shift-select-modenil。这样做不会禁用通过鼠标命令设置标记。如果设置shift-select-mode为值 permanent,则未进行 Shift 转换的光标运动键将不会停用标记,因此,例如,可以通过 Shift-选择来扩展先前命令设置的区域,并且未进行 Shift 转换的光标运动键将扩展该区域通过班次选择设置。

To turn off shift-selection, set shift-select-mode to nil. Doing so does not disable setting the mark via mouse commands. If you set shift-select-mode to the value permanent, cursor motion keys that were not shift-translated will not deactivate the mark, so, for example, the region set by prior commands can be extended by shift-selection, and unshifted cursor motion keys will extend the region set by shift-selection.


12.7 禁用瞬态标记模式

12.7 Disabling Transient Mark Mode

标记和区域的默认行为(其中设置标记会激活它并突出显示区域)称为瞬态标记模式。这是交互式会话中默认启用的次要模式。可以使用M-x transient-mark-mode或 ' 进行切换突出显示活动区域' 中的菜单项选项' 菜单。关闭它会将 Emacs 切换到另一种操作模式:

The default behavior of the mark and region, in which setting the mark activates it and highlights the region, is called Transient Mark mode. This is a minor mode that is enabled by default in interactive sessions. It can be toggled with M-x transient-mark-mode, or with the ‘Highlight Active Region’ menu item in the ‘Options’ menu. Turning it off switches Emacs to an alternative mode of operation:

  • 使用或等命令设置标记不会突出显示该区域。因此,您无法通过查看标记的位置来判断;你必须记住。 C-SPCC-x C-x

    解决此问题的通常方法是设置标记,然后尽快使用它,以免您忘记它在哪里。您还可以使用 来检查标记的位置C-x C-x,这会交换点和标记的位置(请参阅设置标记)。

  • Setting the mark, with commands like C-SPC or C-x C-x, does not highlight the region. Therefore, you can’t tell by looking where the mark is located; you have to remember.

    The usual solution to this problem is to set the mark and then use it soon, before you forget where it is. You can also check where the mark is by using C-x C-x, which exchanges the positions of the point and the mark (see Setting the Mark).

  • 某些命令通常在标记处于活动状态时作用于该区域,但现在不再这样做。例如,如果标记处于活动状态,则通常M-% ( query-replace) 在区域内执行替换。当瞬态标记模式关闭时,它始终从缓冲区的点到末尾运行。以这种方式运行的命令在其自己的文档中进行了标识。
  • Some commands, which ordinarily act on the region when the mark is active, no longer do so. For example, normally M-% (query-replace) performs replacements within the region, if the mark is active. When Transient Mark mode is off, it always operates from point to the end of the buffer. Commands that act this way are identified in their own documentation.

当瞬态标记模式关闭时,您可以使用或临时激活它。 C-SPC C-SPCC-u C-x C-x

While Transient Mark mode is off, you can activate it temporarily using C-SPC C-SPC or C-u C-x C-x.

C-SPC C-SPC
C-SPC C-SPC

在点处设置标记(如 plain )并仅启用一次瞬态标记模式,直到标记停用。 (这实际上并不是一个单独的命令;您使用了该 命令两次。) C-SPCC-SPC

Set the mark at point (like plain C-SPC) and enable Transient Mark mode just once, until the mark is deactivated. (This is not really a separate command; you are using the C-SPC command twice.)

C-u C-x C-x
C-u C-x C-x

交换点和标记,激活标记并暂时启用瞬态标记模式,直到标记下次停用。 (这是 带有前缀参数的 C-x C-x命令。)exchange-point-and-mark

Exchange point and mark, activate the mark and enable Transient Mark mode temporarily, until the mark is next deactivated. (This is the C-x C-x command, exchange-point-and-mark, with a prefix argument.)

这些命令设置或激活标记,并仅启用瞬态标记模式,直到标记停用为止。您可能想要使用它们的原因之一是,当瞬态标记模式关闭时,某些命令对整个缓冲区而不是区域进行操作。立即启用瞬态标记模式可以让您在该区域上使用这些命令。

These commands set or activate the mark, and enable Transient Mark mode only until the mark is deactivated. One reason you may want to use them is that some commands operate on the entire buffer instead of the region when Transient Mark mode is off. Enabling Transient Mark mode momentarily gives you a way to use these commands on the region.

当您使用鼠标指定区域(请参阅设置标记)或使用移位选择(请参阅移位选择)时,这同样会暂时激活瞬态标记模式并突出显示该区域。

When you specify a region with the mouse (see Setting the Mark), or with shift-selection (see Shift Selection), this likewise activates Transient Mark mode temporarily and highlights the region.


13 杀戮与移动文本

13 Killing and Moving Text

在 Emacs 中,kill意味着删除文本并将其复制到 Kill 环中。 Yanking意味着将文本从终止环带回缓冲区。 (某些应用程序使用术语“剪切”和“粘贴”来表示类似的操作。) Kill Ring 之所以如此命名,是因为它可以被可视化为一组排列在环中的文本块,您可以按循环顺序访问它们。参见《杀戮环》

In Emacs, killing means erasing text and copying it into the kill ring. Yanking means bringing text from the kill ring back into the buffer. (Some applications use the terms “cutting” and “pasting” for similar operations.) The kill ring is so-named because it can be visualized as a set of blocks of text arranged in a ring, which you can access in cyclic order. See The Kill Ring.

Killing 和 yanking 是在 Emacs 中移动或复制文本的最常见方法。它非常通用,因为有一些命令可以杀死许多不同类型的语法单元。

Killing and yanking are the most common way to move or copy text within Emacs. It is very versatile, because there are commands for killing many different types of syntactic units.


13.1 删除和删除

13.1 Deletion and Killing

大多数从缓冲区中删除文本的命令都会将其保存在 Kill Ring 中(请参阅Kill Ring)。这些被称为终止命令,它们的名称通常包含单词“”(例如, kill-line)。杀戮环存储最近的几次杀戮,而不仅仅是最后一次杀戮,因此杀戮是一项非常安全的操作:您不必太担心丢失之前杀戮的文本。终止环由所有缓冲区共享,因此可以将一个缓冲区中终止的文本拉入另一个缓冲区。

Most commands which erase text from the buffer save it in the kill ring (see The Kill Ring). These are known as kill commands, and their names normally contain the word ‘kill’ (e.g., kill-line). The kill ring stores several recent kills, not just the last one, so killing is a very safe operation: you don’t have to worry much about losing text that you previously killed. The kill ring is shared by all buffers, so text that is killed in one buffer can be yanked into another buffer.

当您使用C-/( undo) 撤消终止命令(请参阅撤消)时,会将终止的文本带回缓冲区,但不会将其从终止环中删除。

When you use C-/ (undo) to undo a kill command (see Undo), that brings the killed text back into the buffer, but does not remove it from the kill ring.

在图形显示上,删除文本还会将其复制到系统剪贴板。请参阅图形显示上的“剪切和粘贴”操作

On graphical displays, killing text also copies it to the system clipboard. See “Cut and Paste” Operations on Graphical Displays.

删除文本但不将其保存在 Kill Ring 中的命令称为删除命令;他们的名字通常包含“删除'。其中包括一次仅删除一个字符的C-d( delete-char) 和 DEL( ),以及仅删除空格或换行符的命令。delete-backward-char可以擦除大量重要数据的命令通常会执行终止操作。

Commands that erase text but do not save it in the kill ring are known as delete commands; their names usually contain the word ‘delete’. These include C-d (delete-char) and DEL (delete-backward-char), which delete only one character at a time, and those commands that delete only spaces or newlines. Commands that can erase significant amounts of nontrivial data generally do a kill operation instead.

您还可以使用鼠标进行杀死和猛拉。请参阅图形显示上的“剪切和粘贴”操作

You can also use the mouse to kill and yank. See “Cut and Paste” Operations on Graphical Displays.


13.1.1 删除

13.1.1 Deletion

删除意味着删除文本而不将其保存在 Kill Ring 中。在大多数情况下,删除文本的 Emacs 命令是那些仅删除一个字符或仅删除空格的命令。

Deletion means erasing text and not saving it in the kill ring. For the most part, the Emacs commands that delete text are those that erase just one character or only whitespace.

DEL
DEL
BACKSPACE
BACKSPACE

删除前一个字符,或者删除该区域中的文本(如果该区域处于活动状态)( delete-backward-char)。

Delete the previous character, or the text in the region if it is active (delete-backward-char).

Delete
Delete

删除下一个字符,或者该区域中的文本(如果它处于活动状态)( delete-forward-char)。

Delete the next character, or the text in the region if it is active (delete-forward-char).

C-d
C-d

删除下一个字符 ( delete-char)。

Delete the next character (delete-char).

M-\
M-\

删除点 ( ) 周围的空格和制表符delete-horizontal-space

Delete spaces and tabs around point (delete-horizontal-space).

M-SPC
M-SPC

删除点周围的空格和制表符,留下一个空格 ( just-one-space)。

Delete spaces and tabs around point, leaving one space (just-one-space).

C-x C-o
C-x C-o

删除当前行周围的空白行 ( delete-blank-lines)。

Delete blank lines around the current line (delete-blank-lines).

M-^
M-^

通过删除中间的换行符及其后面的任何缩进来连接两行 ( delete-indentation)。

Join two lines by deleting the intervening newline, along with any indentation following it (delete-indentation).

我们已经描述了基本的删除命令DELdelete-backward-char)、deletedelete-forward-char)和C-ddelete-char)。请参阅删除文本。使用数字参数,它们删除指定数量的字符。如果省略数字参数或为 1, DELdelete删除该区域中的所有文本(如果该区域处于活动状态)(请参阅在区域上操作)。

We have already described the basic deletion commands DEL (delete-backward-char), delete (delete-forward-char), and C-d (delete-char). See Erasing Text. With a numeric argument, they delete the specified number of characters. If the numeric argument is omitted or one, DEL and delete delete all the text in the region if it is active (see Operating on the Region).

其他删除命令仅删除空白字符:空格、制表符和换行符。 M-\ ( delete-horizontal-space) 删除点前后的所有空格和制表符。使用前缀参数,只会删除点之前的空格和制表符。

The other delete commands are those that delete only whitespace characters: spaces, tabs and newlines. M-\ (delete-horizontal-space) deletes all the spaces and tab characters before and after point. With a prefix argument, this only deletes spaces and tab characters before point.

just-one-space类似地执行,但在 point 之前留下一个空格,无论之前存在多少个空格(即使之前没有)。对于数字参数n ,如果n为正数,则在 point 之前留下n 个空格;如果n 为负数,除了空格和制表符之外,它还会删除换行符,在点之前留下 - n 个空格。

just-one-space does likewise but leaves a single space before point, regardless of the number of spaces that existed previously (even if there were none before). With a numeric argument n, it leaves n spaces before point if n is positive; if n is negative, it deletes newlines in addition to spaces and tabs, leaving −n spaces before point.

command cycle-spacing( ) 的作用类似于更灵活的.如果连续重复调用它, 它会以循环方式执行由 定义的不同空间清理操作。M-SPCjust-one-spacecycle-spacing-actions

The command cycle-spacing (M-SPC) acts like a more flexible version of just-one-space. It performs different space cleanup actions defined by cycle-spacing-actions, in a cyclic manner, if you call it repeatedly in succession.

C-x C-o( delete-blank-lines) 删除当前行之后的所有空白行。如果当前行为空,它也会删除当前行之前的所有空行(留下一个空行,即当前行)。在单独的空行上,它会删除该行。

C-x C-o (delete-blank-lines) deletes all blank lines after the current line. If the current line is blank, it deletes all blank lines preceding the current line as well (leaving one blank line, the current line). On a solitary blank line, it deletes that line.

M-^( delete-indentation) 通过删除换行符和所有周围的空格来连接当前行和上一行,通常留下一个空格。参见M-^

M-^ (delete-indentation) joins the current line and the previous line, by deleting a newline and all surrounding spaces, usually leaving a single space. See M-^.

该命令delete-duplicate-lines在该区域中搜索相同的行,并删除每行中的所有行,只留下一个副本。通常,它保留每个重复行的第一个实例,但使用C-u 前缀参数时,它保留最后一个实例。使用C-u C-u前缀参数,它仅搜索相邻的相同行。这是一种更有效的操作模式,当行已经排序时很有用。使用C-u C-u C-u前缀参数,它保留重复的空行。

The command delete-duplicate-lines searches the region for identical lines, and removes all but one copy of each. Normally it keeps the first instance of each repeated line, but with a C-u prefix argument it keeps the last. With a C-u C-u prefix argument, it only searches for adjacent identical lines. This is a more efficient mode of operation, useful when the lines have already been sorted. With a C-u C-u C-u prefix argument, it retains repeated blank lines.


13.1.2 行杀

13.1.2 Killing by Lines

C-k
C-k

杀死其余行或一行或多行 ( kill-line)。

Kill rest of line or one or more lines (kill-line).

C-S-backspace
C-S-backspace

一次杀死整行 ( kill-whole-line)

Kill an entire line at once (kill-whole-line)

最简单的终止命令是C-k( kill-line)。如果在行尾使用,它会杀死行结束换行符,将下一行合并到当前行中(因此,空白行被完全删除)。否则,C-k删除从点到行尾的所有文本;如果点最初位于行的开头,则该行会留空。

The simplest kill command is C-k (kill-line). If used at the end of a line, it kills the line-ending newline character, merging the next line into the current one (thus, a blank line is entirely removed). Otherwise, C-k kills all the text from point up to the end of the line; if point was originally at the beginning of the line, this leaves the line blank.

在决定应用哪种情况时,行尾的空格和制表符将被忽略。只要 point 位于行中最后一个非空白字符之后,您就可以确定C-k会杀死换行符。要删除整个非空行,请转到开头并键入C-k两次。

Spaces and tabs at the end of the line are ignored when deciding which case applies. As long as point is after the last non-whitespace character in the line, you can be sure that C-k will kill the newline. To kill an entire non-blank line, go to the beginning and type C-k twice.

在这种情况下,“行”表示逻辑文本行,而不是屏幕行(请参阅延续行)。

In this context, “line” means a logical text line, not a screen line (see Continuation Lines).

C-k给定正参数n时,它会杀死 n行及其后面的换行符(不会杀死 point 之前当前行上的文本)。使用负参数 - n,它会删除当前行之前的n行,以及当前行上的 point 之前的文本。 C-k 参数为零会杀死当前行上的点之前的文本。

When C-k is given a positive argument n, it kills n lines and the newlines that follow them (text on the current line before point is not killed). With a negative argument −n, it kills n lines preceding the current line, together with the text on the current line before point. C-k with an argument of zero kills the text before point on the current line.

如果变量kill-whole-line为 non- nilC-k则在行的最开始处杀死整行,包括后面的换行符。该变量通常为nil.

If the variable kill-whole-line is non-nil, C-k at the very beginning of a line kills the entire line including the following newline. This variable is normally nil.

C-S-backspace( kill-whole-line) 杀死整行,包括换行符,无论点在行内的位置如何。请注意,许多文本终端会阻止您键入按键序列C-S-backspace

C-S-backspace (kill-whole-line) kills a whole line including its newline, regardless of the position of point within the line. Note that many text terminals will prevent you from typing the key sequence C-S-backspace.


13.1.3 其他终止命令

13.1.3 Other Kill Commands

C-w
C-w

杀死区域 ( kill-region)。

Kill the region (kill-region).

M-w
M-w

将该区域复制到 Kill Ring ( kill-ring-save) 中。

Copy the region into the kill ring (kill-ring-save).

M-d
M-d

删除下一个单词(kill-word)。见

Kill the next word (kill-word). See Words.

M-DEL
M-DEL

倒着杀掉一个字(backward-kill-word)。

Kill one word backwards (backward-kill-word).

C-x DEL
C-x DEL

杀回到句首(backward-kill-sentence)。参见句子

Kill back to beginning of sentence (backward-kill-sentence). See Sentences.

M-k
M-k

杀到句末(kill-sentence)。

Kill to the end of the sentence (kill-sentence).

C-M-k
C-M-k

杀掉下面的平衡表达式( kill-sexp)。请参阅带平衡括号的表达式

Kill the following balanced expression (kill-sexp). See Expressions with Balanced Parentheses.

M-z char
M-z char

杀死下一个出现的char ( zap-to-char)。

Kill through the next occurrence of char (zap-to-char).

M-x zap-up-to-char char
M-x zap-up-to-char char

杀死直到但不包括下一次出现的char

Kill up to, but not including, the next occurrence of char.

常用的终止命令之一是C-w ( kill-region),它终止区域中的文本(请参阅标记和区域)。类似地,M-w( kill-ring-save) 将该区域中的文本复制到终止环中,而不将其从缓冲区中删除。如果在您键入C-w或时标记处于非活动状态M-w,则该命令将作用于点与您上次设置标记的位置之间的文本(请参阅在区域上操作)。

One of the commonly-used kill commands is C-w (kill-region), which kills the text in the region (see The Mark and the Region). Similarly, M-w (kill-ring-save) copies the text in the region into the kill ring without removing it from the buffer. If the mark is inactive when you type C-w or M-w, the command acts on the text between point and where you last set the mark (see Operating on the Region).

Emacs 还提供了杀死特定语法单元的命令:单词、with和(参见单词);平衡表达式,with (参见带平衡括号的表达式);和句子,带有and (参见句子)。 M-DELM-dC-M-kC-x DELM-k

Emacs also provides commands to kill specific syntactic units: words, with M-DEL and M-d (see Words); balanced expressions, with C-M-k (see Expressions with Balanced Parentheses); and sentences, with C-x DEL and M-k (see Sentences).

命令M-z( zap-to-char) 将查杀与搜索结合起来:它读取一个字符并从该点开始查杀(并包括)缓冲区中该字符的下一次出现。数字参数充当重复计数;否定参数意味着向后搜索并删除点之前的文本。以前使用过的字符的历史记录被保留,并且可以通过M-p/按键访问 M-n。如果必须通过复杂的输入法输入要使用的字符,这主要有用。 类似的命令zap-up-to-char会杀死从点到字符的下一个出现位置,但不包括下一个出现的字符,并使用数字参数作为重复计数。

The command M-z (zap-to-char) combines killing with searching: it reads a character and kills from point up to (and including) the next occurrence of that character in the buffer. A numeric argument acts as a repeat count; a negative argument means to search backward and kill text before point. A history of previously used characters is maintained and can be accessed via the M-p/M-n keystrokes. This is mainly useful if the character to be used has to be entered via a complicated input method. A similar command zap-up-to-char kills from point up to, but not including the next occurrence of a character, with numeric argument acting as a repeat count.


13.1.4 杀死选项

13.1.4 Options for Killing

一些专用缓冲区包含只读文本,无法修改,因此无法杀死。 Kill 命令专门在只读缓冲区中工作:它们移动文本并将其复制到 Kill Ring,而不实际从缓冲区中删除它。通常,发生这种情况时,它们还会发出蜂鸣声并显示错误消息。但是,如果您将变量设置kill-read-only-ok为非值nil,它们只会在回显区域打印一条消息来解释为什么文本没有被删除。

Some specialized buffers contain read-only text, which cannot be modified and therefore cannot be killed. The kill commands work specially in a read-only buffer: they move over text and copy it to the kill ring, without actually deleting it from the buffer. Normally, they also beep and display an error message when this happens. But if you set the variable kill-read-only-ok to a non-nil value, they just print a message in the echo area to explain why the text has not been erased.

在将 Kill 保存到 Kill Ring 之前,您可以使用 转换字符串kill-transform-function。它是用要杀死的字符串调用的,它应该返回您想要保存的字符串。它也可以返回nil,在这种情况下,字符串不会被保存到 Kill Ring 中。例如,如果您不想将纯空白字符串保存到终止环,您可以说:

Before saving the kill to the kill ring, you can transform the string using kill-transform-function. It’s called with the string to be killed, and it should return the string you want to be saved. It can also return nil, in which case the string won’t be saved to the kill ring. For instance, if you never want to save a pure white space string to the kill ring, you can say:

(setq 终止变换函数
      (拉姆达(字符串)
        (和(不是(字符串-空白-p字符串))
             细绳)))
(setq kill-transform-function
      (lambda (string)
        (and (not (string-blank-p string))
             string)))

如果将变量更改kill-do-not-save-duplicates为非值nil,则相同的后续终止会产生单个终止环条目,而不会重复。

If you change the variable kill-do-not-save-duplicates to a non-nil value, identical subsequent kills yield a single kill-ring entry, without duplication.


13.2 猛拉

13.2 Yanking

Yanking意味着重新插入之前被删除的文本。移动或复制文本的常用方法是删除它,然后将其拖到其他地方。

Yanking means reinserting text previously killed. The usual way to move or copy text is to kill it and then yank it elsewhere.

C-y
C-y

将最后一个杀戮拉入缓冲区中的 ( yank) 点。

Yank the last kill into the buffer, at point (yank).

M-y
M-y

将刚刚拉出的文本替换为较早一批被删除的文本 ( yank-pop),或者允许从先前被删除的文本批次列表中进行选择。请参阅“Yanking Early Kills”

Either replace the text just yanked with an earlier batch of killed text (yank-pop), or allow to select from the list of previously-killed batches of text. See Yanking Earlier Kills.

C-M-w
C-M-w

导致以下命令(如果它是一个kill命令)追加到前一个kill(append-next-kill)之后。请参阅追加击杀数

Cause the following command, if it is a kill command, to append to the previous kill (append-next-kill). See Appending Kills.

基本的拉动命令是C-y( yank)。它插入最近的kill,将光标留在插入文本的末尾。它还在插入文本的开头设置标记,但不激活该标记;如果您愿意,这可以让您轻松跳到该位置(请参阅“标记环”)。 C-u C-SPC

The basic yanking command is C-y (yank). It inserts the most recent kill, leaving the cursor at the end of the inserted text. It also sets the mark at the beginning of the inserted text, without activating the mark; this lets you jump easily to that position, if you wish, with C-u C-SPC (see The Mark Ring).

使用普通前缀参数 ( C-u C-y),该命令会将光标保留在插入文本的前面,并在末尾设置标记。使用任何其他前缀参数指定较早的终止;例如,C-u 4 C-y重新插入第四个最近的杀戮。请参阅“Yanking Early Kills”

With a plain prefix argument (C-u C-y), the command instead leaves the cursor in front of the inserted text, and sets the mark at the end. Using any other prefix argument specifies an earlier kill; e.g., C-u 4 C-y reinserts the fourth most recent kill. See Yanking Earlier Kills.

在图形显示器和支持文本模式的显示器上,C-y 首先检查是否有其他应用程序在最近一次 Emacs 终止之前将任何文本放入系统剪贴板中。如果是这样,它将插入剪贴板的文本。因此,Emacs 有效地处理了在其他应用程序中执行的“剪切”或“复制”剪贴板操作,例如 Emacs Kill,只不过它们不记录在 Kill Ring 中。有关详细信息,请参阅图形显示上的“剪切和粘贴”操作

On graphical displays and on capable text-mode displays, C-y first checks if another application has placed any text in the system clipboard more recently than the last Emacs kill. If so, it inserts the clipboard’s text instead. Thus, Emacs effectively treats “cut” or “copy” clipboard operations performed in other applications like Emacs kills, except that they are not recorded in the kill ring. See “Cut and Paste” Operations on Graphical Displays, for details.


13.2.1 杀戮环

13.2.1 The Kill Ring

杀戮是先前被杀掉的文本块的列表。只有一个终止环,由所有缓冲区共享,因此您可以终止一个缓冲区中的文本并将其拉入另一个缓冲区中。这是将文本从一个缓冲区移动到另一个缓冲区的常用方法。 (还有其他几种方法:例如,您可以将文本存储在寄存器中;请参阅寄存器。有关移动文本的其他一些方法, 请参阅累积文本。)

The kill ring is a list of blocks of text that were previously killed. There is only one kill ring, shared by all buffers, so you can kill text in one buffer and yank it in another buffer. This is the usual way to move text from one buffer to another. (There are several other methods: for instance, you could store the text in a register; see Registers. See Accumulating Text, for some other ways to move text around.)

Kill Ring 中的最大条目数由变量控制kill-ring-max。默认值为 120。如果在达到此限制时进行新的终止,Emacs 会通过删除终止环中最旧的条目来腾出空间。

The maximum number of entries in the kill ring is controlled by the variable kill-ring-max. The default is 120. If you make a new kill when this limit has been reached, Emacs makes room by deleting the oldest entry in the kill ring.

Kill Ring 的实际内容存储在名为 的变量中 kill-ring;您可以使用 查看杀戮环的全部内容C-h v kill-ring

The actual contents of the kill ring are stored in a variable named kill-ring; you can view the entire contents of the kill ring with C-h v kill-ring.


13.2.2 撤回较早的杀戮

13.2.2 Yanking Earlier Kills

正如Yanking中所解释的,您可以使用数字参数来 C-y提取不再是最近删除的文本。如果您记得想要哪个杀环条目,这会很有用。如果不这样做,您可以使用M-y( yank-pop) 命令循环查看可能性或选择较早的击杀之一。

As explained in Yanking, you can use a numeric argument to C-y to yank text that is no longer the most recent kill. This is useful if you remember which kill ring entry you want. If you don’t, you can use the M-y (yank-pop) command to cycle through the possibilities or to select one of the earlier kills.

如果前一个命令是 yank 命令,M-y则获取被 yank 的文本并将其替换为先前终止的文本。因此,要恢复倒数第二个杀戮的文本,请首先使用 C-y拉出最后一个杀戮,然后使用M-y将其替换为前一个杀戮。这仅在一个C-y 或另一个之后才有效M-y。 (如果M-y在其他命令之后调用,则其工作方式有所不同,请参见下文。)

If the previous command was a yank command, M-y takes the text that was yanked and replaces it with the text from an earlier kill. So, to recover the text of the next-to-the-last kill, first use C-y to yank the last kill, and then use M-y to replace it with the previous kill. This works only after a C-y or another M-y. (If M-y is invoked after some other command, it works differently, see below.)

M-y您可以通过指向kill环中的条目的last-yank指针来理解这种操作模式。每次你杀死时,最后一个拉动指针都会移动到环前面新创建的条目。 C-y猛拉最后猛拉指针指向的条目。 M-y在一个C-y或另一个M-y 将最后一个复制指针移动到上一个条目之后,缓冲区中的文本将更改以匹配。足够多的M-y命令一个接一个地可以将指针移动到环中的任何条目,因此您可以获得缓冲区中的任何条目。最终指针到达环的末端;下一个M-y再次循环回到第一个条目。

You can understand this operation mode of M-y in terms of a last-yank pointer which points at an entry in the kill ring. Each time you kill, the last-yank pointer moves to the newly made entry at the front of the ring. C-y yanks the entry which the last-yank pointer points to. M-y after a C-y or another M-y moves the last-yank pointer to the previous entry, and the text in the buffer changes to match. Enough M-y commands one after another can move the pointer to any entry in the ring, so you can get any entry into the buffer. Eventually the pointer reaches the end of the ring; the next M-y loops back around to the first entry again.

M-y在环上移动最后一个拉动指针,但它不会改变环中条目的顺序,该顺序始终从前面最近的杀戮到仍然记得的最旧的杀戮。

M-y moves the last-yank pointer around the ring, but it does not change the order of the entries in the ring, which always runs from the most recent kill at the front to the oldest one still remembered.

C-y当在或之后使用时M-yM-y可以采用一个数字参数,该参数告诉它最后一个复制指针要前进多少个条目。负参数将指针移向环的前面;从环的前面开始,它移动到最后一个条目,并从那里继续向前。

When used after C-y or M-y, M-y can take a numeric argument, which tells it how many entries to advance the last-yank pointer by. A negative argument moves the pointer toward the front of the ring; from the front of the ring, it moves around to the last entry and continues forward from there.

一旦您要查找的文本被带入缓冲区,您就可以停止执行M-y命令,并且最后拉出的文本将保留在那里。它只是 Kill Ring 条目的副本,因此在缓冲区中编辑它不会更改环中的内容。只要没有完成新的kill,最后一个复制指针就会保留在kill环中的同一位置,因此重复C-y将复制相同的先前kill的另一个副本。

Once the text you are looking for is brought into the buffer, you can stop doing M-y commands and the last yanked text will stay there. It’s just a copy of the kill ring entry, so editing it in the buffer does not change what’s in the ring. As long as no new killing is done, the last-yank pointer remains at the same place in the kill ring, so repeating C-y will yank another copy of the same previous kill.

当您C-y使用数字参数调用时,还会将最后复制指针设置为它复制的条目。

When you call C-y with a numeric argument, that also sets the last-yank pointer to the entry that it yanks.

您还可以M-y在非 yank 命令之后调用。在这种情况下,M-y会提示您在迷你缓冲区中进行之前的杀戮之一。您可以使用迷你缓冲区历史记录命令(请参阅迷你缓冲区历史记录)来导航或搜索 Kill Ring 中的条目,直到找到要重新插入的条目。或者,您可以使用完成命令(请参阅完成命令)来完成 Kill Ring 中条目列表中的条目,或者弹出*完工*包含可供您选择的候选条目的缓冲区。选择终止环条目后,您可以选择在迷你缓冲区中编辑它。最后,键入 RET退出迷你缓冲区并插入所选终止环条目的文本。就像在另一个 yank 命令之后的情况一样M-y,最后一个 yank 指针将指向您刚刚 yank 的文本,无论它是先前的删除之一还是您在插入之前编辑的删除环中的条目。 (在后一种情况下,编辑后的条目将添加到终止环的前面。)因此,在这里,键入C-y也会拉出刚刚插入的文本的另一个副本。

You can also invoke M-y after a command that is not a yank command. In that case, M-y prompts you in the minibuffer for one of the previous kills. You can use the minibuffer history commands (see Minibuffer History) to navigate or search through the entries in the kill ring until you find the one you want to reinsert. Or you can use completion commands (see Completion Commands) to complete on an entry from the list of entries in the kill ring or pop up the *Completions* buffer with the candidate entries from which you can choose. After selecting the kill-ring entry, you can optionally edit it in the minibuffer. Finally, type RET to exit the minibuffer and insert the text of the selected kill-ring entry. Like in case of M-y after another yank command, the last-yank pointer is left pointing at the text you just yanked, whether it is one of the previous kills or an entry from the kill-ring that you edited before inserting it. (In the latter case, the edited entry is added to the front of the kill-ring.) So here, too, typing C-y will yank another copy of the text just inserted.

C-u M-y当在非 yank 命令之后使用普通前缀参数 ( ) 调用时,M-y会将光标保留在插入文本的前面,并在末尾设置标记,就像 C-y这样做一样。

When invoked with a plain prefix argument (C-u M-y) after a command that is not a yank command, M-y leaves the cursor in front of the inserted text, and sets the mark at the end, like C-y does.


13.2.3 追加杀戮

13.2.3 Appending Kills

通常,每个终止命令都会将一个新条目推送到终止环上。然而,连续两个或多个终止命令将它们的文本组合成一个条目,以便单个C-y命令将所有文本作为一个单元进行拉取,就像它被终止之前一样。

Normally, each kill command pushes a new entry onto the kill ring. However, two or more kill commands in a row combine their text into a single entry, so that a single C-y yanks all the text as a unit, just as it was before it was killed.

因此,如果您想将文本作为一个单元进行拉取,则无需使用一个命令删除所有文本;只需使用一个命令即可将其全部删除。你可以继续一行一行地删除,或者一个字一个字地删除,直到你把它全部删除,并且你仍然可以立即将其全部恢复。

Thus, if you want to yank text as a unit, you need not kill all of it with one command; you can keep killing line after line, or word after word, until you have killed it all, and you can still get it all back at once.

从点向前删除的命令会添加到前一个被删除文本的末尾。从点向后删除的命令将文本添加到开头。这样,任何混合的向前和向后终止命令序列都会将所有终止的文本放入一个条目中,而无需重新排列。数字参数不会破坏附加终止的顺序。例如,假设缓冲区包含以下文本:

Commands that kill forward from point add onto the end of the previous killed text. Commands that kill backward from point add text onto the beginning. This way, any sequence of mixed forward and backward kill commands puts all the killed text into one entry without rearrangement. Numeric arguments do not break the sequence of appending kills. For example, suppose the buffer contains this text:

这是示例文本的一行*。
This is a line ∗of sample text.

点用*表示。如果你输入,向前和向后交替杀死,你最终会得到 'M-d M-DEL M-d M-DEL一行样本' 作为杀戮环中的一个条目,并且 '这是文字。'在缓冲区中。 (注意 ' 之间的双空格' 和 '文本',您可以使用 或进行清理。) M-SPCM-q

with point shown by ∗. If you type M-d M-DEL M-d M-DEL, killing alternately forward and backward, you end up with ‘a line of sample’ as one entry in the kill ring, and ‘This is  text. in the buffer. (Note the double space between ‘is’ and ‘text’, which you can clean up with M-SPC or M-q.)

另一种杀死相同文本的方法是向后移动两个单词 M-b M-b,然后杀死所有四个单词C-u M-d。这在缓冲区和终止环中产生完全相同的结果。 杀死相同的文本,全部向后;再一次,结果还是一样。终止环条目中的文本始终与终止它之前在缓冲区中的顺序相同。 M-f M-f C-u M-DEL

Another way to kill the same text is to move back two words with M-b M-b, then kill all four words forward with C-u M-d. This produces exactly the same results in the buffer and in the kill ring. M-f M-f C-u M-DEL kills the same text, all going backward; once again, the result is the same. The text in the kill ring entry always has the same order that it had in the buffer before you killed it.

如果一个kill命令与最后一个kill命令被其他命令(不仅仅是数字参数)分开,它会在kill环上启动一个新条目。但是您可以通过预先键入C-M-w( )来强制它与最后删除的文本合并。append-next-kill告诉 C-M-w它的后续命令,如果它是一个终止命令,则将该终止视为先前终止序列的一部分。与往常一样,如果命令向前终止,则终止将附加到先前终止的文本,如果命令向后终止,则终止将附加到前面。通过这种方式,您可以删除几个单独的文本片段并将它们累积起来以拉回到一个地方。

If a kill command is separated from the last kill command by other commands (not just numeric arguments), it starts a new entry on the kill ring. But you can force it to combine with the last killed text, by typing C-M-w (append-next-kill) right beforehand. The C-M-w tells its following command, if it is a kill command, to treat the kill as part of the sequence of previous kills. As usual, the kill is appended to the previous killed text if the command kills forward, and prepended if the command kills backward. In this way, you can kill several separated pieces of text and accumulate them to be yanked back in one place.

M-w( )后面的终止命令不会附加到复制到终止环中的 kill-ring-save文本。M-w

A kill command following M-w (kill-ring-save) does not append to the text that M-w copied into the kill ring.


13.3 图形显示上的“剪切和粘贴”操作

13.3 “Cut and Paste” Operations on Graphical Displays

在大多数图形桌面环境中,您可以使用称为剪贴板的系统工具在不同应用程序之间传输数据(通常是文本)。在 X 上,还有另外两个类似的设施可用:主要选择和次要选择。当 Emacs 在图形显示器上运行时,它的 Kill 和 yank 命令与这些工具集成,以便您可以轻松地在 Emacs 和其他图形应用程序之间传输文本。

In most graphical desktop environments, you can transfer data (usually text) between different applications using a system facility called the clipboard. On X, two other similar facilities are available: the primary selection and the secondary selection. When Emacs is run on a graphical display, its kill and yank commands integrate with these facilities, so that you can easily transfer text between Emacs and other graphical applications.

默认情况下,Emacs 使用 UTF-8 作为程序间文本传输的编码系统。如果您发现粘贴的文本不是您所期望的,您可以通过键入或来指定另一个编码系统。您还可以通过自定义来请求不同的数据类型。请参阅进程间通信的编码系统C-x RET xC-x RET Xx-select-request-type

By default, Emacs uses UTF-8 as the coding system for inter-program text transfers. If you find that the pasted text is not what you expected, you can specify another coding system by typing C-x RET x or C-x RET X. You can also request a different data type by customizing x-select-request-type. See Coding Systems for Interprocess Communication.


13.3.1 使用剪贴板

13.3.1 Using the Clipboard

剪贴板大多数图形应用程序用于“剪切和粘贴”的工具。当剪贴板存在时,Emacs 中的 Kill 和 yank 命令会使用它。

The clipboard is the facility that most graphical applications use for “cutting and pasting”. When the clipboard exists, the kill and yank commands in Emacs make use of it.

C-w 当您使用( )之类的命令删除某些文本,或使用( )kill-region之类的命令将其复制到删除环时,该文本也会放入剪贴板中。 M-wkill-ring-save

When you kill some text with a command such as C-w (kill-region), or copy it to the kill ring with a command such as M-w (kill-ring-save), that text is also put in the clipboard.

当 Emacs Kill 命令将文本放入剪贴板时,现有的剪贴板内容通常会丢失。或者,Emacs 可以将现有剪贴板内容保存到终止环,防止您丢失旧的剪贴板数据。如果 save-interprogram-paste-before-kill已设置为数字,则如果数据(以字符为单位)小于该数字,则数据将被复制。如果此变量是任何其他非nil值,则始终会复制数据 - 如果数据很大,则存在内存消耗较高的风险。

When an Emacs kill command puts text in the clipboard, the existing clipboard contents are normally lost. Optionally, Emacs can save the existing clipboard contents to the kill ring, preventing you from losing the old clipboard data. If save-interprogram-paste-before-kill has been set to a number, then the data is copied over if it’s smaller (in characters) than this number. If this variable is any other non-nil value, the data is always copied over—at the risk of high memory consumption if that data turns out to be large.

Yank 命令(例如C-y( yank))也使用剪贴板。如果另一个应用程序“拥有”剪贴板(即,如果您在 Emacs 中剪切或复制文本的时间比您在 Emacs 中的最后一个终止命令更晚),则 Emacs 会从剪贴板中提取内容而不是从删除环中提取内容。

Yank commands, such as C-y (yank), also use the clipboard. If another application “owns” the clipboard—i.e., if you cut or copied text there more recently than your last kill command in Emacs—then Emacs yanks from the clipboard instead of the kill ring.

M-y通常,用( )旋转终止环yank-pop不会改变剪贴板。但是,如果更改 yank-pop-change-selectiont,则将M-y新的复制保存到剪贴板。

Normally, rotating the kill ring with M-y (yank-pop) does not alter the clipboard. However, if you change yank-pop-change-selection to t, then M-y saves the new yank to the clipboard.

要防止 Kill 和 yank 命令访问剪贴板,请将变量更改select-enable-clipboardnil

To prevent kill and yank commands from accessing the clipboard, change the variable select-enable-clipboard to nil.

程序可以将纯文本以外的其他内容放入剪贴板。例如,网络浏览器通常会让您在图像上选择“复制图像”,该图像将被放置在剪贴板上。在有能力的平台上,Emacs 可以使用该yank-media 命令来拉取这些对象,但仅限于支持它的模式(请参阅《Emacs Lisp 参考手册》中的“Yanking Media”)。

Programs can put other things than plain text on the clipboard. For instance, a web browser will usually let you choose “Copy Image” on images, and this image will be put on the clipboard. On capable platforms, Emacs can yank these objects with the yank-media command—but only in modes that have support for it (see Yanking Media in The Emacs Lisp Reference Manual).

许多 X 桌面环境都支持称为剪贴板管理器的功能 。如果您在 Emacs 是剪贴板数据的当前“所有者”时退出,并且剪贴板管理器正在运行,Emacs 会将剪贴板数据传输到剪贴板管理器,以免丢失。在某些情况下,这可能会导致退出 Emacs 时出现延迟;如果您希望阻止 Emacs 将数据传输到剪贴板管理器,请将变量更改 x-select-enable-clipboard-managernil.

Many X desktop environments support a feature called the clipboard manager. If you exit Emacs while it is the current “owner” of the clipboard data, and there is a clipboard manager running, Emacs transfers the clipboard data to the clipboard manager so that it is not lost. In some circumstances, this may cause a delay when exiting Emacs; if you wish to prevent Emacs from transferring data to the clipboard manager, change the variable x-select-enable-clipboard-manager to nil.

由于包含 NUL 字节的字符串在通过剪贴板时通常会被截断,因此 Emacs 在将它们传输到系统剪贴板之前将这些字符替换为“\0”。

Since strings containing NUL bytes are usually truncated when passed through the clipboard, Emacs replaces such characters with “\0” before transferring them to the system’s clipboard.

在 Emacs 24 之前,kill 和 yank 命令使用主要选择(请参阅使用其他窗口应用程序进行剪切和粘贴),而不是剪贴板。如果您喜欢这种行为,请更改select-enable-clipboardnilselect-enable-primaryt和 。在这种情况下,您可以使用以下命令显式地作用于剪贴板: 杀死该区域并将其保存到剪贴板;将区域复制到 Kill Ring 并将其保存到剪贴板;并 在此时猛拉剪贴板的内容。 mouse-drag-copy-regiontclipboard-kill-regionclipboard-kill-ring-saveclipboard-yank

Prior to Emacs 24, the kill and yank commands used the primary selection (see Cut and Paste with Other Window Applications), not the clipboard. If you prefer this behavior, change select-enable-clipboard to nil, select-enable-primary to t, and mouse-drag-copy-region to t. In this case, you can use the following commands to act explicitly on the clipboard: clipboard-kill-region kills the region and saves it to the clipboard; clipboard-kill-ring-save copies the region to the kill ring and saves it to the clipboard; and clipboard-yank yanks the contents of the clipboard at point.


13.3.2 使用其他窗口应用程序进行剪切和粘贴

13.3.2 Cut and Paste with Other Window Applications

在 X Window 系统、PGTK 和 Haiku 下,存在一个 主要选择,其中包含 X 应用程序中选择的最后一段文本(通常通过拖动鼠标)。通常,可以通过单击将该文本插入到其他 X 应用程序中mouse-2 。主要选择与剪贴板分开。其内容物较易碎;每次使用鼠标选择文本时,它们都会被覆盖,而剪贴板只会被显式剪切或复制命令覆盖。

Under the X Window System, PGTK and Haiku, there exists a primary selection containing the last stretch of text selected in an X application (usually by dragging the mouse). Typically, this text can be inserted into other X applications by mouse-2 clicks. The primary selection is separate from the clipboard. Its contents are more fragile; they are overwritten each time you select text with the mouse, whereas the clipboard is only overwritten by explicit cut or copy commands.

在 X 下,只要区域处于活动状态(请参阅标记和区域),区域中的文本就会保存在主选择中。无论该区域是通过拖动或单击鼠标(请参阅用于编辑的鼠标命令)还是通过键盘命令(例如,通过键入 和移动点;请参阅设置标记)创建的,这都适用。 C-SPC

Under X, whenever the region is active (see The Mark and the Region), the text in the region is saved in the primary selection. This applies regardless of whether the region was made by dragging or clicking the mouse (see Mouse Commands for Editing), or by keyboard commands (e.g., by typing C-SPC and moving point; see Setting the Mark).

如果将该变量更改select-active-regionsonly,Emacs 只会将临时活动区域保存到主要选择中,即使用鼠标或使用 Shift 选择创建的区域(请参阅Shift Selection)。如果更改 select-active-regionsnil,Emacs 会避免将活动区域完全保存到主要选择中。

If you change the variable select-active-regions to only, Emacs saves only temporarily active regions to the primary selection, i.e., those made with the mouse or with shift selection (see Shift Selection). If you change select-active-regions to nil, Emacs avoids saving active regions to the primary selection entirely.

要将主要选择插入 Emacs 缓冲区,请 在要插入的位置单击mouse-2( )。mouse-yank-primary请参阅用于编辑的鼠标命令。如果已设置,您还可以使用普通的 Emacs 复制命令 ( C-y) 来插入此文本(请参阅使用剪贴板)。 select-enable-primary

To insert the primary selection into an Emacs buffer, click mouse-2 (mouse-yank-primary) where you want to insert it. See Mouse Commands for Editing. You can also use the normal Emacs yank command (C-y) to insert this text if select-enable-primary is set (see Using the Clipboard).

默认情况下,即使在另一个程序中选择了文本,Emacs 也会保持该区域处于活动状态;这与典型的 X 行为相反。要使 Emacs 在另一个程序将数据放入主选择后停用该区域,请启用全局次要模式 lost-selection-mode

By default, Emacs keeps the region active even after text is selected in another program; this is contrary to typical X behavior. To make Emacs deactivate the region after another program places data in the primary selection, enable the global minor mode lost-selection-mode.

MS-Windows 不提供主要选择,但 Emacs 通过在内部存储所选文本来在单个 Emacs 会话中模拟它。因此,与主要选择相关的所有功能和命令在 Windows 上的工作方式与在 X 上的工作方式相同,用于在同一会话中剪切和粘贴,但不能跨 Emacs 会话或与其他应用程序一起剪切和粘贴。

MS-Windows provides no primary selection, but Emacs emulates it within a single Emacs session by storing the selected text internally. Therefore, all the features and commands related to the primary selection work on Windows as they do on X, for cutting and pasting within the same session, but not across Emacs sessions or with other applications.


13.3.3 二次选择

13.3.3 Secondary Selection

除了主要选择之外,X Window 系统还提供了第二个类似的功能,称为辅助选择。如今,很少有 X 应用程序使用辅助选择,但您可以使用以下 Emacs 命令访问它:

In addition to the primary selection, the X Window System provides a second similar facility known as the secondary selection. Nowadays, few X applications make use of the secondary selection, but you can access it using the following Emacs commands:

M-Drag-mouse-1
M-Drag-mouse-1

设置辅助选择,一端位于按下按钮的位置,另一端位于松开按钮的位置(mouse-set-secondary)。secondary-selection当您拖动时,所选文本会使用该面突出显示。如果将鼠标拖离窗口的顶部或底部,窗口会自动滚动,就像mouse-set-region(请参阅用于编辑的鼠标命令)。

此命令不会更改终止环。

Set the secondary selection, with one end at the place where you press down the button, and the other end at the place where you release it (mouse-set-secondary). The selected text is highlighted, using the secondary-selection face, as you drag. The window scrolls automatically if you drag the mouse off the top or bottom of the window, just like mouse-set-region (see Mouse Commands for Editing).

This command does not alter the kill ring.

M-mouse-1
M-mouse-1

为二次选择设置一个端点 (mouse-start-secondary);用于M-mouse-3设置另一端并完成选择。当开始新的选择时,此命令会取消任何现有的辅助选择。

Set one endpoint for the secondary selection (mouse-start-secondary); use M-mouse-3 to set the other end and complete the selection. This command cancels any existing secondary selection, when it starts a new one.

M-mouse-3
M-mouse-3

设置辅助选择 ( mouse-secondary-save-then-kill),一端位于您单击的位置M-mouse-3,另一端位于先前使用 指定的位置M-mouse-1。这也会将选定的文本放入 Kill Ring 中。在同一位置的第二个M-mouse-3会杀死刚刚进行的辅助选择所选择的文本。

Set the secondary selection (mouse-secondary-save-then-kill), with one end at the position you click M-mouse-3, and the other at the position specified previously with M-mouse-1. This also puts the selected text in the kill ring. A second M-mouse-3 at the same place kills the text selected by the secondary selection just made.

M-mouse-2
M-mouse-2

在单击的位置插入辅助选择,将点放置在拉出文本的末尾 ( mouse-yank-secondary)。

Insert the secondary selection where you click, placing point at the end of the yanked text (mouse-yank-secondary).

双击或三次单击 可以M-mouse-1对单词和线条进行操作,非常类似于mouse-1

Double or triple clicking of M-mouse-1 operates on words and lines, much like mouse-1.

如果mouse-yank-at-point是非nilM-mouse-2则在该点猛拉。那么,您单击的具体位置,甚至单击框架的哪个窗口都无关紧要。请参阅用于编辑的鼠标命令。此用户选项还会影响交互式搜索:如果不是nil,则用鼠标在框架中的任意位置拖动会将文本添加到搜索字符串中。

If mouse-yank-at-point is non-nil, M-mouse-2 yanks at point. Then it does not matter precisely where you click, or even which of the frame’s windows you click on. See Mouse Commands for Editing. This user option also effects interactive search: if it is non-nil, yanking with the mouse anywhere in the frame will add the text to the search string.


13.4 累积文本

13.4 Accumulating Text

通常,我们通过杀死文本并拉动文本来复制或移动文本,但是还有其他方便的方法可以将一块文本复制到许多地方,或者将许多分散的文本块复制到一个地方。在这里,我们描述将分散的文本片段累积到缓冲区或文件中的命令。

Usually we copy or move text by killing it and yanking it, but there are other convenient methods for copying one block of text in many places, or for copying many scattered blocks of text into one place. Here we describe the commands to accumulate scattered pieces of text into a buffer or into a file.

M-x append-to-buffer
M-x append-to-buffer

将区域附加到指定缓冲区的内容。

Append region to the contents of a specified buffer.

M-x prepend-to-buffer
M-x prepend-to-buffer

将区域添加到指定缓冲区的内容之前。

Prepend region to the contents of a specified buffer.

M-x copy-to-buffer
M-x copy-to-buffer

将区域复制到指定的缓冲区中,删除该缓冲区的旧内容。

Copy region into a specified buffer, deleting that buffer’s old contents.

M-x insert-buffer
M-x insert-buffer

将指定缓冲区的内容插入到当前缓冲区的指定位置。

Insert the contents of a specified buffer into current buffer at point.

M-x append-to-file
M-x append-to-file

将区域附加到指定文件的内容末尾。

Append region to the contents of a specified file, at the end.

要将文本累积到缓冲区中,请使用M-x append-to-buffer.这会读取缓冲区名称,然后将该区域的副本插入到指定的缓冲区中。如果指定不存在的缓冲区,则 append-to-buffer创建该缓冲区。文本将插入到该缓冲区中的任何点处。如果您一直在使用缓冲区进行编辑,则复制的文本将进入缓冲区文本的中间,从当时所在的位置开始。

To accumulate text into a buffer, use M-x append-to-buffer. This reads a buffer name, then inserts a copy of the region into the buffer specified. If you specify a nonexistent buffer, append-to-buffer creates the buffer. The text is inserted wherever point is in that buffer. If you have been using the buffer for editing, the copied text goes into the middle of the text of the buffer, starting from wherever point happens to be at that moment.

该缓冲区中的点保留在复制文本的末尾,因此连续使用将append-to-buffer文本按照复制的顺序累积在指定缓冲区中。严格来说,append-to-buffer并不总是附加到缓冲区中已有的文本 - 仅当缓冲区中的点位于末尾时才附加。但是,如果append-to-buffer是用于更改缓冲区的唯一命令,则 point 始终位于末尾。

Point in that buffer is left at the end of the copied text, so successive uses of append-to-buffer accumulate the text in the specified buffer in the same order as they were copied. Strictly speaking, append-to-buffer does not always append to the text already in the buffer—it appends only if point in that buffer is at the end. However, if append-to-buffer is the only command you use to alter a buffer, then point is always at the end.

M-x prepend-to-buffer与此类似,只是append-to-buffer 另一个缓冲区中的点位于复制的文本之前,因此连续使用此命令会以相反的顺序添加文本。 M-x copy-to-buffer类似,只不过另一个缓冲区中的任何现有文本都被删除,因此缓冲区仅包含新复制到其中的文本。

M-x prepend-to-buffer is just like append-to-buffer except that point in the other buffer is left before the copied text, so successive uses of this command add text in reverse order. M-x copy-to-buffer is similar, except that any existing text in the other buffer is deleted, so the buffer is left containing just the text newly copied into it.

命令C-x x i( insert-buffer) 可用于从另一个缓冲区检索累积的文本。这会提示输入缓冲区的名称,并将该缓冲区中所有文本的副本插入到当前缓冲区的 point 中,将 point 留在插入文本的开头。它还将插入文本末尾的位置添加到标记环,而不激活标记。有关缓冲区的背景信息, 请参阅使用多个缓冲区。

The command C-x x i (insert-buffer) can be used to retrieve the accumulated text from another buffer. This prompts for the name of a buffer, and inserts a copy of all the text in that buffer into the current buffer at point, leaving point at the beginning of the inserted text. It also adds the position of the end of the inserted text to the mark ring, without activating the mark. See Using Multiple Buffers, for background information on buffers.

您可以将文本直接附加到带有M-x append-to-file.这会提示输入文件名,并将该区域的文本添加到指定文件的末尾。该文件立即在磁盘上更改。

Instead of accumulating text in a buffer, you can append text directly into a file with M-x append-to-file. This prompts for a filename, and adds the text of the region to the end of the specified file. The file is changed immediately on disk.

您应该仅对Emacs 中append-to-file访问的文件 使用。在 Emacs 中编辑的文件上使用它会更改 Emacs 背后的文件,这可能会导致丢失一些编辑内容。

You should use append-to-file only with files that are not being visited in Emacs. Using it on a file that you are editing in Emacs would change the file behind Emacs’s back, which can lead to losing some of your editing.

移动文本的另一种方法是将其存储在寄存器中。请参阅寄存器

Another way to move text around is to store it in a register. See Registers.


13.5 矩形

13.5 Rectangles

矩形命令对文本的矩形区域进行操作:特定行范围内的特定对列之间的所有字符。 Emacs 具有杀死矩形、拉出杀死的矩形、清除它们、用空白或文本填充它们或删除它们的命令。矩形命令对于多列格式的文本以及将文本更改为此类格式或将其更改为此类格式非常有用。

Rectangle commands operate on rectangular areas of the text: all the characters between a certain pair of columns, in a certain range of lines. Emacs has commands to kill rectangles, yank killed rectangles, clear them out, fill them with blanks or text, or delete them. Rectangle commands are useful with text in multicolumn formats, and for changing text into or out of such formats.

要为命令指定一个矩形,请将标记设置在一个角并指向对角。这样指定的矩形称为区域矩形。如果点和标记在同一列中,则区域矩形为空。如果它们在同一行,则区域矩形为一行高。

To specify a rectangle for a command to work on, set the mark at one corner and point at the opposite corner. The rectangle thus specified is called the region-rectangle. If point and the mark are in the same column, the region-rectangle is empty. If they are in the same line, the region-rectangle is one line high.

区域矩形的控制方式与区域的控制方式大致相同。但请记住,点和标记值的给定组合可以解释为区域或矩形,具体取决于使用它们的命令。

The region-rectangle is controlled in much the same way as the region is controlled. But remember that a given combination of point and mark values can be interpreted either as a region or as a rectangle, depending on the command that uses them.

也可以使用鼠标来标记矩形区域:单击并 C-M-mouse-1从矩形的一个角拖动到另一角。

A rectangular region can also be marked using the mouse: click and drag C-M-mouse-1 from one corner of the rectangle to the opposite.

C-x r k
C-x r k

删除区域矩形的文本,将其内容保存为最后删除的矩形 ( kill-rectangle)。

Kill the text of the region-rectangle, saving its contents as the last killed rectangle (kill-rectangle).

C-x r M-w
C-x r M-w

将区域矩形的文本保存为最后杀死的矩形(copy-rectangle-as-kill)。

Save the text of the region-rectangle as the last killed rectangle (copy-rectangle-as-kill).

C-x r d
C-x r d

删除区域矩形 ( delete-rectangle) 的文本。

Delete the text of the region-rectangle (delete-rectangle).

C-x r y
C-x r y

拉出最后一个被杀死的矩形,其左上角位于点 ( yank-rectangle) 处。

Yank the last killed rectangle with its upper left corner at point (yank-rectangle).

C-x r o
C-x r o

插入空白区域以填充区域矩形 ( open-rectangle) 的空间。这会将区域矩形的先前内容推到右侧。

Insert blank space to fill the space of the region-rectangle (open-rectangle). This pushes the previous contents of the region-rectangle to the right.

C-x r N
C-x r N

沿区域矩形 ( rectangle-number-lines) 的左边缘插入行号。这会将区域矩形的先前内容推到右侧。

Insert line numbers along the left edge of the region-rectangle (rectangle-number-lines). This pushes the previous contents of the region-rectangle to the right.

C-x r c
C-x r c

通过用空格 ( ) 替换其所有内容来清除区域矩形clear-rectangle

Clear the region-rectangle by replacing all of its contents with spaces (clear-rectangle).

M-x delete-whitespace-rectangle
M-x delete-whitespace-rectangle

从矩形的左边缘列开始,删除指定矩形上每行中的空白。

Delete whitespace in each of the lines on the specified rectangle, starting from the left edge column of the rectangle.

C-x r t string RET
C-x r t string RET

将每行 ( ) 上的矩形内容替换为字符串string-rectangle

Replace rectangle contents with string on each line (string-rectangle).

M-x string-insert-rectangle RET string RET
M-x string-insert-rectangle RET string RET

在矩形的每一行 插入字符串。

Insert string on each line of the rectangle.

C-x SPC
C-x SPC

切换矩形标记模式 ( rectangle-mark-mode)。当此模式处于活动状态时,区域矩形会突出显示并可以缩小/增大,并且标准的终止和复制命令会对其进行操作。

Toggle Rectangle Mark mode (rectangle-mark-mode). When this mode is active, the region-rectangle is highlighted and can be shrunk/grown, and the standard kill and yank commands operate on it.

矩形操作分为两类:擦除或插入矩形的命令和创建空白矩形的命令。

The rectangle operations fall into two classes: commands to erase or insert rectangles, and commands to make blank rectangles.

有两种方法可以删除矩形中的文本:( ) 彻底删除文本,或C-x r d ( )删除文本并将其另存为 最后删除的矩形。在这两种情况下,擦除区域矩形就像擦除矩形每行上的指定文本一样;如果该行有任何后续文本,它将向后移动以填补空白。 delete-rectangleC-x r kkill-rectangle

There are two ways to erase the text in a rectangle: C-x r d (delete-rectangle) to delete the text outright, or C-x r k (kill-rectangle) to remove the text and save it as the last killed rectangle. In both cases, erasing the region-rectangle is like erasing the specified text on each line of the rectangle; if there is any following text on the line, it moves backwards to fill the gap.

杀死一个矩形并不是通常意义上的杀死;而是杀死一个矩形。该矩形并不存储在killring中,而是存储在一个特殊的地方,只记录最近被杀死的矩形。这是因为拉动矩形与拉动线性文本非常不同,因此必须使用不同的拉动命令。没有为矩形定义 Yank-popping。

Killing a rectangle is not killing in the usual sense; the rectangle is not stored in the kill ring, but in a special place that only records the most recent rectangle killed. This is because yanking a rectangle is so different from yanking linear text that different yank commands have to be used. Yank-popping is not defined for rectangles.

C-x r M-w( copy-rectangle-as-kill) 相当于 M-w矩形:它将矩形记录为最后一个被杀死的矩形,而不从缓冲区中删除文本。

C-x r M-w (copy-rectangle-as-kill) is the equivalent of M-w for rectangles: it records the rectangle as the last killed rectangle, without deleting the text from the buffer.

要拉出最后一个被杀死的矩形,请输入C-x r y ( yank-rectangle)。矩形的第一条线插入到点处,矩形的第二条线插入到垂直下方一行的同一水平位置,依此类推。受影响的行数由保存的矩形的高度决定。

To yank the last killed rectangle, type C-x r y (yank-rectangle). The rectangle’s first line is inserted at point, the rectangle’s second line is inserted at the same horizontal position one line vertically below, and so on. The number of lines affected is determined by the height of the saved rectangle.

例如,您可以将两个单列列表转换为双列列表,方法是将其中一个单列列表作为矩形删除,然后将其拉到另一个列表旁边。

For example, you can convert two single-column lists into a double-column list by killing one of the single-column lists as a rectangle, and then yanking it beside the other list.

您还可以使用 和 将矩形复制到寄存器中或从寄存器中复制出来。请参阅在寄存器中保存矩形C-x r r rC-x r i r

You can also copy rectangles into and out of registers with C-x r r r and C-x r i r. See Saving Rectangles in Registers.

您可以使用两个命令来创建空白矩形:( ) 空白区域矩形中的现有文本,C-x r c( )插入空白矩形。 clear-rectangleC-x r oopen-rectangle

There are two commands you can use for making blank rectangles: C-x r c (clear-rectangle) blanks out existing text in the region-rectangle, and C-x r o (open-rectangle) inserts a blank rectangle.

M-x delete-whitespace-rectangle删除从特定列开始的水平空白。这适用于矩形中的每条线,并且列由矩形的左边缘指定。矩形的右边缘对此命令没有任何影响。

M-x delete-whitespace-rectangle deletes horizontal whitespace starting from a particular column. This applies to each of the lines in the rectangle, and the column is specified by the left edge of the rectangle. The right edge of the rectangle does not make any difference to this command.

命令C-x r N( rectangle-number-lines) 沿着区域矩形的左边缘插入行号。通常,编号从 1 开始(矩形的第一行)。使用前缀参数,该命令会提示输入一个开始的数字,以及用于打印数字的格式字符串(请参阅《Emacs Lisp 参考手册》中的格式化字符串)。

The command C-x r N (rectangle-number-lines) inserts line numbers along the left edge of the region-rectangle. Normally, the numbering begins from 1 (for the first line of the rectangle). With a prefix argument, the command prompts for a number to begin from, and for a format string with which to print the numbers (see Formatting Strings in The Emacs Lisp Reference Manual).

命令C-x r t( string-rectangle) 将区域矩形的内容替换为每行上的字符串。字符串的宽度不必与矩形的宽度相同。如果字符串的宽度较小,则矩形后面的文本向左移动;如果字符串比矩形宽,则矩形后面的文本右移。

The command C-x r t (string-rectangle) replaces the contents of a region-rectangle with a string on each line. The string’s width need not be the same as the width of the rectangle. If the string’s width is less, the text after the rectangle shifts left; if the string is wider than the rectangle, the text after the rectangle shifts right.

该命令M-x string-insert-rectangle与 类似 string-rectangle,但在每行插入字符串,将原始文本向右移动。

The command M-x string-insert-rectangle is similar to string-rectangle, but inserts the string on each line, shifting the original text to the right.

命令( ) 切换是否突出显示区域矩形或标准区域(如有必要,首先激活该区域)。启用此模式后,调整区域大小( 等)的命令会以矩形方式执行此操作,并且删除和拉动会在矩形上进行操作。请参阅删除和移动文本。仅当该区域处于活动状态时,该模式才会持续存在。 C-x SPCrectangle-mark-modeC-fC-n

The command C-x SPC (rectangle-mark-mode) toggles whether the region-rectangle or the standard region is highlighted (first activating the region if necessary). When this mode is enabled, commands that resize the region (C-f, C-n etc.) do so in a rectangular fashion, and killing and yanking operate on the rectangle. See Killing and Moving Text. The mode persists only as long as the region is active.

仅当标记处于活动状态时,区域矩形才起作用。特别是,当瞬态标记模式关闭时(请参阅禁用瞬态标记模式),除了键入之外,您还需要激活标记。 C-x SPC

The region-rectangle works only when the mark is active. In particular, when Transient Mark mode is off (see Disabling Transient Mark Mode), in addition to typing C-x SPC you will need to activate the mark.

与标准区域不同,区域矩形的角可以延伸超过缓冲区的末尾,或者点通常无法进入的空白区域内部,例如 TAB 字符的中间。

Unlike the standard region, the region-rectangle can have its corners extended past the end of buffer, or inside stretches of white space that point normally cannot enter, like in the middle of a TAB character.

当区域处于活动状态(请参阅标记和区域)并且处于矩形标记模式时, C-x C-x运行命令 rectangle-exchange-point-and-mark,该命令在区域矩形的四个角之间循环。如果您想在对标记文本调用操作之前修改区域矩形的尺寸,这会很方便。

When the region is active (see The Mark and the Region) and in rectangle-mark-mode, C-x C-x runs the command rectangle-exchange-point-and-mark, which cycles between the four corners of the region-rectangle. This comes in handy if you want to modify the dimensions of the region-rectangle before invoking an operation on the marked text.


13.6 CUA 绑定

13.6 CUA Bindings

该命令M-x cua-mode设置与许多其他应用程序中使用的通用用户访问 (CUA) 系统兼容的键绑定。

The command M-x cua-mode sets up key bindings that are compatible with the Common User Access (CUA) system used in many other applications.

启用 CUA 模式时,按键C-xC-cC-vC-z分别调用剪切(删除)、复制、粘贴(复制)和撤消命令。仅当区域处于活动状态时, 和 键才执行剪切和复制C-xC-c否则,它们仍然充当前缀键,因此标准 Emacs 命令C-x C-c仍然有效。请注意,这意味着该变量对和mark-even-if-inactive 没有影响(请参阅在区域上操作)。 C-xC-c

When CUA mode is enabled, the keys C-x, C-c, C-v, and C-z invoke commands that cut (kill), copy, paste (yank), and undo respectively. The C-x and C-c keys perform cut and copy only if the region is active. Otherwise, they still act as prefix keys, so that standard Emacs commands like C-x C-c still work. Note that this means the variable mark-even-if-inactive has no effect for C-x and C-c (see Operating on the Region).

要在标记处于活动状态时输入类似 Emacs 命令C-x C-f,请使用以下方法之一:按住Shift 前缀键(例如 )S-C-x C-f,或快速键入前缀键两次(例如 )C-x C-x C-f

To enter an Emacs command like C-x C-f while the mark is active, use one of the following methods: either hold Shift together with the prefix key, e.g., S-C-x C-f, or quickly type the prefix key twice, e.g., C-x C-x C-f.

要禁用 CUA 模式覆盖标准 Emacs 绑定,同时保留下述 CUA 模式的其他功能,请将变量设置cua-enable-cua-keysnil

To disable the overriding of standard Emacs binding by CUA mode, while retaining the other features of CUA mode described below, set the variable cua-enable-cua-keys to nil.

默认情况下,CUA 模式会激活删除选择模式(请参阅用于编辑的鼠标命令),以便键入的文本替换活动区域。要在没有此行为的情况下使用 CUA,请将变量设置cua-delete-selectionnil

CUA mode by default activates Delete-Selection mode (see Mouse Commands for Editing) so that typed text replaces the active region. To use CUA without this behavior, set the variable cua-delete-selection to nil.

CUA 模式通过可见矩形突出显示提供增强的矩形支持。使用开始一个矩形,使用移动命令扩展它,然后使用 或 剪切或复制 它 。将光标移动到矩形的下一个(顺时针)角,以便您可以轻松地向任何方向扩展它。您键入的普通文本将插入到矩形中每行的左侧或右侧(与光标位于同一侧)。 C-RETC-xC-cRET

CUA mode provides enhanced rectangle support with visible rectangle highlighting. Use C-RET to start a rectangle, extend it using the movement commands, and cut or copy it using C-x or C-c. RET moves the cursor to the next (clockwise) corner of the rectangle, so you can easily expand it in any direction. Normal text you type is inserted to the left or right of each line in the rectangle (on the same side as the cursor).

您可以通过调用命令来使用此矩形支持,而无需激活 CUA cua-rectangle-mark-mode。还有标准命令 rectangle-mark-mode,请参阅矩形

You can use this rectangle support without activating CUA by calling the cua-rectangle-mark-mode command. There’s also the standard command rectangle-mark-mode, see Rectangles.

使用CUA,您可以通过为kill、copy 和yank 命令提供一位数字前缀,轻松地将文本和矩形复制到寄存器中或从寄存器中复制出来,例如,C-1 C-c将区域复制到寄存器中 1,并C-2 C-v复制寄存器的内容2

With CUA you can easily copy text and rectangles into and out of registers by providing a one-digit numeric prefix to the kill, copy, and yank commands, e.g., C-1 C-c copies the region into register 1, and C-2 C-v yanks the contents of register 2.

CUA 模式还具有全局标记功能,允许在缓冲区之间轻松移动和复制文本。用于打开和关闭全局标记。当全局标记打开时,您删除或复制的所有文本都会自动插入到全局标记处,并且您键入的文本会插入到全局标记处而不是当前位置。 C-S-SPC

CUA mode also has a global mark feature which allows easy moving and copying of text between buffers. Use C-S-SPC to toggle the global mark on and off. When the global mark is on, all text that you kill or copy is automatically inserted at the global mark, and text you type is inserted at the global mark rather than at the current position.

例如,要将单词从各个缓冲区复制到给定缓冲区中的单词列表中,请在目标缓冲区中设置全局标记,然后导航到列表中所需的每个单词,对其进行标记(例如,使用 S-M-f),然后复制它使用C-c或移动到列表M-w,然后按 ,在目标列表中的单词后面插入换行符 RET

For example, to copy words from various buffers into a word list in a given buffer, set the global mark in the target buffer, then navigate to each of the words you want in the list, mark it (e.g., with S-M-f), copy it to the list with C-c or M-w, and insert a newline after the word in the target list by pressing RET.


14个寄存器

14 Registers

Emacs寄存器是一些隔间,您可以在其中保存文本、矩形、位置和其他内容以供以后使用。一旦将文本或矩形保存到寄存器中,您可以将其复制到缓冲区一次或多次;一旦您在寄存器中保存了一个位置,您就可以跳回该位置一次或多次。

Emacs registers are compartments where you can save text, rectangles, positions, and other things for later use. Once you save text or a rectangle in a register, you can copy it into the buffer once or many times; once you save a position in a register, you can jump back to that position once or many times.

每个寄存器都有一个由单个字符组成的名称,我们用r表示;r可以是一个字母(例如 'A') 或一个数字(例如 '1');案件很重要,所以注册'A'与寄存器不同'A'。您还可以使用非字母数字字符设置寄存器,例如 '*' 或者 '光盘'。请注意,不可能在 ' 中设置寄存器' 或者 'ESC键',因为这些键是为退出保留的(请参阅退出和中止)。

Each register has a name that consists of a single character, which we will denote by r; r can be a letter (such as ‘a’) or a number (such as ‘1’); case matters, so register ‘a’ is not the same as register ‘A’. You can also set a register in non-alphanumeric characters, for instance ‘*’ or ‘C-d’. Note, it’s not possible to set a register in ‘C-g’ or ‘ESC’, because these keys are reserved for quitting (see Quitting and Aborting).

寄存器可以存储位置、一段文本、矩形、数字、窗口或框架配置、缓冲区名称或文件名,但在任何给定时间只能存储一件事。您在寄存器中存储的任何内容都会保留在那里,直到您在该寄存器中存储其他内容为止。要查看寄存器r包含什么,请使用M-x view-register

A register can store a position, a piece of text, a rectangle, a number, a window or frame configuration, a buffer name, or a file name, but only one thing at any given time. Whatever you store in a register remains there until you store something else in that register. To see what register r contains, use M-x view-register:

M-x view-register RET r
M-x view-register RET r

显示寄存器r包含的内容的描述。

Display a description of what register r contains.

所有提示输入寄存器的命令将在短暂延迟后显示一个预览窗口,其中列出现有寄存器(如果有)。要更改延迟长度,请自定义register-preview-delay。要防止出现此显示,请将该选项设置为nil。您可以通过按C-h或明确请求预览窗口F1

All of the commands that prompt for a register will display a preview window that lists the existing registers (if there are any) after a short delay. To change the length of the delay, customize register-preview-delay. To prevent this display, set that option to nil. You can explicitly request a preview window by pressing C-h or F1.

书签记录了文件及其位置,以便您再次查看文件时可以返回到这些位置。书签在本质上与寄存器类似,因此本章也对它们进行了记录。

Bookmarks record files and positions in them, so you can return to those positions when you look at the file again. Bookmarks are similar in spirit to registers, so they are also documented in this chapter.


14.1 保存寄存器中的位置

14.1 Saving Positions in Registers

C-x r SPC r
C-x r SPC r

将点的位置和当前缓冲区记录在寄存器 r ( point-to-register)中。

Record the position of point and the current buffer in register r (point-to-register).

C-x r j r
C-x r j r

跳转到寄存器r ( )中保存的位置和缓冲区jump-to-register

Jump to the position and buffer saved in register r (jump-to-register).

键入( ),后跟一个字符,将 point 的位置和当前缓冲区保存在寄存器r中。寄存器会保留此信息,直到您在其中存储其他内容为止。 C-x r SPCpoint-to-registerr

Typing C-x r SPC (point-to-register), followed by a character r, saves both the position of point and the current buffer in register r. The register retains this information until you store something else in it.

该命令切换到寄存器r中记录的缓冲区,压入一个标记,并将 point 移动到记录的位置。 (如果点已经在记录的位置,或者连续调用命令,则不会推送标记。)寄存器的内容不会更改,因此您可以多次跳转到保存的位置。 C-x r j r

The command C-x r j r switches to the buffer recorded in register r, pushes a mark, and moves point to the recorded position. (The mark is not pushed if point was already at the recorded position, or in successive calls to the command.) The contents of the register are not changed, so you can jump to the saved position any number of times.

如果您用于C-x r j转到已保存的位置,但保存它的缓冲区已被终止,C-x r j则尝试通过访问同一文件再次创建缓冲区。当然,这仅适用于正在访问文件的缓冲区。

If you use C-x r j to go to a saved position, but the buffer it was saved from has been killed, C-x r j tries to create the buffer again by visiting the same file. Of course, this works only for buffers that were visiting files.


14.2 在寄存器中保存文本

14.2 Saving Text in Registers

当您想要多次插入同一段文本的副本时,将其从删除环中拉出可能会很不方便,因为随后的每次删除都会将该条目进一步移到环中。另一种方法是将文本存储在寄存器中,然后再检索它。

When you want to insert a copy of the same piece of text several times, it may be inconvenient to yank it from the kill ring, since each subsequent kill moves that entry further down the ring. An alternative is to store the text in a register and later retrieve it.

C-x r s r
C-x r s r

将区域复制到寄存器r ( copy-to-register) 中。

Copy region into register r (copy-to-register).

C-x r i r
C-x r i r

插入寄存器r ( )中的文本insert-register

Insert text from register r (insert-register).

M-x append-to-register RET r
M-x append-to-register RET r

将区域附加到寄存器r中的文本。

当寄存器r包含文本时,可以使用C-x r + ( increment-register) 追加到该寄存器。请注意,C-x r +如果r包含数字,则命令的行为会有所不同。请参阅将数字保存在寄存器中

Append region to text in register r.

When register r contains text, you can use C-x r + (increment-register) to append to that register. Note that command C-x r + behaves differently if r contains a number. See Keeping Numbers in Registers.

M-x prepend-to-register RET r
M-x prepend-to-register RET r

将区域添加到寄存器r中的文本前面。

Prepend region to text in register r.

C-x r s r将区域文本的副本存储到名为r的寄存器中。如果该标记处于非活动状态,Emacs 首先会在上次设置的位置重新激活该标记。该命令结束时该标记被停用。请参阅“标记”和“区域”。 ,带有前缀参数的相同命令,将文本复制到寄存器 r并从缓冲区中删除文本;您可以将其视为将区域文本移动到寄存器中。 C-u C-x r s r

C-x r s r stores a copy of the text of the region into the register named r. If the mark is inactive, Emacs first reactivates the mark where it was last set. The mark is deactivated at the end of this command. See The Mark and the Region. C-u C-x r s r, the same command with a prefix argument, copies the text into register r and deletes the text from the buffer as well; you can think of this as moving the region text into the register.

M-x append-to-register RET r将区域中文本的副本附加到已存储在名为r的寄存器中的文本。如果使用前缀参数调用,它将在将其附加到寄存器后删除该区域。该命令 prepend-to-register类似,只是它将区域文本添加 到寄存器中的文本之前,而不是 附加它。

M-x append-to-register RET r appends the copy of the text in the region to the text already stored in the register named r. If invoked with a prefix argument, it deletes the region after appending it to the register. The command prepend-to-register is similar, except that it prepends the region text to the text in the register instead of appending it.

append-to-register当您使用和 收集文本时prepend-to-register,您可能需要使用分隔符分隔各个收集的片段。在这种情况下,配置 a register-separator并将分隔符文本存储到该寄存器中。例如,要在收集过程中获取双换行符作为文本分隔符,可以使用以下设置。

When you are collecting text using append-to-register and prepend-to-register, you may want to separate individual collected pieces using a separator. In that case, configure a register-separator and store the separator text in to that register. For example, to get double newlines as text separator during the collection process, you can use the following setting.

(setq 寄存器分隔符?+)
(设置寄存器寄存器分隔符“\n\n”)
(setq register-separator ?+)
(set-register register-separator "\n\n")

C-x r i r将寄存器r中的文本插入到缓冲区中 。通常它会在文本后面留下点并在前面设置标记,而不激活它。使用前缀参数,它会将点放在文本之前,将标记放在文本之后。

C-x r i r inserts in the buffer the text from register r. Normally it leaves point after the text and sets the mark before, without activating it. With a prefix argument, it instead puts point before the text and the mark after.


14.3 在寄存器中保存矩形

14.3 Saving Rectangles in Registers

寄存器可以包含矩形而不是线性文本。有关如何在缓冲区中指定矩形的基本信息, 请参阅矩形。

A register can contain a rectangle instead of linear text. See Rectangles, for basic information on how to specify a rectangle in the buffer.

C-x r r r
C-x r r r

将区域矩形复制到寄存器r ( copy-rectangle-to-register) 中。对于前缀参数,也将其删除。

Copy the region-rectangle into register r (copy-rectangle-to-register). With prefix argument, delete it as well.

C-x r i r
C-x r i r

插入存储在寄存器r中的矩形(如果它包含矩形)( insert-register)。

Insert the rectangle stored in register r (if it contains a rectangle) (insert-register).

如果寄存器包含矩形,则 ( )命令(之前记录在寄存器中保存文本)会插入矩形而不是文本字符串。C-x r i rinsert-register

The C-x r i r (insert-register) command, previously documented in Saving Text in Registers, inserts a rectangle rather than a text string, if the register contains a rectangle.


14.4 在寄存器中保存窗口和框架配置

14.4 Saving Window and Frame Configurations in Registers

您可以将所选框架的窗口配置保存在寄存器中,甚至可以将所有框架中所有窗口的配置保存起来,并在以后恢复配置。有关窗口配置的信息, 请参阅窗口处理的便利功能。

You can save the window configuration of the selected frame in a register, or even the configuration of all windows in all frames, and restore the configuration later. See Convenience Features for Window Handling, for information about window configurations.

C-x r w r
C-x r w r

将所选帧窗口的状态保存在寄存器r ( window-configuration-to-register) 中。

Save the state of the selected frame’s windows in register r (window-configuration-to-register).

C-x r f r
C-x r f r

将所有框架的状态,包括其所有窗口(又名 框架集)保存在寄存器r ( frameset-to-register) 中。

Save the state of all frames, including all their windows (a.k.a. frameset), in register r (frameset-to-register).

用于恢复窗口或框架配置。这与用于恢复光标位置的命令相同。当您恢复框架配置时,任何未包含在配置中的现有框架将变得不可见。如果您想删除这些帧,请使用。 C-x r j rC-u C-x r j r

Use C-x r j r to restore a window or frame configuration. This is the same command used to restore a cursor position. When you restore a frame configuration, any existing frames not included in the configuration become invisible. If you wish to delete these frames instead, use C-u C-x r j r.


14.5 将数字保存在寄存器中

14.5 Keeping Numbers in Registers

有一些命令可以将数字存储在寄存器中,以十进制形式将数字插入到缓冲区中,以及将其递增。这些命令在键盘宏中很有用(请参阅键盘宏)。

There are commands to store a number in a register, to insert the number in the buffer in decimal, and to increment it. These commands can be useful in keyboard macros (see Keyboard Macros).

C-u number C-x r n r
C-u number C-x r n r

将数字存储到寄存器r ( number-to-register) 中。

Store number into register r (number-to-register).

C-u number C-x r + r
C-u number C-x r + r

如果r包含数字,则将该寄存器中的数字增加 number。请注意,如果r包含文本,则命令C-x r + ( increment-register) 的行为会有所不同。请参阅在寄存器中保存文本

If r contains a number, increment the number in that register by number. Note that command C-x r + (increment-register) behaves differently if r contains text. See Saving Text in Registers.

C-x r i r
C-x r i r

将寄存器r中的数字插入缓冲区。

Insert the number from register r into the buffer.

C-x r i与用于将任何其他类型的寄存器内容插入缓冲区的命令相同。 C-x r +如果没有数字参数,则寄存器值加 1;C-x r n如果没有数字参数,则在寄存器中存储零。

C-x r i is the same command used to insert any other sort of register contents into the buffer. C-x r + with no numeric argument increments the register value by 1; C-x r n with no numeric argument stores zero in the register.


14.6 将文件和缓冲区名称保存在寄存器中

14.6 Keeping File and Buffer Names in Registers

如果您经常访问某些文件名,则将其名称放入寄存器中可以更方便地访问它们。下面是用于将文件放入寄存器r 的Lisp 代码:

If you visit certain file names frequently, you can visit them more conveniently if you put their names in registers. Here’s the Lisp code used to put a file name into register r:

(设置寄存器r '(文件.名称))
(set-register r '(file . name))

例如,

For example,

(设置寄存器?z'(文件。“/gd/gnu/emacs/19.0/src/ChangeLog”))
(set-register ?z '(file . "/gd/gnu/emacs/19.0/src/ChangeLog"))

将文件名显示在寄存器'z'。

puts the file name shown in register ‘z’.

要访问名称位于寄存器r中的文件,请键入。 (这与用于跳转到某个位置或恢复帧配置的命令相同。) C-x r j r

To visit the file whose name is in register r, type C-x r j r. (This is the same command used to jump to a position or restore a frame configuration.)

同样,如果您经常访问某些缓冲区,则可以将它们的名称放入寄存器中。例如,如果您访问 '*留言*' 经常缓冲,您可以使用以下代码片段将该缓冲区放入 '' 登记:

Similarly, if there are certain buffers you visit frequently, you can put their names in registers. For instance, if you visit the ‘*Messages*’ buffer often, you can use the following snippet to put that buffer into the ‘m’ register:

(设置寄存器?m'(缓冲区。“*消息*”))
(set-register ?m '(buffer . "*Messages*"))

要切换到名称位于寄存器r中的缓冲区,请键入 。 C-x r j r

To switch to the buffer whose name is in register r, type C-x r j r.


14.7 键盘宏寄存器

14.7 Keyboard Macro Registers

如果您需要频繁执行键盘宏(请参阅键盘宏),则将其放入寄存器或保存它会更方便(请参阅命名和保存键盘宏)。 ( ) 将最后一个键盘宏存储在寄存器 r中。 C-x C-k x rkmacro-to-register

If you need to execute a keyboard macro (see Keyboard Macros) frequently, it is more convenient to put it in a register or save it (see Naming and Saving Keyboard Macros). C-x C-k x r (kmacro-to-register) stores the last keyboard macro in register r.

要执行寄存器r中的键盘宏,请键入。 (这与用于跳转到某个位置或恢复框架集的命令相同。) C-x r j r

To execute the keyboard macro in register r, type C-x r j r. (This is the same command used to jump to a position or restore a frameset.)


14.8 书签

14.8 Bookmarks

书签有点像寄存器,它们记录您可以跳转到的位置。与寄存器不同,它们的名称很长,并且会自动从一个 Emacs 会话持续到下一个会话。书签的典型用途是记录您在各种文件中阅读的位置。

Bookmarks are somewhat like registers in that they record positions you can jump to. Unlike registers, they have long names, and they persist automatically from one Emacs session to the next. The prototypical use of bookmarks is to record where you were reading in various files.

C-x r m RET
C-x r m RET

为所访问的文件设置书签。

Set the bookmark for the visited file, at point.

C-x r m bookmark RET
C-x r m bookmark RET

在点 ( ) 处设置名为 bookmark 的书签bookmark-set

Set the bookmark named bookmark at point (bookmark-set).

C-x r M bookmark RET
C-x r M bookmark RET

与 类似C-x r m,但不要覆盖现有书签。

Like C-x r m, but don’t overwrite an existing bookmark.

C-x r b bookmark RET
C-x r b bookmark RET

跳转到名为书签( bookmark-jump) 的书签。

Jump to the bookmark named bookmark (bookmark-jump).

C-x r l
C-x r l

列出所有书签 ( list-bookmarks)。

List all bookmarks (list-bookmarks).

M-x bookmark-save
M-x bookmark-save

将所有当前书签值保存在默认书签文件中。

Save all the current bookmark values in the default bookmark file.

要记录已访问文件中的当前位置,请使用命令 C-x r m,该命令使用已访问文件名作为默认书签名称来设置书签。如果您按照每个书签指向的文件来命名它,那么您可以使用 方便地重新访问这些文件中的任何一个C-x r b,并同时移动到书签的位置。

To record the current position in the visited file, use the command C-x r m, which sets a bookmark using the visited file name as the default for the bookmark name. If you name each bookmark after the file it points to, then you can conveniently revisit any of those files with C-x r b, and move to the position of the bookmark at the same time.

命令C-x r M( bookmark-set-no-overwrite) 的工作方式类似于C-x r m,但如果指定的书签已存在,它会发出错误信号,而不是覆盖它。

The command C-x r M (bookmark-set-no-overwrite) works like C-x r m, but it signals an error if the specified bookmark already exists, instead of overwriting it.

要在单独的缓冲区中显示所有书签的列表,请键入 C-x r l( list-bookmarks)。如果切换到该缓冲区,则可以使用它来编辑书签定义或注释书签。输入C-h m书签缓冲区以获取有关其特殊编辑命令的更多信息。

To display a list of all your bookmarks in a separate buffer, type C-x r l (list-bookmarks). If you switch to that buffer, you can use it to edit your bookmark definitions or annotate the bookmarks. Type C-h m in the bookmark buffer for more information about its special editing commands.

当您终止 Emacs 时,如果您更改了任何书签值,Emacs 会保存您的书签。您还可以随时使用该M-x bookmark-save命令保存书签。书签保存到文件中〜/.emacs.d/书签(为了与旧版本的 Emacs 兼容,如果您有一个名为〜/ .emacs.bmk,而是使用它)。书签命令会自动加载默认书签文件。这种保存和加载就是书签从一个 Emacs 会话持续到下一个会话的方式。

When you kill Emacs, Emacs saves your bookmarks, if you have changed any bookmark values. You can also save the bookmarks at any time with the M-x bookmark-save command. Bookmarks are saved to the file ~/.emacs.d/bookmarks (for compatibility with older versions of Emacs, if you have a file named ~/.emacs.bmk, that is used instead). The bookmark commands load your default bookmark file automatically. This saving and loading is how bookmarks persist from one Emacs session to the next.

如果将该变量设置bookmark-save-flag为 1,则每个设置书签的命令也会保存您的书签;这样,即使 Emacs 崩溃,您也不会丢失任何书签值。该值(如果是数字)表示保存之间应进行多少次书签修改。如果将此变量设置为nil,则 Emacs 仅在显式使用时才保存书签M-x bookmark-save

If you set the variable bookmark-save-flag to 1, each command that sets a bookmark will also save your bookmarks; this way, you don’t lose any bookmark values even if Emacs crashes. The value, if a number, says how many bookmark modifications should go by between saving. If you set this variable to nil, Emacs only saves bookmarks if you explicitly use M-x bookmark-save.

该变量bookmark-default-file指定默认保存书签的文件。

The variable bookmark-default-file specifies the file in which to save bookmarks by default.

如果将该变量设置bookmark-use-annotationst,设置书签将查询注释。如果书签有注释,当您跳转到书签时,它会自动显示在单独的窗口中。

If you set the variable bookmark-use-annotations to t, setting a bookmark will query for an annotation. If a bookmark has an annotation, it is automatically shown in a separate window when you jump to the bookmark.

书签位置值与周围上下文一起保存,因此 bookmark-jump即使文件略有修改也可以找到正确的位置。该变量bookmark-search-size表示在书签位置的每一侧要记录多少个上下文字符。 (在访问加密文件的缓冲区中,无论此变量的值如何,书签文件中都不会保存任何上下文。)

Bookmark position values are saved with surrounding context, so that bookmark-jump can find the proper position even if the file is modified slightly. The variable bookmark-search-size says how many characters of context to record on each side of the bookmark’s position. (In buffers that are visiting encrypted files, no context is saved in the bookmarks file no matter the value of this variable.)

以下是一些用于处理书签的附加命令:

Here are some additional commands for working with bookmarks:

M-x bookmark-load RET filename RET
M-x bookmark-load RET filename RET

加载名为filename的文件,其中包含书签值列表。除了默认书签文件之外,您还可以使用此命令以及bookmark-write来处理其他书签值文件。

Load a file named filename that contains a list of bookmark values. You can use this command, as well as bookmark-write, to work with other files of bookmark values in addition to your default bookmark file.

M-x bookmark-write RET filename RET
M-x bookmark-write RET filename RET

将所有当前书签值保存在文件filename中。

Save all the current bookmark values in the file filename.

M-x bookmark-delete RET bookmark RET
M-x bookmark-delete RET bookmark RET

删除名为 bookmark 的书签

Delete the bookmark named bookmark.

M-x bookmark-insert-location RET bookmark RET
M-x bookmark-insert-location RET bookmark RET

在缓冲区中插入书签书签指向的文件的名称 。

Insert in the buffer the name of the file that bookmark bookmark points to.

M-x bookmark-insert RET bookmark RET
M-x bookmark-insert RET bookmark RET

将书签书签指向的文件的 内容插入到缓冲区中。

Insert in the buffer the contents of the file that bookmark bookmark points to.


15 控制显示

15 Controlling the Display

由于窗口中只能容纳大缓冲区的一部分,因此 Emacs 只能显示其中的一部分。本章介绍的命令和变量可让您指定要查看文本的哪一部分以及文本的显示方式。

Since only part of a large buffer fits in the window, Emacs has to show only a part of it. This chapter describes commands and variables that let you specify which part of the text you want to see, and how the text is displayed.


15.1 滚动

15.1 Scrolling

如果窗口太小而无法显示其缓冲区中的所有文本,则它仅显示其中的一部分。 滚动命令更改缓冲区的显示部分。

If a window is too small to display all the text in its buffer, it displays only a portion of it. Scrolling commands change which portion of the buffer is displayed.

向前或向上滚动可前进窗口中显示的缓冲区部分;同样,它相对于窗口向上移动缓冲区文本。向后或向下滚动会显示缓冲区的较早部分,并相对于窗口向下移动文本。

Scrolling forward or up advances the portion of the buffer displayed in the window; equivalently, it moves the buffer text upwards relative to the window. Scrolling backward or down displays an earlier portion of the buffer, and moves the text downwards relative to the window.

在 Emacs 中,向上或向下滚动是指文本在窗口中移动的方向,而不是窗口相对于文本移动的方向。在“向上滚动”和“向下滚动”的现代含义广泛传播之前,Emacs 就采用了这个术语。因此,PageDown 出现了 Emacs 意义上的向上滚动 的奇怪结果。

In Emacs, scrolling up or down refers to the direction that the text moves in the window, not the direction that the window moves relative to the text. This terminology was adopted by Emacs before the modern meaning of “scrolling up” and “scrolling down” became widespread. Hence, the strange result that PageDown scrolls up in the Emacs sense.

窗口中显示的缓冲区部分始终包含点。如果您将点移过窗口的底部或顶部,则会自动发生滚动,将其带回到屏幕上(请参阅自动滚动)。您还可以使用以下命令显式滚动:

The portion of a buffer displayed in a window always contains point. If you move point past the bottom or top of the window, scrolling occurs automatically to bring it back onscreen (see Automatic Scrolling). You can also scroll explicitly with these commands:

C-v
C-v
PageDown
PageDown
next
next

向前滚动几乎整个窗口 ( scroll-up-command)。

Scroll forward by nearly a full window (scroll-up-command).

M-v
M-v
PageUp
PageUp
prior
prior

向后滚动 ( scroll-down-command)。

Scroll backward (scroll-down-command).

C-v( scroll-up-command) 向前滚动几乎整个窗口的高度。效果是把窗口底部的两条线放在顶部,后面是以前不可见的线。如果点位于从顶部滚动的文本中,则它最终会出现在窗口新的最上面一行。PageDown(或)键 next相当于C-v

C-v (scroll-up-command) scrolls forward by nearly the whole window height. The effect is to take the two lines at the bottom of the window and put them at the top, followed by lines that were not previously visible. If point was in the text that scrolled off the top, it ends up on the window’s new topmost line. The PageDown (or next) key is equivalent to C-v.

M-v( scroll-down-command) 以类似方式向后滚动。PageUp(或)键prior相当于 M-v

M-v (scroll-down-command) scrolls backward in a similar way. The PageUp (or prior) key is equivalent to M-v.

这些滚动命令留下的重叠行数由变量 控制next-screen-context-lines,其默认值为 2。您可以为命令提供数字前缀参数n,以滚动n行; Emacs 尝试保持点不变,以便文本和点一起向上或向下移动。 C-v与否定论点是一样的M-v,反之亦然。

The number of lines of overlap left by these scroll commands is controlled by the variable next-screen-context-lines, whose default value is 2. You can supply the commands with a numeric prefix argument, n, to scroll by n lines; Emacs attempts to leave point unchanged, so that the text and point move up or down together. C-v with a negative argument is like M-v and vice versa.

默认情况下,如果由于窗口已到达缓冲区的开头或结尾而无法再滚动,则这些命令会发出错误信号(通过发出蜂鸣声或闪烁屏幕)。如果将变量更改scroll-error-top-bottomt,这些命令会将点移动到尽可能远的位置。如果点已经存在,则命令发出错误信号。

By default, these commands signal an error (by beeping or flashing the screen) if no more scrolling is possible, because the window has reached the beginning or end of the buffer. If you change the variable scroll-error-top-bottom to t, these commands move point to the farthest possible position. If point is already there, the commands signal an error.

一些用户喜欢滚动命令将指针保持在同一屏幕位置,以便滚动回同一屏幕可以方便地将指针返回到其原始位置。您可以通过变量启用此行为scroll-preserve-screen-position。如果值为t,则每当滚动命令将光标移出窗口时,Emacs 都会调整 point 以使光标保持在同一屏幕位置,而不是将其移动到最上面或最下面的行。对于任何其他非nil值,即使滚动命令在窗口中留下 point,Emacs 也会以这种方式调整 point。该变量影响本节中记录的所有滚动命令,以及使用鼠标滚轮滚动(请参阅用于编辑的鼠标命令);一般来说,它会影响任何具有非属性的命令nil scroll-command。请参阅Emacs Lisp 参考手册中的属性列表。当调用这些命令之一且为非命令时,同一属性还会导致 Emacs 不退出增量搜索(请参阅不退出增量搜索)。 isearch-allow-scrollnil

Some users like scroll commands to keep point at the same screen position, so that scrolling back to the same screen conveniently returns point to its original position. You can enable this behavior via the variable scroll-preserve-screen-position. If the value is t, Emacs adjusts point to keep the cursor at the same screen position whenever a scroll command moves it off-window, rather than moving it to the topmost or bottommost line. With any other non-nil value, Emacs adjusts point this way even if the scroll command leaves point in the window. This variable affects all the scroll commands documented in this section, as well as scrolling with the mouse wheel (see Mouse Commands for Editing); in general, it affects any command that has a non-nil scroll-command property. See Property Lists in The Emacs Lisp Reference Manual. The same property also causes Emacs not to exit incremental search when one of these commands is invoked and isearch-allow-scroll is non-nil (see Not Exiting Incremental Search).

有时,特别是当您按住C-v 和等键M-v激活键盘自动重复时,Emacs 无法跟上所请求的快速滚动速度;显示不会更新,并且 Emacs 可能会在相当长的时间内对输入没有响应。您可以通过将变量设置 fast-but-imprecise-scrolling为非值来应对这种缓慢的情况nil。这指示滚动命令不要对滚动的任何无字体文本进行字体化(请参阅字体锁定模式),而是假设它具有默认外观。当使用的面大小不一样时,这可能会导致 Emacs 滚动到有些错误的缓冲区位置,即使是单个(即没有自动重复)滚动操作也是如此。

Sometimes, particularly when you hold down keys such as C-v and M-v, activating keyboard auto-repeat, Emacs fails to keep up with the rapid rate of scrolling requested; the display doesn’t update and Emacs can become unresponsive to input for quite a long time. You can counter this sluggishness by setting the variable fast-but-imprecise-scrolling to a non-nil value. This instructs the scrolling commands not to fontify (see Font Lock mode) any unfontified text they scroll over, instead to assume it has the default face. This can cause Emacs to scroll to somewhat wrong buffer positions when the faces in use are not all the same size, even with single (i.e., without auto-repeat) scrolling operations.

作为设置的替代方法,fast-but-imprecise-scrolling您可能更愿意启用 jit-lock 延迟字体化(请参阅字体锁定模式)。为此,请自定义jit-lock-defer-time为一个较小的正数,例如 0.25,如果您打字速度很快,甚至可以自定义为 0.1。当您按住 时,这可以减少滚动的不稳定C-v,但是在滚动到缓冲区的新部分的任何操作之后,窗口内容将暂时取消字体显示。

As an alternative to setting fast-but-imprecise-scrolling you might prefer to enable jit-lock deferred fontification (see Font Lock mode). To do this, customize jit-lock-defer-time to a small positive number such as 0.25, or even 0.1 if you type quickly. This gives you less jerky scrolling when you hold down C-v, but the window contents after any action which scrolls into a fresh portion of the buffer will be momentarily unfontified.

最后,这些变量的第三个替代方案是 redisplay-skip-fontification-on-input。如果此变量为非 - nil,则在有待输入的情况下跳过一些字体。这通常不会影响显示,因为如果输入待处理,重新显示无论如何都会被完全跳过,但它可以通过避免不必要的字体来使滚动更平滑。

Finally, a third alternative to these variables is redisplay-skip-fontification-on-input. If this variable is non-nil, skip some fontifications if there’s input pending. This usually does not affect the display because redisplay is completely skipped anyway if input was pending, but it can make scrolling smoother by avoiding unnecessary fontification.

命令M-x scroll-up和 的M-x scroll-down行为类似于scroll-up-commandscroll-down-command,但它们不服从命令scroll-error-top-bottom。在 Emacs 24 之前,这些是用于上下滚动的默认命令。命令M-x scroll-up-line并将M-x scroll-down-line 当前窗口一次滚动一行。如果您打算使用这些命令中的任何一个,您可能需要为它们提供键绑定(请参阅在初始化文件中重新绑定键)。

The commands M-x scroll-up and M-x scroll-down behave similarly to scroll-up-command and scroll-down-command, except they do not obey scroll-error-top-bottom. Prior to Emacs 24, these were the default commands for scrolling up and down. The commands M-x scroll-up-line and M-x scroll-down-line scroll the current window by one line at a time. If you intend to use any of these commands, you might want to give them key bindings (see Rebinding Keys in Your Init File).


15.2 居中

15.2 Recentering

C-l
C-l

滚动选定的窗口,使当前行成为最中心的文本行;在随后的连续调用中,使当前行成为顶行、底行,依此类推。也可能重新显示屏幕 ( recenter-top-bottom)。

Scroll the selected window so the current line is the center-most text line; on subsequent consecutive invocations, make the current line the top line, the bottom line, and so on in cyclic order. Possibly redisplay the screen too (recenter-top-bottom).

C-M-S-l
C-M-S-l

滚动另一个窗口;这相当于C-l作用于另一个窗口。

Scroll the other window; this is equivalent to C-l acting on the other window.

M-x recenter
M-x recenter

滚动选定的窗口,使当前行成为最中心的文本行。也可能重新显示屏幕。

Scroll the selected window so the current line is the center-most text line. Possibly redisplay the screen too.

C-M-l
C-M-l

试探性地滚动以将有用的信息显示到屏幕上 ( reposition-window)。

Scroll heuristically to bring useful information onto the screen (reposition-window).

C-l( recenter-top-bottom) 命令使选定的窗口居中 ,滚动它,使当前屏幕行恰好位于窗口的中心,或尽可能靠近中心。

The C-l (recenter-top-bottom) command recenters the selected window, scrolling it so that the current screen line is exactly in the center of the window, or as close to the center as possible.

C-l连续键入两次 ( C-l C-l) 会滚动窗口,以便该点位于屏幕的最上面一行。键入第三个C-l 会滚动窗口,使该点位于最底部的屏幕行。每个连续C-l循环都经过这三个位置。

Typing C-l twice in a row (C-l C-l) scrolls the window so that point is on the topmost screen line. Typing a third C-l scrolls the window so that point is on the bottom-most screen line. Each successive C-l cycles through these three positions.

您可以通过自定义列表变量来更改循环顺序 recenter-positions。每个列表元素应该是符号 topmiddle、 或bottom、 或数字;整数表示将该行移动到指定的屏幕行,而 0.0 到 1.0 之间的浮点数则指定距窗口顶部的屏幕空间的百分比。默认值 (middle top bottom)是上述循环顺序。此外,如果将变量更改scroll-margin为非零值n,则始终 在点和窗口顶部或底部之间C-l留下至少n 条屏幕线(请参阅自动滚动)。

You can change the cycling order by customizing the list variable recenter-positions. Each list element should be the symbol top, middle, or bottom, or a number; an integer means to move the line to the specified screen line, while a floating-point number between 0.0 and 1.0 specifies a percentage of the screen space from the top of the window. The default, (middle top bottom), is the cycling order described above. Furthermore, if you change the variable scroll-margin to a non-zero value n, C-l always leaves at least n screen lines between point and the top or bottom of the window (see Automatic Scrolling).

您还可以给出C-l前缀参数。一个简单的前缀参数C-u C-l,只是将显示点的线居中。正参数n将显示点n 的线从窗口顶部向下移动。零参数将点的线移动到窗口的顶部。负参数 - n将点的线从窗口底部移动n行。当给定参数时,C-l不会清除屏幕或循环显示不同的屏幕位置。

You can also give C-l a prefix argument. A plain prefix argument, C-u C-l, simply recenters the line showing point. A positive argument n moves line showing point n lines down from the top of the window. An argument of zero moves point’s line to the top of the window. A negative argument −n moves point’s line n lines from the bottom of the window. When given an argument, C-l does not clear the screen or cycle through different screen positions.

如果变量recenter-redisplay具有非nil 值,则每次调用C-l也会清除并重新显示屏幕;特殊值tty(默认值)表示仅在文本终端框架上执行此操作。如果屏幕因任何原因出现乱码,重新显示非常有用(请参阅屏幕上的垃圾)。

If the variable recenter-redisplay has a non-nil value, each invocation of C-l also clears and redisplays the screen; the special value tty (the default) says to do this on text-terminal frames only. Redisplaying is useful in case the screen becomes garbled for any reason (see Garbage on the Screen).

更原始的命令的M-x recenter行为类似于 recenter-top-bottom,但不会在屏幕位置之间循环。

The more primitive command M-x recenter behaves like recenter-top-bottom, but does not cycle among screen positions.

C-M-l( reposition-window) 试探性地滚动当前窗口,旨在将有用的信息显示到屏幕上。例如,在 Lisp 文件中,如果可能,此命令会尝试将整个当前 defun 显示到屏幕上。

C-M-l (reposition-window) scrolls the current window heuristically in a way designed to get useful information onto the screen. For example, in a Lisp file, this command tries to get the entire current defun onto the screen if possible.


15.3 自动滚动

15.3 Automatic Scrolling

当点移出文本的可见部分时,Emacs 会执行自动滚动。通常,自动滚动中心垂直指向窗口,但有多种方法可以改变这种行为。

Emacs performs automatic scrolling when point moves out of the visible portion of the text. Normally, automatic scrolling centers point vertically in the window, but there are several ways to alter this behavior.

如果您设置scroll-conservatively为一个较小的数字n,那么将 point 稍微移离屏幕(不超过n 行)会导致 Emacs 滚动到足以将 point 返回到屏幕上;如果这样做无法使点可见,Emacs 会滚动到窗口中心点。如果设置的 scroll-conservatively数字较大(大于 100),则无论点移动多远,自动滚动都不会以点为中心; Emacs 总是滚动文本,使其足以使点进入视图,根据滚动方向,在窗口的顶部或底部。默认情况下,scroll-conservatively为 0,这意味着始终将点置于窗口的中心。这就是说,在迷你缓冲区窗口中,默认情况下滚动始终是保守的,因为scroll-minibuffer-conservatively是 non- nil,它优先于scroll-conservatively

If you set scroll-conservatively to a small number n, then moving point just a little off the screen (no more than n lines) causes Emacs to scroll just enough to bring point back on screen; if doing so fails to make point visible, Emacs scrolls just far enough to center point in the window. If you set scroll-conservatively to a large number (larger than 100), automatic scrolling never centers point, no matter how far point moves; Emacs always scrolls text just enough to bring point into view, either at the top or bottom of the window depending on the scroll direction. By default, scroll-conservatively is 0, which means to always center point in the window. This said, in minibuffer windows, scrolling is always conservative by default because scroll-minibuffer-conservatively is non-nil, which takes precedence over scroll-conservatively.

控制自动滚动的另一种方法是自定义变量scroll-step。它的值决定了当点移出屏幕时自动滚动的行数。如果滚动该行数无法使点重新回到视图中,则点会居中。默认值为零,这(默认情况下)导致滚动后点始终居中。

Another way to control automatic scrolling is to customize the variable scroll-step. Its value determines the number of lines by which to automatically scroll, when point moves off the screen. If scrolling by that number of lines fails to bring point back into view, point is centered instead. The default value is zero, which (by default) causes point to always be centered after scrolling.

第三种控制自动滚动的方法是自定义变量scroll-up-aggressivelyscroll-down-aggressively,直接指定滚动后点的垂直位置。的值 scroll-up-aggressively应该是nil(默认值),或者是 0 到 1 之间的浮点数f。后者意味着当 point 低于窗口底部边缘时(即向前滚动),Emacs 滚动窗口,使得 point 为f 窗口部分距离窗口底部边缘的高度。因此,较大的 f意味着更积极的滚动:更多新文本进入视图。默认值nil等于 0.5。

A third way to control automatic scrolling is to customize the variables scroll-up-aggressively and scroll-down-aggressively, which directly specify the vertical position of point after scrolling. The value of scroll-up-aggressively should be either nil (the default), or a floating point number f between 0 and 1. The latter means that when point goes below the bottom window edge (i.e., scrolling forward), Emacs scrolls the window so that point is f parts of the window height from the bottom window edge. Thus, larger f means more aggressive scrolling: more new text is brought into view. The default value, nil, is equivalent to 0.5.

同样,scroll-down-aggressively当点位于窗口顶部边缘上方(即向后滚动)时使用。该值指定滚动后点距离窗口上边距的距离。因此,与 一样scroll-up-aggressively,值越大越激进。

Likewise, scroll-down-aggressively is used when point goes above the top window edge (i.e., scrolling backward). The value specifies how far point should be from the top margin of the window after scrolling. Thus, as with scroll-up-aggressively, a larger value is more aggressive.

请注意,变量scroll-conservativelyscroll-stepscroll-up-aggressively/ scroll-down-aggressively以矛盾的方式控制自动滚动。因此,您应该选择最多其中一种方法来自定义自动滚动。如果您自定义多个变量,优先级顺序为: scroll-conservatively,然后scroll-step,最后 scroll-up-aggressively/ scroll-down-aggressively

Note that the variables scroll-conservatively, scroll-step, and scroll-up-aggressively / scroll-down-aggressively control automatic scrolling in contradictory ways. Therefore, you should pick no more than one of these methods to customize automatic scrolling. In case you customize multiple variables, the order of priority is: scroll-conservatively, then scroll-step, and finally scroll-up-aggressively / scroll-down-aggressively.

该变量scroll-margin限制点距离窗口顶部或底部的距离(即使激进滚动指定的分数f大于顶部和底部边距之间的窗口部分)。其值为屏幕行数;如果点位于窗口顶部或底部的那么多行内,Emacs 会执行自动滚动。默认情况下, scroll-margin为 0。默认情况下,有效边距大小限制为窗口高度的四分之一,但可以通过自定义将此限制增加到一半(或减少到零) maximum-scroll-margin

The variable scroll-margin restricts how close point can come to the top or bottom of a window (even if aggressive scrolling specifies a fraction f that is larger than the window portion between the top and the bottom margins). Its value is a number of screen lines; if point comes within that many lines of the top or bottom of the window, Emacs performs automatic scrolling. By default, scroll-margin is 0. The effective margin size is limited to a quarter of the window height by default, but this limit can be increased up to half (or decreased down to zero) by customizing maximum-scroll-margin.


15.4 水平滚动

15.4 Horizontal Scrolling

水平滚动意味着将窗口内的所有行向侧面移动,以便不显示靠近左边距的一些文本。当窗口中的文本水平滚动时,文本行会被截断而不是连续(请参阅行截断)。如果窗口显示截断的行,只要点移出屏幕的左边缘或右边缘,Emacs 就会执行自动水平滚动。默认情况下,窗口中的所有行都会一起水平滚动,但如果将该变量设置 auto-hscroll-mode为特殊值current-line,则只有显示光标的行才会滚动。要完全禁用自动水平滚动,请将变量设置 auto-hscroll-modenil。请注意,当自动水平滚动关闭时,如果点移出屏幕边缘,光标会消失以表明这一点。 (在文本终端上,光标留在边缘。)

Horizontal scrolling means shifting all the lines sideways within a window, so that some of the text near the left margin is not displayed. When the text in a window is scrolled horizontally, text lines are truncated rather than continued (see Line Truncation). If a window shows truncated lines, Emacs performs automatic horizontal scrolling whenever point moves off the left or right edge of the screen. By default, all the lines in the window are scrolled horizontally together, but if you set the variable auto-hscroll-mode to the special value of current-line, only the line showing the cursor will be scrolled. To disable automatic horizontal scrolling entirely, set the variable auto-hscroll-mode to nil. Note that when the automatic horizontal scrolling is turned off, if point moves off the edge of the screen, the cursor disappears to indicate that. (On text terminals, the cursor is left at the edge instead.)

该变量hscroll-margin控制在自动滚动发生之前点距离窗口左边缘和右边缘的距离。它以列为单位进行测量。例如,如果值为 5,则在边缘的 5 列内移动点会导致远离该边缘的水平滚动。

The variable hscroll-margin controls how close point can get to the window’s left and right edges before automatic scrolling occurs. It is measured in columns. For example, if the value is 5, then moving point within 5 columns of an edge causes horizontal scrolling away from that edge.

该变量hscroll-step确定当点太靠近边缘时要滚动窗口的列数。零(默认值)意味着在窗口内水平居中。正整数值指定要滚动的列数。浮点数(其值应介于 0 和 1 之间)指定要滚动的窗口宽度的分数。

The variable hscroll-step determines how many columns to scroll the window when point gets too close to the edge. Zero, the default value, means to center point horizontally within the window. A positive integer value specifies the number of columns to scroll by. A floating-point number (whose value should be between 0 and 1) specifies the fraction of the window’s width to scroll by.

您还可以使用以下命令执行显式水平滚动:

You can also perform explicit horizontal scrolling with the following commands:

C-x <
C-x <

将当前窗口中的文本向左滚动 ( scroll-left)。

Scroll text in current window to the left (scroll-left).

C-x >
C-x >

向右滚动 ( scroll-right)。

Scroll to the right (scroll-right).

C-x <( scroll-left) 将选定窗口中的文本向左滚动窗口的整个宽度(减去两列)。 (换句话说,窗口中的文本相对于窗口向左移动。)使用数字参数n,它会滚动n 列。

C-x < (scroll-left) scrolls text in the selected window to the left by the full width of the window, less two columns. (In other words, the text in the window moves left relative to the window.) With a numeric argument n, it scrolls by n columns.

如果文本向左滚动,并且 point 移出窗口的左边缘,则光标将冻结在窗口的左边缘,直到 point 移回到文本的显示部分。这与 的当前设置无关 auto-hscroll-mode,对于向左滚动的文本,该设置仅影响窗口右边缘的行为。

If the text is scrolled to the left, and point moves off the left edge of the window, the cursor will freeze at the left edge of the window, until point moves back to the displayed portion of the text. This is independent of the current setting of auto-hscroll-mode, which, for text scrolled to the left, only affects the behavior at the right edge of the window.

C-x >( scroll-right) 类似地向右滚动。窗口正常显示后就不能再向右滚动,每一行都从窗口的左边距开始;尝试这样做没有效果。这意味着您不必精确计算C-x >;的参数。任何足够大的参数都会恢复正常显示。

C-x > (scroll-right) scrolls similarly to the right. The window cannot be scrolled any farther to the right once it is displayed normally, with each line starting at the window’s left margin; attempting to do so has no effect. This means that you don’t have to calculate the argument precisely for C-x >; any sufficiently large argument will restore the normal display.

如果您使用这些命令水平滚动窗口,则会设置自动水平滚动的下限。自动滚动将继续滚动窗口,但永远不会比您之前通过 设置的量更靠右scroll-left。当 auto-hscroll-mode设置为时current-line,除显示光标的行之外的所有行都将滚动该最小量。

If you use those commands to scroll a window horizontally, that sets a lower bound for automatic horizontal scrolling. Automatic scrolling will continue to scroll the window, but never farther to the right than the amount you previously set by scroll-left. When auto-hscroll-mode is set to current-line, all the lines other than the one showing the cursor will be scrolled by that minimal amount.


15.5 缩小范围

15.5 Narrowing

缩小意味着集中于缓冲区的某些部分,使其余部分暂时无法访问。您仍然可以到达的部分称为可访问部分。取消缩小,使整个缓冲区再次可访问,称为加宽。缓冲区中有效的缩小范围称为缓冲区的限制

Narrowing means focusing in on some portion of the buffer, making the rest temporarily inaccessible. The portion which you can still get to is called the accessible portion. Canceling the narrowing, which makes the entire buffer once again accessible, is called widening. The bounds of narrowing in effect in a buffer are called the buffer’s restriction.

通过消除混乱,缩小范围可以更容易地集中在单个子例程或段落上。它还可用于限制替换命令或重复键盘宏的操作范围。

Narrowing can make it easier to concentrate on a single subroutine or paragraph by eliminating clutter. It can also be used to limit the range of operation of a replace command or repeating keyboard macro.

C-x n n
C-x n n

缩小到点和标记 ( narrow-to-region) 之间。

Narrow down to between point and mark (narrow-to-region).

C-x n w
C-x n w

加宽以使整个缓冲区再次可访问 ( widen)。

Widen to make the entire buffer accessible again (widen).

C-x n p
C-x n p

缩小到当前页面 ( narrow-to-page)。

Narrow down to the current page (narrow-to-page).

C-x n d
C-x n d

缩小到当前 defun ( narrow-to-defun)。

Narrow down to the current defun (narrow-to-defun).

当您缩小到缓冲区的一部分时,该部分似乎就是全部。您看不到其余部分,无法进入其中(动作命令不会超出可访问部分),也无法以任何方式更改它。但是,它并没有消失,如果您保存文件,所有无法访问的文本都将被保存。这个单词 '狭窄的每当缩小生效时,都会出现在模式行中。

When you have narrowed down to a part of the buffer, that part appears to be all there is. You can’t see the rest, you can’t move into it (motion commands won’t go outside the accessible part), you can’t change it in any way. However, it is not gone, and if you save the file all the inaccessible text will be saved. The word ‘Narrow’ appears in the mode line whenever narrowing is in effect.

主要缩小命令是C-x n n( narrow-to-region)。它设置当前缓冲区的限制,以便当前区域中的文本仍然可访问,但该区域之前或之后的所有文本都不可访问。点和标记不变。

The primary narrowing command is C-x n n (narrow-to-region). It sets the current buffer’s restrictions so that the text in the current region remains accessible, but all text before the region or after the region is inaccessible. Point and mark do not change.

或者,使用C-x n p( narrow-to-page) 缩小到当前页面。有关页面的定义, 请参阅PagesC-x n d 。 ( narrow-to-defun) 缩小到包含 defun 的点(请参阅顶级定义或 Defuns)。

Alternatively, use C-x n p (narrow-to-page) to narrow down to the current page. See Pages, for the definition of a page. C-x n d (narrow-to-defun) narrows down to the defun containing point (see Top-Level Definitions, or Defuns).

取消缩小的方法是用C-x n w ( widen)扩大。这使得缓冲区中的所有文本都可以再次访问。

The way to cancel narrowing is to widen with C-x n w (widen). This makes all text in the buffer accessible again.

您可以使用该命令获取有关您缩小到缓冲区哪一部分的信息C-x =。请参阅光标位置信息

You can get information on what part of the buffer you are narrowed down to using the C-x = command. See Cursor Position Information.

因为缩小很容易让不理解它的用户感到困惑,所以 narrow-to-region通常是一个禁用的命令。尝试使用此命令会要求确认并为您提供启用它的选项;如果启用该命令,则不再需要确认。请参阅禁用命令

Because narrowing can easily confuse users who do not understand it, narrow-to-region is normally a disabled command. Attempting to use this command asks for confirmation and gives you the option of enabling it; if you enable the command, confirmation will no longer be required for it. See Disabling Commands.


15.6 视图模式

15.6 View Mode

查看模式是一种次要模式,可让您按顺序整屏扫描缓冲区。它提供了方便地滚动缓冲区的命令,但不提供更改缓冲区的命令。除了常用的 Emacs 光标移动命令之外,您还可以键入SPC向前滚动一窗口、向后滚动以及开始增量搜索。 S-SPCDELs

View mode is a minor mode that lets you scan a buffer by sequential screenfuls. It provides commands for scrolling through the buffer conveniently but not for changing it. Apart from the usual Emacs cursor motion commands, you can type SPC to scroll forward one windowful, S-SPC or DEL to scroll backward, and s to start an incremental search.

键入q( View-quit) 将禁用查看模式,并切换回启用查看模式之前的缓冲区和位置。键入 e( View-exit) 将禁用查看模式,保留当前缓冲区和位置。

Typing q (View-quit) disables View mode, and switches back to the buffer and position before View mode was enabled. Typing e (View-exit) disables View mode, keeping the current buffer and position.

M-x view-buffer提示现有的 Emacs 缓冲区,切换到它,并启用查看模式。 M-x view-file提示输入文件并在启用查看模式的情况下访问该文件。

M-x view-buffer prompts for an existing Emacs buffer, switches to it, and enables View mode. M-x view-file prompts for a file and visits it with View mode enabled.


15.7 跟随模式

15.7 Follow Mode

跟随模式是一种次要模式,它使两个显示相同缓冲区的窗口作为单个高虚拟窗口滚动。要使用“跟随”模式,请转至只有一个窗口的框架,使用 将其拆分为两个并排的窗口C-x 3,然后键入M-x follow-mode。从那时起,您可以在两个窗口之一中编辑缓冲区,或滚动其中一个;另一个窗口紧随其后。

Follow mode is a minor mode that makes two windows, both showing the same buffer, scroll as a single tall virtual window. To use Follow mode, go to a frame with just one window, split it into two side-by-side windows using C-x 3, and then type M-x follow-mode. From then on, you can edit the buffer in either of the two windows, or scroll either one; the other window follows it.

在“跟随”模式下,如果将点移出一个窗口中可见的部分并移入另一个窗口中可见的部分,则会选择另一个窗口 - 再次将这两个窗口视为一个大窗口的一部分。

In Follow mode, if you move point outside the portion visible in one window and into the portion visible in the other window, that selects the other window—again, treating the two as if they were parts of one large window.

要关闭跟随模式,请M-x follow-mode再次键入。

To turn off Follow mode, type M-x follow-mode a second time.


15.8 文本面孔

15.8 Text Faces

Emacs 可以以多种不同的样式显示文本,称为 faces。每个面都可以指定各种面属性,例如字体、高度、粗细、倾斜、前景色和背景色以及下划线或上划线。大多数主要模式通过字体锁定模式自动将面孔分配给文本。有关如何分配这些面的更多信息, 请参阅字体锁定模式。

Emacs can display text in several different styles, called faces. Each face can specify various face attributes, such as the font, height, weight, slant, foreground and background color, and underlining or overlining. Most major modes assign faces to the text automatically, via Font Lock mode. See Font Lock mode, for more information about how these faces are assigned.

要查看当前定义的面及其外观,请键入M-x list-faces-display。使用前缀参数,这会提示输入正则表达式,并仅显示名称与该正则表达式匹配的面孔(请参阅正则表达式的语法)。

To see what faces are currently defined, and what they look like, type M-x list-faces-display. With a prefix argument, this prompts for a regular expression, and displays only faces with names matching that regular expression (see Syntax of Regular Expressions).

一张特定的脸在不同的框架中看起来可能会有所不同。例如,某些文本终端不支持所有面部属性,特别是字体、高度和宽度,并且某些文本终端支持有限的颜色范围。此外,出于易读性的原因,大多数 Emacs 面孔都被定义为它们的属性在浅色和深色框架背景上有所不同。默认情况下,Emacs 根据帧的当前背景颜色自动选择在每个帧上显示哪组面部属性。但是,您可以通过为变量指定frame-background-mode 非值来覆盖此设置nil。值dark使 Emacs 将所有帧视为具有深色背景,而值使其将 light所有帧视为具有浅色背景。

It’s possible for a given face to look different in different frames. For instance, some text terminals do not support all face attributes, particularly font, height, and width, and some support a limited range of colors. In addition, most Emacs faces are defined so that their attributes are different on light and dark frame backgrounds, for reasons of legibility. By default, Emacs automatically chooses which set of face attributes to display on each frame, based on the frame’s current background color. However, you can override this by giving the variable frame-background-mode a non-nil value. A value of dark makes Emacs treat all frames as if they have a dark background, whereas a value of light makes it treat all frames as if they have a light background.

您可以自定义面孔以更改其属性,并保存这些自定义以供将来的 Emacs 会话使用。有关详细信息,请参阅自定义面孔

You can customize a face to alter its attributes, and save those customizations for future Emacs sessions. See Customizing Faces, for details.

default是显示文本的默认值,并且它的所有属性都是指定的。它的背景颜色也用作框架的背景颜色。请参阅面部颜色

The default face is the default for displaying text, and all of its attributes are specified. Its background color is also used as the frame’s background color. See Colors for Faces.

另一种特殊的面孔是cursor脸。在图形显示上,该面的背景颜色用于绘制文本光标。这张脸的其他属性都没有任何效果;光标下文本的前景色取自底层文本的背景色。在文本终端上,文本光标的外观由终端决定,而不是由面部决定cursor

Another special face is the cursor face. On graphical displays, the background color of this face is used to draw the text cursor. None of the other attributes of this face have any effect; the foreground color for text under the cursor is taken from the background color of the underlying text. On text terminals, the appearance of the text cursor is determined by the terminal, not by the cursor face.

您还可以使用 X 资源来指定任何特定面的属性。请参阅X 资源

You can also use X resources to specify attributes of any particular face. See X Resources.

Emacs 可以显示可变宽度字体,但某些 Emacs 命令,特别是缩进命令,不考虑可变字符显示宽度。因此,我们建议不要对大多数字体使用可变宽度字体,特别是那些由字体锁定模式指定的字体。

Emacs can display variable-width fonts, but some Emacs commands, particularly indentation commands, do not account for variable character display widths. Therefore, we recommend not using variable-width fonts for most faces, particularly those assigned by Font Lock mode.


15.9 面部颜色

15.9 Colors for Faces

面孔可以有各种前景色和背景色。当您指定面的颜色时(例如,自定义面时(请参阅自定义面)),您可以使用颜色名称RGB 三元组

Faces can have various foreground and background colors. When you specify a color for a face—for instance, when customizing the face (see Customizing Faces)—you can use either a color name or an RGB triplet.

15.9.1 颜色名称

15.9.1 Color Names

颜色名称是预定义的名称,例如 '深橙色' 或者 '中海绿色'。要查看颜色名称列表,请键入M-x list-colors-display。要控制颜色的显示顺序,请自定义list-colors-sort。如果您在图形显示器上运行此命令,它将显示 Emacs 已知的全部颜色名称(这些是标准 X11 颜色名称,在 X 的 RGB.txt文件)。如果您在文本终端上运行该命令,它只会显示可以在此类终端上安全显示的一小部分颜色。然而,即使在文本终端上,Emacs 也能理解 X11 颜色名称;如果给一个面指定了由 X11 颜色名称指定的颜色,则将使用最接近匹配的终端颜色来显示该面。

A color name is a pre-defined name, such as ‘dark orange’ or ‘medium sea green’. To view a list of color names, type M-x list-colors-display. To control the order in which colors are shown, customize list-colors-sort. If you run this command on a graphical display, it shows the full range of color names known to Emacs (these are the standard X11 color names, defined in X’s rgb.txt file). If you run the command on a text terminal, it shows only a small subset of colors that can be safely displayed on such terminals. However, Emacs understands X11 color names even on text terminals; if a face is given a color specified by an X11 color name, it is displayed using the closest-matching terminal color.

15.9.2 RGB 三元组

15.9.2 RGB Triplets

RGB 三元组是以下形式的字符串 '#RRGGBB'。每个原色分量都由 ' 之间的十六进制数表示00'(强度 0)和 'FF'(最大强度)。每个组件也可以使用一位、三位或四位十六进制数字,因此 '红色的' 可以表示为 '#F00','#fff000000', 或者 '#ffff00000000'。组件的位数必须相同。对于十六进制值 A 到 F,大写或小写均可。

An RGB triplet is a string of the form ‘#RRGGBB’. Each of the primary color components is represented by a hexadecimal number between ‘00’ (intensity 0) and ‘FF’ (the maximum intensity). It is also possible to use one, three, or four hex digits for each component, so ‘red’ can be represented as ‘#F00’, ‘#fff000000’, or ‘#ffff00000000’. The components must have the same number of digits. For hexadecimal values A to F, either upper or lower case are acceptable.

M-x list-colors-display命令还显示每个命名颜色的等效 RGB 三元组。例如, '中海绿色' 相当于 '#3CB371'。

The M-x list-colors-display command also shows the equivalent RGB triplet for each named color. For instance, ‘medium sea green’ is equivalent to ‘#3CB371’.

M-x set-face-foreground您可以使用和更改脸部的前景色和背景色 M-x set-face-background。这些命令在迷你缓冲区中提示输入面名称和颜色并完成,然后将该面设置为使用指定的颜色。它们会影响所有帧上的面部颜色,但与使用自定义缓冲区或 X 资源不同,它们的效果不会在未来的 Emacs 会话中持续存在。您还可以使用框架参数来设置特定框架的前景色和背景色;请参阅帧参数

You can change the foreground and background colors of a face with M-x set-face-foreground and M-x set-face-background. These commands prompt in the minibuffer for a face name and a color, with completion, and then set that face to use the specified color. They affect the face colors on all frames, but their effects do not persist for future Emacs sessions, unlike using the customization buffer or X resources. You can also use frame parameters to set foreground and background colors for a specific frame; See Frame Parameters.


15.10 标准面

15.10 Standard Faces

以下是用于指定文本外观的标准面。当您想要它们产生的效果时,可以将它们应用到特定文本。

Here are the standard faces for specifying text appearance. You can apply them to specific text when you want the effects they produce.

default
default

该面用于不指定任何面的普通文本。它的背景颜色用作框架的背景颜色。

This face is used for ordinary text that doesn’t specify any face. Its background color is used as the frame’s background color.

bold
bold

该字体使用默认字体的粗体变体。

This face uses a bold variant of the default font.

italic
italic

该字体使用默认字体的斜体变体。

This face uses an italic variant of the default font.

bold-italic
bold-italic

该字体使用默认字体的粗体斜体变体。

This face uses a bold italic variant of the default font.

underline
underline

这张脸强调了文字。

This face underlines text.

fixed-pitch
fixed-pitch

该字体强制使用固定宽度字体。如果您愿意,可以自定义此字体以使用不同的固定宽度字体,但不应将其设为可变宽度字体。

This face forces use of a fixed-width font. It’s reasonable to customize this face to use a different fixed-width font, if you like, but you should not make it a variable-width font.

fixed-pitch-serif
fixed-pitch-serif

这个字体很像fixed-pitch,只不过字体有衬线,看起来更像传统打字。

This face is like fixed-pitch, except the font has serifs and looks more like traditional typewriting.

variable-pitch
variable-pitch

该字体强制使用可变宽度(即比例)字体。为此面选择的字体大小与为默认(通常是固定宽度)字体选择的字体相匹配。

This face forces use of a variable-width (i.e., proportional) font. The font size picked for this face matches the font picked for the default (usually fixed-width) font.

variable-pitch-text
variable-pitch-text

这就像variable-pitch脸(它继承自脸),但稍大一些。与等宽字体高度相同的比例字体通常在视觉上显得较小,因此更难以阅读。当显示较长的文本时,与(稍小)的variable-pitch面相比,此面可能是一个不错的选择。

This is like the variable-pitch face (from which it inherits), but is slightly larger. A proportional font of the same height as a monospace font usually appears visually smaller, and can therefore be harder to read. When displaying longer texts, this face can be a good choice over the (slightly smaller) variable-pitch face.

shadow
shadow

该面用于使文本比周围的普通文本不那么引人注目。通常,这可以通过使用与黑色或白色默认前景色形成对比的灰色阴影来实现。

This face is used for making the text less noticeable than the surrounding ordinary text. Usually this can be achieved by using shades of gray in contrast with either black or white default foreground color.

以下是用于出于特定目的临时突出显示部分文本的面孔的不完整列表。 (许多其他模式为此目的定义了自己的面孔。)

Here’s an incomplete list of faces used to highlight parts of the text temporarily for specific purposes. (Many other modes define their own faces for this purpose.)

highlight
highlight

该面用于在各种上下文中突出显示文本,例如当鼠标光标移动到超链接上时。

This face is used for text highlighting in various contexts, such as when the mouse cursor is moved over a hyperlink.

isearch
isearch

该面用于突出显示当前 Isearch 匹配(请参阅增量搜索)。

This face is used to highlight the current Isearch match (see Incremental Search).

query-replace
query-replace

该面用于突出显示当前查询替换匹配(请参阅替换命令)。

This face is used to highlight the current Query Replace match (see Replacement Commands).

lazy-highlight
lazy-highlight

该面用于突出显示 Isearch 和 Query Replace 的惰性匹配(当前匹配以外的匹配)。

This face is used to highlight lazy matches for Isearch and Query Replace (matches other than the current one).

region
region

该面用于显示活动区域(请参阅标记和区域)。当 Emacs 构建为支持 GTK+ 时,其颜色取自当前的 GTK+ 主题。

This face is used for displaying an active region (see The Mark and the Region). When Emacs is built with GTK+ support, its colors are taken from the current GTK+ theme.

secondary-selection
secondary-selection

该面用于显示辅助 X 选择(请参阅辅助选择)。

This face is used for displaying a secondary X selection (see Secondary Selection).

trailing-whitespace
trailing-whitespace

show-trailing-whitespace当为非时,用于突出显示行尾多余空格和制表符的面nil(请参阅无用空白)。

The face for highlighting excess spaces and tabs at the end of a line when show-trailing-whitespace is non-nil (see Useless Whitespace).

escape-glyph
escape-glyph

用于显示控制字符和转义序列的表面(请参阅如何显示文本)。

The face for displaying control characters and escape sequences (see How Text Is Displayed).

homoglyph
homoglyph

用于显示相似字符的表面,即看起来像但不是所表示的字符的字符(请参阅如何显示文本)。

The face for displaying lookalike characters, i.e., characters that look like but are not the characters being represented (see How Text Is Displayed).

nobreak-space
nobreak-space

用于显示不间断空格字符的表面(请参阅如何显示文本)。

The face for displaying no-break space characters (see How Text Is Displayed).

nobreak-hyphen
nobreak-hyphen

用于显示不间断连字符的面(请参阅如何显示文本)。

The face for displaying no-break hyphen characters (see How Text Is Displayed).

以下面控制 Emacs 框架各部分的外观:

The following faces control the appearance of parts of the Emacs frame:

mode-line
mode-line

当不使用工具包菜单时,这是用于模式线、标题线和菜单栏的基面。默认情况下,它使用阴影绘制,以在图形显示上产生凸起效果,并在文本终端上绘制为默认面的反面。

和面(模式线上使用的面)继承自该面 mode-line-activemode-line-inactive

This is the base face used for the mode lines, as well as header lines and for menu bars when toolkit menus are not used. By default, it’s drawn with shadows for a raised effect on graphical displays, and drawn as the inverse of the default face on text terminals.

The mode-line-active and mode-line-inactive faces (which are the ones used on the mode lines) inherit from this face.

mode-line-active
mode-line-active

与 类似mode-line,但用于当前选定窗口的模式行。该面继承自mode-line,因此该面的更改会影响所有窗口中的模式线。

Like mode-line, but used for the mode line of the currently selected window. This face inherits from mode-line, so changes in that face affect mode lines in all windows.

mode-line-inactive
mode-line-inactive

与 类似mode-line,但用于除所选窗口之外的窗口的模式行(如果mode-line-in-non-selected-windows为非nil)。该面继承自mode-line,因此该面的更改会影响所有窗口中的模式线。

Like mode-line, but used for mode lines of the windows other than the selected one (if mode-line-in-non-selected-windows is non-nil). This face inherits from mode-line, so changes in that face affect mode lines in all windows.

mode-line-highlight
mode-line-highlight

与 类似highlight,但用于模式行上文本的鼠标敏感部分。当鼠标指针悬停在文本的此类部分上方时, 通常会弹出工具提示(请参阅工具提示)。

Like highlight, but used for mouse-sensitive portions of text on mode lines. Such portions of text typically pop up tooltips (see Tooltips) when the mouse pointer hovers above them.

mode-line-buffer-id
mode-line-buffer-id

该面用于模式行中的缓冲区识别部分。

This face is used for buffer identification parts in the mode line.

header-line
header-line

与窗口的标题行类似mode-line,它出现在窗口的顶部,就像模式行出现在底部一样。大多数窗口没有标题行,只有某些特殊模式(例如信息模式)才会创建标题行。

Similar to mode-line for a window’s header line, which appears at the top of a window just as the mode line appears at the bottom. Most windows do not have a header line—only some special modes, such Info mode, create one.

header-line-highlight
header-line-highlight

highlight与和类似mode-line-highlight,但用于标题行上文本的鼠标敏感部分。这是一个单独的面孔,因为该header-line面孔可能以无法与 良好交互的方式进行自定义highlight

Similar to highlight and mode-line-highlight, but used for mouse-sensitive portions of text on header lines. This is a separate face because the header-line face might be customized in a way that does not interact well with highlight.

tab-line
tab-line

与窗口的选项卡行类似mode-line,它出现在窗口顶部,其中选项卡代表窗口缓冲区。请参见窗口选项卡行

Similar to mode-line for a window’s tab line, which appears at the top of a window with tabs representing window buffers. See Window Tab Line.

vertical-border
vertical-border

该面用于文本终端上窗口之间的垂直分隔线。

This face is used for the vertical divider between windows on text terminals.

minibuffer-prompt
minibuffer-prompt

该面用于迷你缓冲区中显示的提示字符串。默认情况下,Emacs 会自动将此面添加到 的值中 ,该值是用于显示提示文本的minibuffer-prompt-properties文本属性列表(请参阅Emacs Lisp 参考手册中的文本属性)。 (该变量在进入迷你缓冲区时生效。)

This face is used for the prompt strings displayed in the minibuffer. By default, Emacs automatically adds this face to the value of minibuffer-prompt-properties, which is a list of text properties (see Text Properties in the Emacs Lisp Reference Manual) used to display the prompt text. (This variable takes effect when you enter the minibuffer.)

fringe
fringe

图形显示器上窗口左侧和右侧边缘的面。 (边缘是 Emacs 框架中文本区域与窗口左右边框之间的狭窄部分。)请参阅窗口边缘

The face for the fringes to the left and right of windows on graphic displays. (The fringes are the narrow portions of the Emacs frame between the text area and the window’s right and left borders.) See Window Fringes.

cursor
cursor

该面的属性:background指定文本光标的颜色。请参阅显示光标

The :background attribute of this face specifies the color of the text cursor. See Displaying the Cursor.

tooltip
tooltip

该面用于工具提示文本。默认情况下,如果 Emacs 是使用 GTK+ 支持构建的,则工具提示是通过 GTK+ 绘制的,并且该面没有任何效果。请参阅工具提示

This face is used for tooltip text. By default, if Emacs is built with GTK+ support, tooltips are drawn via GTK+ and this face has no effect. See Tooltips.

mouse
mouse

该面决定鼠标指针的颜色。

This face determines the color of the mouse pointer.

以下面孔同样控制 Emacs 框架部分的外观,但仅限于文本终端,或者当 Emacs 构建在 X 上且没有工具包支持时。 (对于所有其他情况,各个框架元素的外观由系统范围的设置决定。)

The following faces likewise control the appearance of parts of the Emacs frame, but only on text terminals, or when Emacs is built on X with no toolkit support. (For all other cases, the appearance of the respective frame elements is determined by system-wide settings.)

scroll-bar
scroll-bar

该面决定了滚动条的视觉外观。请参阅滚动条

This face determines the visual appearance of the scroll bar. See Scroll Bars.

tool-bar
tool-bar

该面决定工具栏图标的颜色。请参阅工具栏

This face determines the color of tool bar icons. See Tool Bars.

tab-bar
tab-bar

该面决定选项卡栏图标的颜色。请参阅选项卡栏

This face determines the color of tab bar icons. See Tab Bars.

menu
menu

该面决定了 Emacs 菜单的颜色和字体。请参阅菜单栏

This face determines the colors and font of Emacs’s menus. See Menu Bars.

tty-menu-enabled-face
tty-menu-enabled-face

该面用于显示文本模式终端上启用的菜单项。

This face is used to display enabled menu items on text-mode terminals.

tty-menu-disabled-face
tty-menu-disabled-face

该面用于显示文本模式终端上禁用的菜单项。

This face is used to display disabled menu items on text-mode terminals.

tty-menu-selected-face
tty-menu-selected-face

该面用于在文本模式终端上显示单击鼠标或按 时将选择的菜单项RET

This face is used to display on text-mode terminals the menu item that would be selected if you click a mouse or press RET.


15.11 图标

15.11 Icons

Emacs 有时会显示可单击的按钮(或其他信息丰富的图标),您可以自定义这些按钮的显示方式。

Emacs sometimes displays clickable buttons (or other informative icons), and you can customize how these look on display.

这里的主要定制点是icon-preference用户选项。通过使用它,您可以告诉 Emacs 您对图标的总体偏好。这是图标类型的列表,将使用第一个支持的图标类型。支持的类型有:

The main customization point here is the icon-preference user option. By using this, you can tell Emacs your overall preferences for icons. This is a list of icon types, and the first icon type that’s supported will be used. The supported types are:

image
image

使用图像作为图标。

Use an image for the icon.

emoji
emoji

使用彩色表情符号作为图标。

Use a colorful emoji for the icon.

symbol
symbol

使用单色符号作为图标。

Use a monochrome symbol for the icon.

text
text

使用简单的文本作为图标。

Use a simple text for the icon.

此外,每个单独的图标都可以使用 进行自定义M-x customize-icon,主题可以进一步改变图标的​​外观。

In addition, each individual icon can be customized with M-x customize-icon, and themes can further alter the looks of the icons.

要获取图标的快速描述,请使用该M-x describe-icon 命令。

To get a quick description of an icon, use the M-x describe-icon command.


15.12 文本比例

15.12 Text Scale

default要增加当前缓冲区中面部的字体大小,请键入C-x C-+C-x C-=。要减少它,请键入 C-x C--。要恢复默认(全局)字体大小,请键入 C-x C-0。这些键都绑定到同一个命令 , text-scale-adjust该命令查看最后键入的键以确定要执行的操作,并通过更改默认字体的高度来相应地调整字体大小。

To increase the font size of the default face in the current buffer, type C-x C-+ or C-x C-=. To decrease it, type C-x C--. To restore the default (global) font size, type C-x C-0. These keys are all bound to the same command, text-scale-adjust, which looks at the last key typed to determine which action to take and adjusts the font size accordingly by changing the height of the default face.

大多数面孔没有明确的属性设置:height ,因此继承了面孔的高度default。这些面也通过上述命令进行缩放。

Most faces don’t have an explicit setting of the :height attribute, and thus inherit the height from the default face. Those faces are also scaled by the above commands.

default除具有显式属性设置的 面孔外,其他面孔:height不受这些字体大小更改的影响。脸部header-line是一个例外:即使它具有明确的:height属性设置,它也会被缩放。

Faces other than default that have an explicit setting of the :height attribute are not affected by these font size changes. The header-line face is an exception: it will be scaled even if it has an explicit setting of the :height attribute.

同样,当鼠标指针位于缓冲区文本上方时,按下修改器滚动鼠标滚轮Ctrl将增大或减小受影响的面的字体大小,具体取决于滚动的方向。

Similarly, scrolling the mouse wheel with the Ctrl modifier pressed, when the mouse pointer is above buffer text, will increase or decrease the font size of the affected faces, depending on the direction of the scrolling.

这些命令的最后一个键可以在没有前导 C-x和修饰符的情况下重复。例如, 将面部高度增加三级。每一步都会将文本高度缩放 ​​1.2 倍;要更改此因素,请自定义变量。命令的数字参数 0将恢复默认高度,与键入 相同。 C-x C-= C-= C-=C-x C-= = =text-scale-mode-steptext-scale-adjustC-x C-0

The final key of these commands may be repeated without the leading C-x and without the modifiers. For instance, C-x C-= C-= C-= and C-x C-= = = increase the face height by three steps. Each step scales the text height by a factor of 1.2; to change this factor, customize the variable text-scale-mode-step. A numeric argument of 0 to the text-scale-adjust command restores the default height, the same as typing C-x C-0.

同样,要全局更改字体大小,请键入C-x C-M-+C-x C-M-=C-x C-M--,或在按下和修饰键C-x C-M-0的同时滚动鼠标滚轮。要在全局更改字体大小时启用框架大小调整,请自定义变量 (请参阅轻松自定义界面)。 CtrlMetaglobal-text-scale-adjust-resizes-frames

Similarly, to change the sizes of the fonts globally, type C-x C-M-+, C-x C-M-=, C-x C-M-- or C-x C-M-0, or scroll the mouse wheel with both the Ctrl and Meta modifiers pressed. To enable frame resizing when the font size is changed globally, customize the variable global-text-scale-adjust-resizes-frames (see Easy Customization Interface).

命令text-scale-increasetext-scale-decrease增加或减少当前缓冲区中的字体大小,就像分别C-x C-+一样C-x C-- 。您可能会发现绑定到这些命令比绑定到text-scale-adjust.

The commands text-scale-increase and text-scale-decrease increase or decrease the size of the font in the current buffer, just like C-x C-+ and C-x C-- respectively. You may find it convenient to bind to these commands, rather than text-scale-adjust.

该命令text-scale-set将当前缓冲区中的字体大小缩放到由其前缀参数指定的绝对级别。

The command text-scale-set scales the size of the font in the current buffer to an absolute level specified by its prefix argument.

text-scale-mode如果当前字体缩放比例不为 1, 上述命令会自动启用次要模式 ,否则禁用它。

The above commands automatically enable the minor mode text-scale-mode if the current font scaling is other than 1, and disable it otherwise.

text-scale-pinch当通过将两根手指放在触摸板上并将它们移向或远离彼此来执行捏合手势时,该命令基于触摸板上手指之间的距离来增大或减小文本比例。这仅适用于某些具有受支持硬件的系统。

The command text-scale-pinch increases or decreases the text scale based on the distance between fingers on a touchpad when a pinch gesture is performed by placing two fingers on a touchpad and moving them towards or apart from each other. This is only available on some systems with supported hardware.

该命令mouse-wheel-text-scale还可以更改文本比例。通常,当您Ctrl在移动鼠标滚轮的同时按下时,它就会运行。当滚轮向下移动时,文本比例增大,当滚轮向上移动时,文本比例减小。

The command mouse-wheel-text-scale also changes the text scale. Normally, it is run when you press Ctrl while moving the mouse wheel. The text scale is increased when the wheel is moved downwards, and it is decreased when the wheel is moved upwards.


15.13 字体锁定模式

15.13 Font Lock mode

字体锁定模式是一种次要模式,始终位于特定缓冲区的本地,它将字体分配给缓冲区中的文本(或字体化)。每个缓冲区的主要模式告诉字体锁定模式要字体化的文本;例如,编程语言模式将语法相关的结构(如注释、字符串和函数名称)字体化。

Font Lock mode is a minor mode, always local to a particular buffer, which assigns faces to (or fontifies) the text in the buffer. Each buffer’s major mode tells Font Lock mode which text to fontify; for instance, programming language modes fontify syntactically relevant constructs like comments, strings, and function names.

在支持字体锁定模式的主要模式中默认启用该模式。要在当前缓冲区中切换它,请键入M-x font-lock-mode。正数参数无条件启用字体锁定模式,负数或零参数则禁用它。

Font Lock mode is enabled by default in major modes that support it. To toggle it in the current buffer, type M-x font-lock-mode. A positive numeric argument unconditionally enables Font Lock mode, and a negative or zero argument disables it.

键入M-x global-font-lock-mode以在所有缓冲区中切换字体锁定模式。要为将来的 Emacs 会话强加此设置,请自定义变量global-font-lock-mode(请参阅轻松自定义界面),或将以下行添加到您的 init 文件中:

Type M-x global-font-lock-mode to toggle Font Lock mode in all buffers. To impose this setting for future Emacs sessions, customize the variable global-font-lock-mode (see Easy Customization Interface), or add the following line to your init file:

(全局字体锁定模式 0)
(global-font-lock-mode 0)

font-lock-mode如果您已禁用全局字体锁定模式,您仍然可以通过将该函数添加到模式挂钩来启用特定主要模式的字体锁定 (请参阅挂钩)。例如,要启用字体锁定模式来编辑 C 文件,您可以执行以下操作:

If you have disabled Global Font Lock mode, you can still enable Font Lock for specific major modes by adding the function font-lock-mode to the mode hooks (see Hooks). For example, to enable Font Lock mode for editing C files, you can do this:

(add-hook 'c-mode-hook 'font-lock-mode)
(add-hook 'c-mode-hook 'font-lock-mode)

字体锁定模式使用几个专门命名的面孔来完成其工作,包括font-lock-string-facefont-lock-comment-face和其他。找到所有这些的最简单方法是使用.然后,您可以使用该自定义缓冲区来自定义这些面的外观。请参阅自定义面M-x customize-group RET font-lock-faces RET

Font Lock mode uses several specifically named faces to do its job, including font-lock-string-face, font-lock-comment-face, and others. The easiest way to find them all is to use M-x customize-group RET font-lock-faces RET. You can then use that customization buffer to customize the appearance of these faces. See Customizing Faces.

字体化非常大的缓冲区可能需要很长时间。为了避免访问文件时出现较大延迟,Emacs 最初仅对缓冲区的可见部分进行字体设置。当您滚动缓冲区时,每个变得可见的部分在显示时都会被字体化;这种类型的字体锁定称为即时(或JIT)锁定。您可以通过自定义自定义组中的变量来控制 JIT Lock 的行为方式,包括告诉它在空闲时执行字体化即时锁定'。请参阅自定义特定项目

Fontifying very large buffers can take a long time. To avoid large delays when a file is visited, Emacs initially fontifies only the visible portion of a buffer. As you scroll through the buffer, each portion that becomes visible is fontified as soon as it is displayed; this type of Font Lock is called Just-In-Time (or JIT) Lock. You can control how JIT Lock behaves, including telling it to perform fontification while idle, by customizing variables in the customization group ‘jit-lock’. See Customizing Specific Items.

主要模式用于确定缓冲文本的哪些部分要字体化以及要使用哪些外观的信息可以基于分析文本的几种不同方式:

The information that major modes use for determining which parts of buffer text to fontify and what faces to use can be based on several different ways of analyzing the text:

  • 基于正则表达式搜索关键字和其他文本模式(请参阅正则表达式搜索)。
  • Search for keywords and other textual patterns based on regular expressions (see Regular Expression Search).
  • 根据内置语法表查找文本中语法不同的部分(请参阅Emacs Lisp 参考手册中的语法表)。
  • Find syntactically distinct parts of text based on built-in syntax tables (see Syntax Tables in The Emacs Lisp Reference Manual).
  • 使用由成熟的解析器通过专用库(例如 tree-sitter 库)或外部程序 生成的语法树(请参阅Emacs Lisp 参考手册中的解析程序源代码)。
  • Use syntax tree produced by a full-blown parser, via a special-purpose library, such as the tree-sitter library (see Parsing Program Source in The Emacs Lisp Reference Manual), or an external program.

15.13.1 传统字体锁定

15.13.1 Traditional Font Lock

提供字体锁定信息的“传统”方法基于正则表达式搜索和使用 Emacs 内置语法表进行语法分析。本小节描述了使用这些传统方法的主要模式的字体锁定的使用和定制。

“Traditional” methods of providing font-lock information are based on regular-expression search and on syntactic analysis using syntax tables built into Emacs. This subsection describes the use and customization of font-lock for major modes which use these traditional methods.

font-lock-maximum-decoration对于支持此功能的主要模式,您可以通过自定义变量 来控制“字体锁定”模式应用的字体量。该变量的值应该是一个数字(1 代表最小的字体量;某些模式支持级别高达 3);或t,表示“尽可能高”(默认值)。为了对给定的文件缓冲区有效, 应该在访问文件之前font-lock-maximum-decoration进行定制;如果您在自定义此变量时已经在缓冲区中访问了该文件,请在自定义后终止该缓冲区并再次访问该文件。

You can control the amount of fontification applied by Font Lock mode by customizing the variable font-lock-maximum-decoration, for major modes that support this feature. The value of this variable should be a number (with 1 representing a minimal amount of fontification; some modes support levels as high as 3); or t, meaning “as high as possible” (the default). To be effective for a given file buffer, the customization of font-lock-maximum-decoration should be done before the file is visited; if you already have the file visited in a buffer when you customize this variable, kill the buffer and visit the file again after the customization.

您还可以为特定的主要模式指定不同的数字;例如,要对 C/C++ 模式使用级别 1,否则使用默认级别,请使用值

You can also specify different numbers for particular major modes; for example, to use level 1 for C/C++ modes, and the default level otherwise, use the value

'((c-模式. 1) (c++-模式. 1)))
'((c-mode . 1) (c++-mode . 1)))

注释和字符串字体化(或“句法”字体化)依赖于对缓冲区文本的句法结构的分析。为了速度,某些模式(包括 Lisp 模式)依赖于一种特殊的约定:最左边一列中的左括号或左大括号始终定义 defun 的开头,因此始终位于任何字符串或注释之外。因此,如果左括号或左大括号位于字符串或注释内,则应避免在最左列中放置左括号或左大括号。有关详细信息,请参阅左边距约定

Comment and string fontification (or “syntactic” fontification) relies on analysis of the syntactic structure of the buffer text. For the sake of speed, some modes, including Lisp mode, rely on a special convention: an open-parenthesis or open-brace in the leftmost column always defines the beginning of a defun, and is thus always outside any string or comment. Therefore, you should avoid placing an open-parenthesis or open-brace in the leftmost column, if it is inside a string or comment. See Left Margin Convention, for details.

大多数模式都已存在字体锁定突出显示模式,但您可能想要字体化其他模式。您可以使用 , 函数 font-lock-add-keywords为特定模式添加您自己的突出显示模式。例如,要突出显示 '整我:' C 注释中的单词,使用:

Font Lock highlighting patterns already exist for most modes, but you may want to fontify additional patterns. You can use the function font-lock-add-keywords, to add your own highlighting patterns for a particular mode. For example, to highlight ‘FIXME:’ words in C comments, use this:

(添加钩子'c-模式钩子
          (拉姆达()
           (字体锁定添加关键字 nil
            '((“\\<\\(FIXME\\):”1
               字体锁定警告面 t)))))
(add-hook 'c-mode-hook
          (lambda ()
           (font-lock-add-keywords nil
            '(("\\<\\(FIXME\\):" 1
               font-lock-warning-face t)))))

要从字体锁定突出显示模式中删除关键字,请使用函数font-lock-remove-keywords。请参阅Emacs Lisp 参考手册中的基于搜索的字体化。或者,您可以通过自定义选项选择性地禁用某些关键字的突出显示,请参阅Emacs Lisp 参考手册中的自定义关键字font-lock-ignore

To remove keywords from the font-lock highlighting patterns, use the function font-lock-remove-keywords. See Search-based Fontification in The Emacs Lisp Reference Manual. Alternatively, you can selectively disable highlighting due to some keywords by customizing the font-lock-ignore option, see Customizing Keywords in The Emacs Lisp Reference Manual.


15.13.2 基于解析器的字体锁定

15.13.2 Parser-based Font Lock

如果您的 Emacs 是使用 tree-sitter 库构建的,则它可以使用该库解析缓冲区文本的结果来实现字体化。这通常比上一小节中描述的“传统”方法更快、更准确,因为 tree-sitter 库为编程语言和它支持的其他类型的格式化文本提供了成熟的解析器。利用 Tree-sitter 库的主要模式被命名 foo-ts-mode为 '-ts-' 指示库的使用的部分。本小节记录了基于 tree-sitter 库的字体锁定支持。

If your Emacs was built with the tree-sitter library, it can use the results of parsing the buffer text by that library for the purposes of fontification. This is usually faster and more accurate than the “traditional” methods described in the previous subsection, since the tree-sitter library provides full-blown parsers for programming languages and other kinds of formatted text which it supports. Major modes which utilize the tree-sitter library are named foo-ts-mode, with the ‘-ts-’ part indicating the use of the library. This subsection documents the Font Lock support based on the tree-sitter library.

您可以通过自定义变量 来控制基于 tree-sitter 的主要模式的 Font Lock 模式应用的字体量 treesit-font-lock-level。它的值是 1 到 4 之间的数字:

You can control the amount of fontification applied by Font Lock mode of major modes based on tree-sitter by customizing the variable treesit-font-lock-level. Its value is a number between 1 and 4:

1级
Level 1

此级别通常仅对函数定义中的注释和函数名称进行字体显示。

This level usually fontifies only comments and function names in function definitions.

2级
Level 2

此级别添加关键字、字符串和数据类型的字体化。

This level adds fontification of keywords, strings, and data types.

3级
Level 3

这是默认级别;它添加了作业、数字等的字体。

This is the default level; it adds fontification of assignments, numbers, etc.

4级
Level 4

此级别添加了所有其他可以字体化的内容:运算符、分隔符、方括号、其他标点符号、函数调用中的函数名称、属性查找、变量等。

This level adds everything else that can be fontified: operators, delimiters, brackets, other punctuation, function names in function calls, property look ups, variables, etc.

上述每个语法类别的具体构成取决于主要模式和树守护者针对主要模式语言使用的解析器语法。然而,一般来说,类别遵循编程语言的约定或主要模式支持的文件格式。变量的缓冲区本地值treesit-font-lock-feature-list保存基于树守护者的主要模式支持的字体化特征,其中每个子列表显示相应字体化级别提供的特征。

What exactly constitutes each of the syntactical categories mentioned above depends on the major mode and the parser grammar used by tree-sitter for the major-mode’s language. However, in general the categories follow the conventions of the programming language or the file format supported by the major mode. The buffer-local value of the variable treesit-font-lock-feature-list holds the fontification features supported by a tree-sitter based major mode, where each sub-list shows the features provided by the corresponding fontification level.

treesit-font-lock-level一旦您更改via 的值(请参阅自定义特定项目),它会立即在所有现有缓冲区以及您将来在同一会话中访问的文件中生效。 M-x customize-variable

Once you change the value of treesit-font-lock-level via M-x customize-variable (see Customizing Specific Items), it takes effect immediately in all the existing buffers and for files you visit in the future in the same session.


15.14 交互式突出显示

15.14 Interactive Highlighting

突出显示更改模式是一种次要模式,通过为文本提供不同的外观来突出显示最近更改的缓冲区部分。要启用或禁用突出显示更改模式,请使用 M-x highlight-changes-mode

Highlight Changes mode is a minor mode that highlights the parts of the buffer that were changed most recently, by giving that text a different face. To enable or disable Highlight Changes mode, use M-x highlight-changes-mode.

Hi Lock 模式是一种次要模式,可突出显示与您指定的正则表达式匹配的文本。例如,您可以使用它来突出显示程序源文件中对某个变量的所有引用,突出显示某个程序的大量输出中的某些部分,或者突出显示文章中的某些名称。要启用或禁用高锁定模式,请使用命令M-x hi-lock-mode。要为所有缓冲区启用 Hi Lock 模式,请使用M-x global-hi-lock-mode或放置 (global-hi-lock-mode 1)在您的.emacs文件。

Hi Lock mode is a minor mode that highlights text that matches regular expressions you specify. For example, you can use it to highlight all the references to a certain variable in a program source file, highlight certain parts in a voluminous output of some program, or highlight certain names in an article. To enable or disable Hi Lock mode, use the command M-x hi-lock-mode. To enable Hi Lock mode for all buffers, use M-x global-hi-lock-mode or place (global-hi-lock-mode 1) in your .emacs file.

Hi Lock 模式的工作方式类似于 Font Lock 模式(请参阅Font Lock 模式),只不过您显式指定要突出显示的正则表达式。您可以使用以下命令来控制它们。 (下面以 开头的键绑定C-x w已被弃用,取而代之的是全局M-s h绑定,并将在未来的某些 Emacs 版本中删除。)

Hi Lock mode works like Font Lock mode (see Font Lock mode), except that you specify explicitly the regular expressions to highlight. You can control them with the following commands. (The key bindings below that begin with C-x w are deprecated in favor of the global M-s h bindings, and will be removed in some future Emacs version.)

M-s h r regexp RET face RET
M-s h r regexp RET face RET
C-x w h regexp RET face RET
C-x w h regexp RET face RET

使用face ( )突出显示与正则表达式匹配的文本。只要缓冲区被加载,突出显示就会保持不变。例如,要使用默认外观(黄色背景)突出显示所有出现的单词“whim”,请输入 。任何面都可以用于突出显示,Hi Lock 提供了几个自己的面,并且这些面已预先加载到默认值列表中。同时提示您使用面部并循环使用它们。前缀数字参数将突出显示限制为相应的子表达式。 highlight-regexpM-s h r whim RET RETM-nM-p

将该选项设置hi-lock-auto-select-face为非nil 值会导致此命令(以及读取面孔的其他 Hi Lock 命令)自动从默认列表中选择下一张面孔,而无需提示。

您可以多次使用此命令,指定各种正则表达式以不同的方式突出显示。

Highlight text that matches regexp using face face (highlight-regexp). The highlighting will remain as long as the buffer is loaded. For example, to highlight all occurrences of the word “whim” using the default face (a yellow background), type M-s h r whim RET RET. Any face can be used for highlighting, Hi Lock provides several of its own and these are pre-loaded into a list of default values. While being prompted for a face use M-n and M-p to cycle through them. A prefix numeric argument limits the highlighting to the corresponding subexpression.

Setting the option hi-lock-auto-select-face to a non-nil value causes this command (and other Hi Lock commands that read faces) to automatically choose the next face from the default list without prompting.

You can use this command multiple times, specifying various regular expressions to highlight in different ways.

M-s h u regexp RET
M-s h u regexp RET
C-x w r regexp RET
C-x w r regexp RET

取消突出显示正则表达式( unhighlight-regexp)。如果从菜单中调用它,则可以从列表中选择要取消突出显示的表达式。如果从键盘调用它,则使用迷你缓冲区。它将显示最近添加的正则表达式;用于M-n 显示下一个较旧的表达式并M-p选择下一个较新的表达式。 (您也可以手动键入表达式并完成。)当要取消突出显示的表达式出现在迷你缓冲区中时,按RET退出迷你缓冲区并取消突出显示它。

Unhighlight regexp (unhighlight-regexp). If you invoke this from the menu, you select the expression to unhighlight from a list. If you invoke this from the keyboard, you use the minibuffer. It will show the most recently added regular expression; use M-n to show the next older expression and M-p to select the next newer expression. (You can also type the expression by hand, with completion.) When the expression you want to unhighlight appears in the minibuffer, press RET to exit the minibuffer and unhighlight it.

M-s h l regexp RET face RET
M-s h l regexp RET face RET
C-x w l regexp RET face RET
C-x w l regexp RET face RET

使用 Face ( )突出显示包含regexp匹配项的整行。 highlight-lines-matching-regexp

Highlight entire lines containing a match for regexp, using face face (highlight-lines-matching-regexp).

M-s h p phrase RET face RET
M-s h p phrase RET face RET
C-x w p phrase RET face RET
C-x w p phrase RET face RET

使用face ( )突出 显示短语的匹配项。短语可以是任何正则表达式,但空格将被替换为空白,并且首字母小写字母将变得不区分大小写。 highlight-phrase

Highlight matches of phrase, using face face (highlight-phrase). phrase can be any regexp, but spaces will be replaced by matches to whitespace and initial lower-case letters will become case insensitive.

M-s h .
M-s h .
C-x w .
C-x w .

使用下一个可用面 ( ) 突出显示在点​​附近找到的符号highlight-symbol-at-point

Highlight the symbol found near point, using the next available face (highlight-symbol-at-point).

M-s h w
M-s h w
C-x w b
C-x w b

将所有当前突出显示的 regexp/face 对插入到缓冲区中,并使用注释分隔符以防止它们更改您的程序。 (此键绑定运行 hi-lock-write-interactive-patterns命令。)

M-x hi-lock-find-patterns如果适当的话,如果您调用,或者如果您在启用高锁定模式时访问该文件(自运行以来hi-lock-find-patterns), 这些模式将从注释中提取。

Insert all the current highlighting regexp/face pairs into the buffer at point, with comment delimiters to prevent them from changing your program. (This key binding runs the hi-lock-write-interactive-patterns command.)

These patterns are extracted from the comments, if appropriate, if you invoke M-x hi-lock-find-patterns, or if you visit the file while Hi Lock mode is enabled (since that runs hi-lock-find-patterns).

M-s h f
M-s h f
C-x w i
C-x w i

从当前缓冲区 ( hi-lock-find-patterns) 中的注释中提取正则表达式/人脸对。因此,您可以使用 交互地输入模式highlight-regexp,使用 存储它们到文件中hi-lock-write-interactive-patterns,编辑它们(可能包括匹配的不同括号部分的不同面孔),最后使用此命令 ( hi-lock-find-patterns) 让 Hi Lock 突出显示编辑的模式。

该变量hi-lock-file-patterns-policy控制高锁定模式是否应在访问文件时自动提取并突出显示文件中找到的模式。它的值可以是nil(从不突出显示)、 ask(查询用户)或函数。如果它是一个函数, hi-lock-find-patterns则使用模式作为参数来调用它;如果函数返回 non- nil,则使用这些模式。默认为ask.请注意,如果直接调用 hi-lock-find-patterns,无论该变量的值如何, 模式始终会突出显示。

此外,hi-lock-find-patterns如果当前主模式的符号是 list 的成员,则不执行任何操作hi-lock-exclude-modes

Extract regexp/face pairs from comments in the current buffer (hi-lock-find-patterns). Thus, you can enter patterns interactively with highlight-regexp, store them into the file with hi-lock-write-interactive-patterns, edit them (perhaps including different faces for different parenthesized parts of the match), and finally use this command (hi-lock-find-patterns) to have Hi Lock highlight the edited patterns.

The variable hi-lock-file-patterns-policy controls whether Hi Lock mode should automatically extract and highlight patterns found in a file when it is visited. Its value can be nil (never highlight), ask (query the user), or a function. If it is a function, hi-lock-find-patterns calls it with the patterns as argument; if the function returns non-nil, the patterns are used. The default is ask. Note that patterns are always highlighted if you call hi-lock-find-patterns directly, regardless of the value of this variable.

Also, hi-lock-find-patterns does nothing if the current major mode’s symbol is a member of the list hi-lock-exclude-modes.


15.15 窗边

15.15 Window Fringes

在图形显示上,每个 Emacs 窗口的 左右边缘通常都有狭窄的边缘。边缘用于显示提供有关窗口中文本的信息的符号。您可以键入M-x fringe-mode来切换边缘的显示或修改其宽度。该命令影响所有帧中的条纹;要仅修改选定帧上的条纹,请使用M-x set-fringe-style。您可以通过自定义变量使对边缘的更改永久化fringe-mode

On graphical displays, each Emacs window normally has narrow fringes on the left and right edges. The fringes are used to display symbols that provide information about the text in the window. You can type M-x fringe-mode to toggle display of the fringes or to modify their width. This command affects fringes in all frames; to modify fringes on the selected frame only, use M-x set-fringe-style. You can make your changes to the fringes permanent by customizing the variable fringe-mode.

边缘最常见的用途是指示连续线(请参阅连续线)。当一行文本被分割成多条屏幕线时,除了第一条屏幕线之外,左边缘会显示每个屏幕线的弯曲箭头,表明这不是真正的开始。右边缘显示除最后一行之外的每条屏幕线的弯曲箭头,表明这不是真正的结束。如果线条的方向是从右到左(请参阅双向编辑),则边缘中弯曲箭头的含义会交换。

The most common use of the fringes is to indicate a continuation line (see Continuation Lines). When one line of text is split into multiple screen lines, the left fringe shows a curving arrow for each screen line except the first, indicating that this is not the real beginning. The right fringe shows a curving arrow for each screen line except the last, indicating that this is not the real end. If the line’s direction is right-to-left (see Bidirectional Editing), the meanings of the curving arrows in the fringes are swapped.

边缘表示行截断(请参阅行截断),并带有短水平箭头,这意味着该行上有更多文本,这些文本水平滚动到视图之外。单击其中一个箭头可沿箭头方向水平滚动显示。

The fringes indicate line truncation (see Line Truncation) with short horizontal arrows meaning there’s more text on this line which is scrolled horizontally out of view. Clicking the mouse on one of the arrows scrolls the display horizontally in the direction of the arrow.

边缘还可以指示其他内容,例如缓冲区边界(请参阅显示边界)、窗口末尾附近未使用的行(请参阅indicates-empty-lines)以及正在调试的程序正在执行的位置(请参阅在 Emacs 下运行调试器))。

The fringes can also indicate other things, such as buffer boundaries (see Displaying Boundaries), unused lines near the end of the window (see indicate-empty-lines), and where a program you are debugging is executing (see Running Debuggers Under Emacs).

如果当前行与窗口完全一样宽并且点位于行的末尾,则边缘还用于绘制光标。要禁用此功能,请将变量更改 overflow-newline-into-fringenil;这会导致 Emacs 继续或截断与窗口宽度完全相同的行。

The fringe is also used for drawing the cursor, if the current line is exactly as wide as the window and point is at the end of the line. To disable this, change the variable overflow-newline-into-fringe to nil; this causes Emacs to continue or truncate lines that are exactly as wide as the window.

如果您自定义fringe-mode删除窗口显示一侧或两侧的边缘,则显示在边缘上的功能将不可用。行连续和截断的指示符是一个例外:当边缘不可用时,Emacs 使用最左边和最右边的字符单元来用特殊 ASCII 字符来指示连续和截断,请参阅 连续行行截断。这会减少每行上可用于显示文本的宽度,因为用于截断和连续指示符的字符单元是为此目的而保留的。由于缓冲区文本可以包含双向文本,因此可以包含从左到右和从右到左的段落(请参阅双向编辑),因此仅删除其中一个边缘仍然保留两个字符单元,窗口的每一侧各一个,以便截断和继续指示符,因为这些指示符在从右到左的段落中显示在窗口的相对两侧。

If you customize fringe-mode to remove the fringes on one or both sides of the window display, the features that display on the fringe are not available. Indicators of line continuation and truncation are an exception: when fringes are not available, Emacs uses the leftmost and rightmost character cells to indicate continuation and truncation with special ASCII characters, see Continuation Lines, and Line Truncation. This reduces the width available for displaying text on each line, because the character cells used for truncation and continuation indicators are reserved for that purpose. Since buffer text can include bidirectional text, and thus both left-to-right and right-to-left paragraphs (see Bidirectional Editing), removing only one of the fringes still reserves two character cells, one on each side of the window, for truncation and continuation indicators, because these indicators are displayed on opposite sides of the window in right-to-left paragraphs.


15.16 显示边界

15.16 Displaying Boundaries

Emacs 可以显示位置指示fill-column(请参阅显式填充命令)。填充列指示器是一个有用的功能,特别是在prog-mode及其后代(请参阅主要模式)中,用于指示特定列的位置,该特定列对于格式化程序的源代码具有一些特殊含义。这假设缓冲区使用固定间距字体,其中所有字符(双宽字符可能除外)在显示时具有相同的宽度。如果缓冲区使用可变间距字体,则不同行上的填充列指示器可能会显示不对齐。

Emacs can display an indication of the fill-column position (see Explicit Fill Commands). The fill-column indicator is a useful functionality especially in prog-mode and its descendants (see Major Modes) to indicate the position of a specific column that has some special meaning for formatting the source code of a program. This assumes the buffer uses a fixed-pitch font, where all the characters (with the possible exception of double-width characters) have the same width on display. If the buffer uses variable-pitch fonts, the fill-column indicators on different lines might appear unaligned.

要激活填充列指示显示,请使用次要模式 display-fill-column-indicator-modeglobal-display-fill-column-indicator-mode,它们分别在本地或全局启用指示器。

To activate the fill-column indication display, use the minor modes display-fill-column-indicator-mode and global-display-fill-column-indicator-mode, which enable the indicator locally or globally, respectively.

或者,您可以设置两个缓冲区局部变量 display-fill-column-indicatordisplay-fill-column-indicator-character激活指示器并控制用于指示的字符。请注意,两个变量都必须为非,nil才能显示指示。 (打开次要模式会设置这两个变量。)

Alternatively, you can set the two buffer-local variables display-fill-column-indicator and display-fill-column-indicator-character to activate the indicator and control the character used for the indication. Note that both variables must be non-nil for the indication to be displayed. (Turning on the minor mode sets both these variables.)

有 2 个缓冲区局部变量和一个面孔来自定义此模式:

There are 2 buffer local variables and a face to customize this mode:

display-fill-column-indicator-column
display-fill-column-indicator-column

指定应设置指示器的列号。它可以为列取正数值,或者特殊值 ,这意味着将使用 t变量的值 。fill-column

任何其他值都会禁用该指示器。默认值为t

Specifies the column number where the indicator should be set. It can take positive numerical values for the column, or the special value t, which means that the value of the variable fill-column will be used.

Any other value disables the indicator. The default value is t.

display-fill-column-indicator-character
display-fill-column-indicator-character

指定用于指示符的字符。该字符可以是任何有效字符,包括 Unicode 字符(如果字体支持)。该值nil禁用指示器。当通过函数display-fill-column-indicator-mode或 启用该模式时global-display-fill-column-indicator-mode,它们将使用该变量指定的字符(如果不是)nil;否则 Emacs 将使用字符 U+2502 BOX DRAWINGS LIGHT VERTICAL,回退到 '|' 如果无法显示 U+2502。

Specifies the character used for the indicator. This character can be any valid character including Unicode ones if the font supports them. The value nil disables the indicator. When the mode is enabled through the functions display-fill-column-indicator-mode or global-display-fill-column-indicator-mode, they will use the character specified by this variable, if it is non-nil; otherwise Emacs will use the character U+2502 BOX DRAWINGS LIGHT VERTICAL, falling back to ‘|’ if U+2502 cannot be displayed.

fill-column-indicator
fill-column-indicator

指定用于显示指示器的面。它继承了face的默认值shadow,但没有背景颜色。要更改指示器颜色,您只需设置该面的前景色即可。

Specifies the face used to display the indicator. It inherits its default values from the face shadow, but without background color. To change the indicator color, you need only set the foreground color of this face.

在图形显示上,Emacs 可以在边缘指示缓冲区边界。如果启用此功能,第一行和最后一行将在条纹中标记有角度图像。这可以与向上和向下箭头图像组合,指示是否可以滚动窗口。

On graphical displays, Emacs can indicate the buffer boundaries in the fringes. If you enable this feature, the first line and the last line are marked with angle images in the fringes. This can be combined with up and down arrow images which say whether it is possible to scroll the window.

缓冲区局部变量indicate-buffer-boundaries控制如何在边缘中指示缓冲区边界和窗口滚动。如果值为leftright,则角度位图和箭头位图分别显示在左边缘或右边缘。

The buffer-local variable indicate-buffer-boundaries controls how the buffer boundaries and window scrolling is indicated in the fringes. If the value is left or right, both angle and arrow bitmaps are displayed in the left or right fringe, respectively.

如果 value 是一个列表(请参阅Emacs Lisp 参考手册中的关联列表),则每个元素指定其中一个指示符的位置。该 指示符必须是、、、 或之一,它指定列表中不存在的指示符的默认位置。该位置是、、 或之一 ,指定不显示该指示符。 (indicator . position)topbottomupdowntleftrightnil

If value is an alist (see Association Lists in the Emacs Lisp Reference Manual), each element (indicator . position) specifies the position of one of the indicators. The indicator must be one of top, bottom, up, down, or t which specifies the default position for the indicators not present in the alist. The position is one of left, right, or nil which specifies not to show this indicator.

例如,((top . left) (t . right))将顶部角度位图放置在左边缘,将底部角度位图放置在右边缘,并将两个箭头位图放置在右边缘。要仅显示左边缘的角度位图,而不显示箭头位图,请使用((top . left) (bottom . left))

For example, ((top . left) (t . right)) places the top angle bitmap in left fringe, the bottom angle bitmap in right fringe, and both arrow bitmaps in right fringe. To show just the angle bitmaps in the left fringe, but no arrow bitmaps, use ((top . left) (bottom . left)).


15.17 无用的空白

15.17 Useless Whitespace

很容易在行尾留下不必要的空格,或在缓冲区末尾留下空行,而自己却没有意识到。在大多数情况下,这个尾随空格没有任何作用,但有时它可能会很麻烦。

It is easy to leave unnecessary spaces at the end of a line, or empty lines at the end of a buffer, without realizing it. In most cases, this trailing whitespace has no effect, but sometimes it can be a nuisance.

show-trailing-whitespace您可以通过将缓冲区局部变量设置为 来使行尾的尾随空白可见t。然后 Emacs 使用 Face 来显示尾随空白 trailing-whitespace

You can make trailing whitespace at the end of a line visible by setting the buffer-local variable show-trailing-whitespace to t. Then Emacs displays trailing whitespace, using the face trailing-whitespace.

当点位于包含空格的行的末尾时,此功能不适用。严格来说,这仍然是尾随空白,但在这种情况下特别显示它在您输入新文本时看起来很难看。在这种特殊情况下,点的位置足以表明空间存在。

This feature does not apply when point is at the end of the line containing the whitespace. Strictly speaking, that is trailing whitespace nonetheless, but displaying it specially in that case looks ugly while you are typing in new text. In this special case, the location of point is enough to show you that the spaces are present.

键入M-x delete-trailing-whitespace以删除所有尾随空格。该命令删除缓冲区中每行末尾的所有多余空格以及缓冲区末尾的所有空行;要忽略后者,请将变量更改delete-trailing-linesnil。如果该区域处于活动状态,则该命令会删除该区域中每行末尾的多余空格。

Type M-x delete-trailing-whitespace to delete all trailing whitespace. This command deletes all extra spaces at the end of each line in the buffer, and all empty lines at the end of the buffer; to ignore the latter, change the variable delete-trailing-lines to nil. If the region is active, the command instead deletes extra spaces at the end of each line in the region.

在图形显示上,Emacs 可以用左边缘的小图像指示窗口末尾未使用的行(请参阅窗口边缘)。该图像出现的屏幕行与任何缓冲区文本都不对应,因此缓冲区末尾的空白行会很突出,因为它们缺少该图像。要启用此功能,请将缓冲区局部变量设置indicate-empty-lines为非值nil。您可以通过设置此变量的默认值(例如 )来为所有新缓冲区启用或禁用此功能(setq-default indicate-empty-lines t)

On graphical displays, Emacs can indicate unused lines at the end of the window with a small image in the left fringe (see Window Fringes). The image appears for screen lines that do not correspond to any buffer text, so blank lines at the end of the buffer stand out because they lack this image. To enable this feature, set the buffer-local variable indicate-empty-lines to a non-nil value. You can enable or disable this feature for all new buffers by setting the default value of this variable, e.g., (setq-default indicate-empty-lines t).

空白模式是一种缓冲区本地次要模式,可让您通过用特殊的面绘制空白字符或将它们显示为特殊的字形来可视化缓冲区中的多种空白。要切换此模式,请键入M-x whitespace-mode。可视化的空白类型由列表变量决定whitespace-style。通过键入 可以在当前缓冲区中打开或关闭该列表中的各个元素 。以下是可能元素的部分列表(有关完整列表,请参阅变量的文档): M-x whitespace-toggle-options

Whitespace mode is a buffer-local minor mode that lets you visualize many kinds of whitespace in the buffer, by either drawing the whitespace characters with a special face or displaying them as special glyphs. To toggle this mode, type M-x whitespace-mode. The kinds of whitespace visualized are determined by the list variable whitespace-style. Individual elements in that list can be toggled on or off in the current buffer by typing M-x whitespace-toggle-options. Here is a partial list of possible elements (see the variable’s documentation for the full list):

face
face

启用所有使用特殊面孔的可视化。该元素具有特殊含义:如果列表中不存在该元素,则除了 、 和 之外,其他任何可视化效果都space-mark不会tab-mark生效newline-mark

Enable all visualizations which use special faces. This element has a special meaning: if it is absent from the list, none of the other visualizations take effect except space-mark, tab-mark, and newline-mark.

trailing
trailing

突出显示尾随空白。

Highlight trailing whitespace.

tabs
tabs

突出显示制表符。

Highlight tab characters.

spaces
spaces

突出显示空格和不间断空格字符。

Highlight space and non-breaking space characters.

lines
lines

突出显示长度超过 80 列的行。要更改列限制,请自定义变量whitespace-line-column

Highlight lines longer than 80 columns. To change the column limit, customize the variable whitespace-line-column.

newline
newline

突出显示换行符。

Highlight newlines.

missing-newline-at-eof
missing-newline-at-eof

如果缓冲区不以换行符结尾,则突出显示最后一个字符。

Highlight the final character if the buffer doesn’t end with a newline character.

empty
empty

突出显示缓冲区开头和/或结尾处的空行。

Highlight empty lines at the beginning and/or end of the buffer.

big-indent
big-indent

突出显示太深的缩进。默认情况下,任何至少 4 个连续制表符或 32 个连续空格字符的序列都会突出显示。要更改它,请自定义正则表达式 whitespace-big-indent-regexp

Highlight too-deep indentation. By default any sequence of at least 4 consecutive tab characters or 32 consecutive space characters is highlighted. To change that, customize the regular expression whitespace-big-indent-regexp.

space-mark
space-mark

使用特殊的字形绘制空格和不间断字符。

Draw space and non-breaking characters with a special glyph.

tab-mark
tab-mark

用特殊的字形绘制制表符。

Draw tab characters with a special glyph.

newline-mark
newline-mark

用特殊的字形绘制换行符。

Draw newline characters with a special glyph.

全局空白模式是一种全局次要模式,可让您可视化所有缓冲区中的空白。要切换各个功能,请使用 M-x global-whitespace-toggle-options

Global Whitespace mode is a global minor mode that lets you visualize whitespace in all buffers. To toggle individual features, use M-x global-whitespace-toggle-options.


15.18 选择性显示

15.18 Selective Display

Emacs 能够隐藏缩进超过给定列数的行。您可以使用它来概述程序的一部分。

Emacs has the ability to hide lines indented more than a given number of columns. You can use this to get an overview of a part of a program.

要隐藏当前缓冲区中的行,请键入C-x $ ( set-selective-display) 和数字参数n。然后,至少有n列缩进的行就会从屏幕上消失。它们存在的唯一迹象是三个点('……') 出现在每条可见行的末尾,后面跟着一个或多个隐藏行。

To hide lines in the current buffer, type C-x $ (set-selective-display) with a numeric argument n. Then lines with at least n columns of indentation disappear from the screen. The only indication of their presence is that three dots (‘’) appear at the end of each visible line that is followed by one or more hidden ones.

命令C-nC-p穿过隐藏线,就好像它们不存在一样。

The commands C-n and C-p move across the hidden lines as if they were not there.

隐藏线仍然存在于缓冲区中,并且大多数编辑命令照常看到它们,因此您可能会在隐藏文本的中间找到点。发生这种情况时,光标出现在上一行末尾的三个点之后。如果点位于可见行的末尾,在结束它的换行符之前,光标将出现在三个点之前。

The hidden lines are still present in the buffer, and most editing commands see them as usual, so you may find point in the middle of the hidden text. When this happens, the cursor appears at the end of the previous line, after the three dots. If point is at the end of the visible line, before the newline that ends it, the cursor appears before the three dots.

要使所有行再次可见,请键入C-x $不带参数的内容。

To make all lines visible again, type C-x $ with no argument.

如果将该变量设置selective-display-ellipsesnil,则三个点不会出现在隐藏线之前的行的末尾。那么就没有隐藏线的可见指示。该变量设置后自动成为本地变量。

If you set the variable selective-display-ellipses to nil, the three dots do not appear at the end of a line that precedes hidden lines. Then there is no visible indication of the hidden lines. This variable becomes local automatically when set.

另请参阅大纲模式,了解隐藏缓冲区中部分文本的另一种方法。

See also Outline Mode for another way to hide part of the text in a buffer.


15.19 可选模式线功能

15.19 Optional Mode Line Features

缓冲区百分比pos表示缓冲区在窗口顶部上方的百分比。您还可以通过键入M-x size-indication-mode打开大小指示模式来显示缓冲区的大小。大小将立即显示在缓冲区百分比之后,如下所示:

The buffer percentage pos indicates the percentage of the buffer above the top of the window. You can additionally display the size of the buffer by typing M-x size-indication-mode to turn on Size Indication mode. The size will be displayed immediately following the buffer percentage like this:

大小位置
pos of size

这里的大小是缓冲区中字符数的人类可读表示,这意味着 'k' 对于 10^3,'中号' 对于 10^6,'G' 为 10^9 等,用于缩写。

Here size is the human readable representation of the number of characters in the buffer, which means that ‘k’ for 10^3, ‘M’ for 10^6, ‘G’ for 10^9, etc., are used to abbreviate.

当启用行号模式时,点的当前行号出现在模式行中。使用命令M-x line-number-mode打开和关闭该模式;通常它是打开的。行号出现在缓冲区百分比pos之后,带有字母 'L' 来表明它是什么。

The current line number of point appears in the mode line when Line Number mode is enabled. Use the command M-x line-number-mode to turn this mode on and off; normally it is on. The line number appears after the buffer percentage pos, with the letter ‘L’ to indicate what it is.

同样,您可以通过使用 打开列号模式来显示当前列号M-x column-number-mode。列号由字母 ' 表示C'。但是,当这两种模式都启用时,行号和列号将显示在括号中,行号在前,而不是用 'L' 和 'C'。例如: '(561,2)'。有关次要模式以及如何使用这些命令的更多信息,请 参阅次要模式。

Similarly, you can display the current column number by turning on Column Number mode with M-x column-number-mode. The column number is indicated by the letter ‘C’. However, when both of these modes are enabled, the line and column numbers are displayed in parentheses, the line number first, rather than with ‘L’ and ‘C’. For example: ‘(561,2)’. See Minor Modes, for more information about minor modes and about how to use these commands.

在列号模式下,显示的列号从窗口的左边距开始从零开始计数。如果您希望显示的列号从 1 开始计数,您可以设置 column-number-indicator-zero-basednil

In Column Number mode, the displayed column number counts from zero starting at the left margin of the window. If you would prefer for the displayed column number to count from one, you may set column-number-indicator-zero-based to nil.

如果您缩小了缓冲区(请参阅缩小范围),则显示的行号是相对于缓冲区的可访问部分而言的。因此,它不适合作为 的参数goto-line。 (该命令what-line显示相对于整个文件的行号。)您可以使用goto-line-relative命令将点移动到相对于缩小的缓冲区的可访问部分的行。

If you have narrowed the buffer (see Narrowing), the displayed line number is relative to the accessible portion of the buffer. Thus, it isn’t suitable as an argument to goto-line. (The command what-line shows the line number relative to the whole file.) You can use goto-line-relative command to move point to the line relative to the accessible portion of the narrowed buffer.

如果缓冲区非常大(大于 的值 line-number-display-limit),Emacs 将不会计算行号,因为那样会太慢;因此,行号不会出现在模式行上。要删除此限制,请设置 line-number-display-limitnil

If the buffer is very large (larger than the value of line-number-display-limit), Emacs won’t compute the line number, because that would be too slow; therefore, the line number won’t appear on the mode-line. To remove this limit, set line-number-display-limit to nil.

如果缓冲区中的行太长,行号计算也会很慢。因此,如果点附近行的平均宽度(以字符为单位)大于 的值,Emacs 不会显示行号line-number-display-limit-width。默认值为 200 个字符。

Line-number computation can also be slow if the lines in the buffer are too long. For this reason, Emacs doesn’t display line numbers if the average width, in characters, of lines near point is larger than the value of line-number-display-limit-width. The default value is 200 characters.

Emacs 可以选择在所有模式行中显示时间和系统负载。要启用此功能,请键入M-x display-time或自定义选项display-time-mode。添加到模式行的信息如下所示:

Emacs can optionally display the time and system load in all mode lines. To enable this feature, type M-x display-time or customize the option display-time-mode. The information added to the mode line looks like this:

:下午l.ll
hh:mmPM l.ll

这里hhmm是小时和分钟,后面总是跟着 '' 或者 '下午'。 l.ll是整个系统中正在运行或准备运行(即正在等待可用处理器)的进程在最后几分钟内收集的平均数量。 (如果您的操作系统不支持,某些字段可能会丢失。)如果您喜欢以 24 小时格式显示时间,请将变量设置display-time-24hr-formatt

Here hh and mm are the hour and minute, followed always by ‘AM’ or ‘PM’. l.ll is the average number, collected for the last few minutes, of processes in the whole system that were either running or ready to run (i.e., were waiting for an available processor). (Some fields may be missing if your operating system cannot support them.) If you prefer time display in 24-hour format, set the variable display-time-24hr-format to t.

这个单词 '邮件如果有您尚未阅读的邮件,则会在负载级别后出现。在图形显示上,您可以使用图标代替 '邮件' 通过定制 display-time-use-mail-icon;这可能会节省模式行上的一些空间。您可以进行自定义display-time-mail-face以使邮件指示器突出。用于display-time-mail-file指定要检查的邮件文件,或设置 display-time-mail-directory指定要检查传入邮件的目录(目录中任何非空常规文件都被视为新到达的邮件)。

The word ‘Mail’ appears after the load level if there is mail for you that you have not read yet. On graphical displays, you can use an icon instead of ‘Mail’ by customizing display-time-use-mail-icon; this may save some space on the mode line. You can customize display-time-mail-face to make the mail indicator prominent. Use display-time-mail-file to specify the mail file to check, or set display-time-mail-directory to specify the directory to check for incoming mail (any nonempty regular file in the directory is considered to be newly arrived mail).

display-battery-mode在笔记本电脑上运行 Emacs 时,您可以通过使用命令或自定义变量 在模式行上显示电池电量 display-battery-mode。该变量 battery-mode-line-format决定电池电量的显示方式;确切的模式行消息取决于操作系统,它通常显示当前电池电量占总电量的百分比。中的函数 battery-update-functions在更新模式行后运行,可用于根据电池状态触发操作。

When running Emacs on a laptop computer, you can display the battery charge on the mode-line, by using the command display-battery-mode or customizing the variable display-battery-mode. The variable battery-mode-line-format determines the way the battery charge is displayed; the exact mode-line message depends on the operating system, and it usually shows the current battery charge as a percentage of the total charge. The functions in battery-update-functions are run after updating the mode line, and can be used to trigger actions based on the battery status.

在图形显示上,模式线被绘制为 3D 框。如果您不喜欢这种效果,可以通过自定义脸部 mode-line并将其box属性设置为 来 禁用它nil。请参阅自定义面

On graphical displays, the mode line is drawn as a 3D box. If you don’t like this effect, you can disable it by customizing the mode-line face and setting its box attribute to nil. See Customizing Faces.

默认情况下,未选定窗口的模式线显示在不同的面上,称为mode-line-inactive。面上仅显示选定的窗口mode-line。这有助于显示选择了哪个窗口。当选择迷你缓冲区时,由于它没有模式行,因此激活迷你缓冲区的窗口将使用mode-line;显示其模式行。因此,对迷你缓冲区的普通输入不会更改任何模式行。

By default, the mode line of nonselected windows is displayed in a different face, called mode-line-inactive. Only the selected window is displayed in the mode-line face. This helps show which window is selected. When the minibuffer is selected, since it has no mode line, the window from which you activated the minibuffer has its mode line displayed using mode-line; as a result, ordinary entry to the minibuffer does not change any mode lines.

mode-line-inactive您可以通过将变量设置 mode-line-in-non-selected-windows为来禁用使用nil;然后所有模式线都显示在mode-line脸上。

You can disable use of mode-line-inactive by setting variable mode-line-in-non-selected-windows to nil; then all mode lines are displayed in the mode-line face.

eol-mnemonic-unix您可以通过将每个变量、 eol-mnemonic-doseol-mnemonic-mac和 设置eol-mnemonic-undecided为您喜欢的字符串 来自定义每种行尾格式的模式行显示。

You can customize the mode line display for each of the end-of-line formats by setting each of the variables eol-mnemonic-unix, eol-mnemonic-dos, eol-mnemonic-mac, and eol-mnemonic-undecided to the strings you prefer.


15.20 文本如何显示

15.20 How Text Is Displayed

大多数字符都是打印字符:当它们出现在缓冲区中时,它们会按字面显示在屏幕上。打印字符包括ASCII数字、字母和标点符号,以及许多非ASCII字符。

Most characters are printing characters: when they appear in a buffer, they are displayed literally on the screen. Printing characters include ASCII numbers, letters, and punctuation characters, as well as many non-ASCII characters.

ASCII字符集包含非打印控制字符。其中两个是特殊显示的:换行符(Unicode 代码点 U+000A)通过开始新行来显示,而制表符(U+0009)显示为延伸到下一个制表位列的空格(通常每 8 列)。每个制表符的空格数由缓冲区局部变量 控制tab-width,该变量必须具有 1 到 1000 之间的整数值(含 1 和 1000)。请注意,缓冲区中制表符的显示方式与TAB作为命令 的定义无关。

The ASCII character set contains non-printing control characters. Two of these are displayed specially: the newline character (Unicode code point U+000A) is displayed by starting a new line, while the tab character (U+0009) is displayed as a space that extends to the next tab stop column (normally every 8 columns). The number of spaces per tab is controlled by the buffer-local variable tab-width, which must have an integer value between 1 and 1000, inclusive. Note that the way the tab character in the buffer is displayed has nothing to do with the definition of TAB as a command.

代码低于 U+0020(八进制 40,十进制 32)的其他ASCII控制字符显示为脱字号 ('^')后面是角色的非控制版本,带有脸部escape-glyph。例如,'对照-A' 字符 U+0001 显示为 '^A'。

Other ASCII control characters, whose codes are below U+0020 (octal 40, decimal 32), are displayed as a caret (‘^’) followed by the non-control version of the character, with the escape-glyph face. For instance, the ‘control-A’ character, U+0001, is displayed as ‘^A’.

代码为 U+0080(八进制 200)到 U+009F(八进制 237)的原始字节显示为八进制转义序列,并带有escape-glyph字符。例如,字符代码 U+0098(八进制 230)显示为 '230 日元'。如果将缓冲区局部变量更改ctl-arrownil,则ASCII控制字符也会显示为八进制转义序列而不是脱字符转义序列。 (您还可以请求以十六进制显示原始字节,请参阅display-raw-bytes-as-hex。)

The raw bytes with codes U+0080 (octal 200) through U+009F (octal 237) are displayed as octal escape sequences, with the escape-glyph face. For instance, character code U+0098 (octal 230) is displayed as ‘\230’. If you change the buffer-local variable ctl-arrow to nil, the ASCII control characters are also displayed as octal escape sequences instead of caret escape sequences. (You can also request that raw bytes be shown in hex, see display-raw-bytes-as-hex.)

某些非ASCII字符与ASCII空格或连字符(减号)具有相同的外观 。如果这些字符在您没有意识到的情况下被输入到缓冲区中,例如通过猛拉,它们可能会导致问题;例如,源代码编译器通常不会将非ASCII空格视为空白字符。为了解决这个问题,Emacs 专门显示了这样的字符:它显示 U+00A0 NO-BREAK SPACE和其他来自 Unicode 水平空格类的字符 nobreak-space,并显示 U+00AD SOFT HYPHEN、 U+2010 HYPHEN和 U +2011脸部不间断连字符nobreak-hyphen。要禁用此功能,请将变量更改nobreak-char-displaynil。如果您为该变量指定非值nil和非t值,Emacs 会显示突出显示的反斜杠后跟空格或连字符等字符。

Some non-ASCII characters have the same appearance as an ASCII space or hyphen (minus) character. Such characters can cause problems if they are entered into a buffer without your realization, e.g., by yanking; for instance, source code compilers typically do not treat non-ASCII spaces as whitespace characters. To deal with this problem, Emacs displays such characters specially: it displays U+00A0 NO-BREAK SPACE and other characters from the Unicode horizontal space class with the nobreak-space face, and it displays U+00AD SOFT HYPHEN, U+2010 HYPHEN, and U+2011 NON-BREAKING HYPHEN with the nobreak-hyphen face. To disable this, change the variable nobreak-char-display to nil. If you give this variable a non-nil and non-t value, Emacs instead displays such characters as a highlighted backslash followed by a space or hyphen.

您可以通过显示表自定义任何特定字符代码的显示方式。请参阅Emacs Lisp 参考手册中的显示表

You can customize the way any particular character code is displayed by means of a display table. See Display Tables in The Emacs Lisp Reference Manual.

在图形显示上,某些字符在 Emacs 可用的任何字体中可能没有字形。这些无字形字符通常显示为包含十六进制字符代码的框。同样,在文本终端上,无法使用终端编码(请参阅终端 I/O 的编码系统)显示的字符通常显示为问号。您可以通过自定义变量来控制显示方式glyphless-char-display-control。您还可以自定义glyphless-char脸部,使这些角色在显示时更加突出。有关详细信息, 请参阅Emacs Lisp 参考手册中的无字形字符显示。

On graphical displays, some characters may have no glyphs in any of the fonts available to Emacs. These glyphless characters are normally displayed as boxes containing the hexadecimal character code. Similarly, on text terminals, characters that cannot be displayed using the terminal encoding (see Coding Systems for Terminal I/O) are normally displayed as question signs. You can control the display method by customizing the variable glyphless-char-display-control. You can also customize the glyphless-char face to make these characters more prominent on display. See Glyphless Character Display in The Emacs Lisp Reference Manual, for details.

次要glyphless-display-mode模式可用于切换当前缓冲区中无字形字符的显示。无字形字符将显示为框,其中包含其名称的首字母缩略词。

The glyphless-display-mode minor mode can be used to toggle the display of glyphless characters in the current buffer. The glyphless characters will be displayed as boxes with acronyms of their names inside.

Emacs 尝试确定弯曲的引号和是否 可以显示在当前显示器上。默认情况下,如果情况确实如此,那么 Emacs 将翻译ASCII引号 ('`' 和 ''') ,当它们出现在消息和帮助文本中时,改为这些弯曲的引号。您可以通过自定义用户选项来影响或禁止此转换text-quoting-style(请参阅《Emacs Lisp 参考手册》中的文档中的键)。

Emacs tries to determine if the curved quotes and can be displayed on the current display. By default, if this seems to be so, then Emacs will translate the ASCII quotes (‘`’ and ‘'’), when they appear in messages and help texts, to these curved quotes. You can influence or inhibit this translation by customizing the user option text-quoting-style (see Keys in Documentation in The Emacs Lisp Reference Manual).

如果已知弯曲引号、 和看起来就像ASCII字符,则它们会与面一起显示homoglyph。已知不可显示的弯曲引号显示为其ASCII近似值 '`',''', 和 ''用homoglyph脸。

If the curved quotes , , , and are known to look just like ASCII characters, they are shown with the homoglyph face. Curved quotes that are known not to be displayable are shown as their ASCII approximations ‘`’, ‘'’, and ‘"’ with the homoglyph face.


15.21 显示光标

15.21 Displaying the Cursor

在文本终端上,光标的外观由终端控制,很大程度上不受 Emacs 的控制。某些终端提供两种不同的光标:可见的静态光标和非常明显的闪烁光标。默认情况下,Emacs 使用非常明显的光标,并在启动或恢复 Emacs 时切换到它。如果该变量visible-cursornil在 Emacs 启动或恢复时发生的,则它使用普通光标。

On a text terminal, the cursor’s appearance is controlled by the terminal, largely out of the control of Emacs. Some terminals offer two different cursors: a visible static cursor, and a very visible blinking cursor. By default, Emacs uses the very visible cursor, and switches to it when you start or resume Emacs. If the variable visible-cursor is nil when Emacs starts or resumes, it uses the normal cursor.

在图形显示上,可以更改文本光标的更多属性。要自定义其颜色,请更改:background 指定面的属性cursor(请参阅自定义面)。 (该面的其他属性没有影响;光标下显示的文本是使用框架的背景颜色绘制的。)要更改其形状,请自定义缓冲区局部变量 cursor-type;可能的值是box(默认), (框光标成为大于任一维度中的 size像素的蒙版图像下的空心框), (空心框),(垂直条), ( n像素宽的垂直条),(a水平条)、 ( n像素高的水平条 )或(根本没有光标)。 (box . size)hollowbar(bar . n)hbar(hbar . n)nil

On a graphical display, many more properties of the text cursor can be altered. To customize its color, change the :background attribute of the face named cursor (see Customizing Faces). (The other attributes of this face have no effect; the text shown under the cursor is drawn using the frame’s background color.) To change its shape, customize the buffer-local variable cursor-type; possible values are box (the default), (box . size) (box cursor becoming a hollow box under masked images larger than size pixels in either dimension), hollow (a hollow box), bar (a vertical bar), (bar . n) (a vertical bar n pixels wide), hbar (a horizontal bar), (hbar . n) (a horizontal bar n pixels tall), or nil (no cursor at all).

默认情况下,如果 Emacs 在此期间没有收到任何输入,光标将在闪烁 10 次后停止闪烁;任何输入事件都会重新开始计数。您可以自定义变量blink-cursor-blinks来控制:它的值表示在停止之前在没有输入的情况下闪烁多少次。将该变量设置为零或负值将使光标永远闪烁。要完全禁用光标闪烁,请将变量更改blink-cursor-modenil (请参阅轻松自定义界面),或添加行

By default, the cursor stops blinking after 10 blinks, if Emacs does not get any input during that time; any input event restarts the count. You can customize the variable blink-cursor-blinks to control that: its value says how many times to blink without input before stopping. Setting that variable to a zero or negative value will make the cursor blink forever. To disable cursor blinking altogether, change the variable blink-cursor-mode to nil (see Easy Customization Interface), or add the line

  (闪烁光标模式 0)
  (blink-cursor-mode 0)

到你的初始化文件。或者,您可以通过自定义列表变量来更改光标闪烁时的外观 blink-cursor-alist。列表中的每个元素都应采用以下形式;这意味着,如果光标在闪烁时 显示为开启型(其中开启型是上述光标类型之一),则当其闪烁时 显示为关闭型。(on-type . off-type)

to your init file. Alternatively, you can change how the cursor looks when it blinks off by customizing the list variable blink-cursor-alist. Each element in the list should have the form (on-type . off-type); this means that if the cursor is displayed as on-type when it blinks on (where on-type is one of the cursor types described above), then it is displayed as off-type when it blinks off.

某些字符(例如制表符)非常宽。当光标位于此类字符上时,通常会使用默认字符宽度绘制该字符。通过将变量更改 x-stretch-cursor为非值,可以使光标伸展以覆盖宽字符nil

Some characters, such as tab characters, are extra wide. When the cursor is positioned over such a character, it is normally drawn with the default character width. You can make the cursor stretch to cover wide characters, by changing the variable x-stretch-cursor to a non-nil value.

光标通常在未选定的窗口中显示为不闪烁的空心框。 (对于条形光标,它显示为较细的条形。)要关闭未选定窗口中的光标,请将变量更改cursor-in-non-selected-windowsnil

The cursor normally appears in non-selected windows as a non-blinking hollow box. (For a bar cursor, it instead appears as a thinner bar.) To turn off cursors in non-selected windows, change the variable cursor-in-non-selected-windows to nil.

为了使光标更加明显,您可以使用 HL 线模式,这是一种突出显示包含点的线的次要模式。用于M-x hl-line-mode在当前缓冲区中启用或禁用它。 M-x global-hl-line-mode全局启用或禁用相同模式。

To make the cursor even more visible, you can use HL Line mode, a minor mode that highlights the line containing point. Use M-x hl-line-mode to enable or disable it in the current buffer. M-x global-hl-line-mode enables or disables the same mode globally.


15.22 行截断

15.22 Line Truncation

作为延续的替代方案(请参阅延续行),Emacs 可以通过截断来显示长行。这意味着所有不适合屏幕或窗口宽度的字符根本不会出现。在图形显示上,边缘中的小直箭头表示线两端的截断。在文本终端上,这用 ' 表示$' 在最右边和/或最左边的列中签名。

As an alternative to continuation (see Continuation Lines), Emacs can display long lines by truncation. This means that all the characters that do not fit in the width of the screen or window do not appear at all. On graphical displays, a small straight arrow in the fringe indicates truncation at either end of the line. On text terminals, this is indicated with ‘$’ signs in the rightmost and/or leftmost columns.

水平滚动会自动导致行截断(请参阅水平滚动)。您可以使用命令C-x x t ( toggle-truncate-lines) 显式启用特定缓冲区的行截断。这是通过本地更改变量来实现的truncate-lines。如果该变量为非nil,则长行将被截断;如果是nil,它们将继续显示在多个屏幕行上。以任何方式设置变量truncate-lines都会使其成为当前缓冲区的本地变量;在此之前,默认值(通常为nil)一直有效。

Horizontal scrolling automatically causes line truncation (see Horizontal Scrolling). You can explicitly enable line truncation for a particular buffer with the command C-x x t (toggle-truncate-lines). This works by locally changing the variable truncate-lines. If that variable is non-nil, long lines are truncated; if it is nil, they are continued onto multiple screen lines. Setting the variable truncate-lines in any way makes it local to the current buffer; until that time, the default value, which is normally nil, is in effect.

由于行截断和自动换行(在下一节中描述)是矛盾的,因此toggle-truncate-lines在打开行截断时禁用自动换行。

Since line truncation and word wrap (described in the next section) are contradictory, toggle-truncate-lines disables word wrap when it turns on line truncation.

如果分割窗口变得太窄,Emacs 可能会自动启用行截断。有关控制此操作的 变量, 请参阅分割窗口。truncate-partial-width-windows

If a split window becomes too narrow, Emacs may automatically enable line truncation. See Splitting Windows, for the variable truncate-partial-width-windows which controls this.


15.23 视线模式

15.23 Visual Line Mode

普通续行的另一种替代方法(请参阅续行)是使用自动换行。这里,每条长逻辑行被分成两条或更多条屏幕线,或“视线”,就像普通的行延续一样。然而,Emacs 尝试在靠近窗口右边缘的字边界处换行。 (如果该行的方向是从右到左,则它会在左窗口边缘处换行。)这使得文本更易于阅读,因为换行不会发生在单词中间。

Another alternative to ordinary line continuation (see Continuation Lines) is to use word wrap. Here, each long logical line is divided into two or more screen lines, or “visual lines”, like in ordinary line continuation. However, Emacs attempts to wrap the line at word boundaries near the right window edge. (If the line’s direction is right-to-left, it is wrapped at the left window edge instead.) This makes the text easier to read, as wrapping does not occur in the middle of words.

自动换行由 Visual Line 模式(一种可选的次要模式)启用。要在当前缓冲区中打开 Visual Line 模式,请键入M-x visual-line-mode;重复此命令会将其关闭。您还可以使用菜单栏打开 Visual Line 模式:在“选项”菜单中,选择“此缓冲区中的换行' 子菜单,后跟 '自动换行(视觉行模式)' 菜单项。当启用 Visual Line 模式时,模式行显示字符串 '' 在模式显示中。该命令M-x global-visual-line-mode在所有缓冲区中切换可视线模式。

Word wrap is enabled by Visual Line mode, an optional minor mode. To turn on Visual Line mode in the current buffer, type M-x visual-line-mode; repeating this command turns it off. You can also turn on Visual Line mode using the menu bar: in the Options menu, select the ‘Line Wrapping in this Buffer’ submenu, followed by the ‘Word Wrap (Visual Line mode)’ menu item. While Visual Line mode is enabled, the mode line shows the string ‘wrap’ in the mode display. The command M-x global-visual-line-mode toggles Visual Line mode in all buffers.

由于自动换行和行截断(在上一节中描述)是矛盾的,因此打开visual-line-mode 会禁用行截断。

Since word wrap and line truncation (described in the previous section) are contradictory, turning on visual-line-mode disables line truncation.

在 Visual Line 模式下,某些编辑命令适用于屏幕行而不是逻辑行:( ) 移动到屏幕行的开头,C-a( ) 移动到屏幕行的结尾,以及 ( ) 删除屏幕结尾的文本线。 beginning-of-visual-lineC-eend-of-visual-lineC-kkill-visual-line

In Visual Line mode, some editing commands work on screen lines instead of logical lines: C-a (beginning-of-visual-line) moves to the beginning of the screen line, C-e (end-of-visual-line) moves to the end of the screen line, and C-k (kill-visual-line) kills text to the end of the screen line.

要按逻辑行移动,请使用命令M-x next-logical-lineM-x previous-logical-line。无论是否启用视觉线模式,这些移动分别指向下一个逻辑线和上一个逻辑线。如果您经常使用这些命令,则为它们分配键绑定可能会很方便。请参阅在初始化文件中重新绑定键

To move by logical lines, use the commands M-x next-logical-line and M-x previous-logical-line. These move point to the next logical line and the previous logical line respectively, regardless of whether Visual Line mode is enabled. If you use these commands frequently, it may be convenient to assign key bindings to them. See Rebinding Keys in Your Init File.

默认情况下,自动换行不显示边缘指示符。视觉行模式通常用于编辑包含许多长逻辑行的文件,因此为每个换行行设置边缘指示器会在视觉上分散注意力。您可以通过自定义变量来更改此设置visual-line-fringe-indicators

By default, word-wrapped lines do not display fringe indicators. Visual Line mode is often used to edit files that contain many long logical lines, so having a fringe indicator for each wrapped line would be visually distracting. You can change this by customizing the variable visual-line-fringe-indicators.

SPC默认情况下,Emacs 仅在和等空白字符后换行 TAB,但在 等空白字符后不换行EN QUAD。 Emacs 提供了一种名为 的次要模式, word-wrap-whitespace-mode可以在当前模式下打开自动换行,并根据用户选项设置换行的字符word-wrap-whitespace-characters。该模式还有一个全球化版本,称为 global-word-wrap-whitespace-mode.

By default, Emacs only breaks lines after whitespace characters like SPC and TAB, but does not break after whitespace characters like EN QUAD. Emacs provides a minor mode called word-wrap-whitespace-mode that switches on word wrapping in the current mode, and sets up which characters to wrap lines on based on the word-wrap-whitespace-characters user option. There’s also a globalized version of that mode called global-word-wrap-whitespace-mode.

当 CJK 和拉丁文本混合在一起时,只有在空格字符后进行中断才会产生不正确的结果(因为 CJK 字符不使用空格来分隔单词)。您可以自定义选项word-wrap-by-category以允许 Emacs 在任何带有 ' 的字符后换行|' 类别(请参阅Emacs Lisp 参考手册中的类别),它为 CJK 字符提供了更好的支持。另外,如果使用“Customize”设置此变量,Emacs 会自动加载避难所。什么时候避难所加载后,Emacs 在断行时遵循避头尾规则。这意味着带有 ' 的字符>' 类别不会出现在行首(例如, U+FF0C FULLWIDTH COMMA),并且带有 ' 的字符<' 类别不会出现在行尾(例如, U+300A LEFT DOUBLE ANGLE BACKET)。您可以使用命令char-category-set和 查看字符的类别集category-set-mnemonics,或者通过C-u C-x =在字符上键入点并查看报告中的“类别”部分。您可以使用命令向角色添加类别 modify-category-entry

Only breaking after whitespace character produces incorrect results when CJK and Latin text are mixed together (because CJK characters don’t use whitespace to separate words). You can customize the option word-wrap-by-category to allow Emacs to break lines after any character with ‘|’ category (see Categories in the Emacs Lisp Reference Manual), which provides better support for CJK characters. Also, if this variable is set using Customize, Emacs automatically loads kinsoku.el. When kinsoku.el is loaded, Emacs respects kinsoku rules when breaking lines. That means characters with the ‘>’ category don’t appear at the beginning of a line (e.g., U+FF0C FULLWIDTH COMMA), and characters with the ‘<’ category don’t appear at the end of a line (e.g., U+300A LEFT DOUBLE ANGLE BRACKET). You can view the category set of a character using the commands char-category-set and category-set-mnemonics, or by typing C-u C-x = with point on the character and looking at the “category” section in the report. You can add categories to a character using the command modify-category-entry.


15.24 显示定制

15.24 Customization of Display

本节介绍控制 Emacs 屏幕外观的各个方面的变量。初级用户可以跳过它。

This section describes variables that control miscellaneous aspects of the appearance of the Emacs screen. Beginning users can skip it.

如果您想让 Emacs 显示缓冲区中每一行的行号,请自定义缓冲区局部变量 display-line-numbers;这是nil默认的。该变量可以有多个不同的值以支持各种行号显示模式:

If you want to have Emacs display line numbers for every line in the buffer, customize the buffer-local variable display-line-numbers; it is nil by default. This variable can have several different values to support various modes of line-number display:

t
t

在显示缓冲区文本的每个非连续屏幕行之前显示(绝对)行号。如果该行是连续行,或者整个屏幕行显示显示或覆盖字符串,则不会对该行进行编号。

Display (an absolute) line number before each non-continuation screen line that displays buffer text. If the line is a continuation line, or if the entire screen line displays a display or an overlay string, that line will not be numbered.

relative
relative

在显示缓冲区文本的非连续行之前显示相对行号。行号是相对于显示点的行而言的,因此随着行距当前行越来越远,行号会上下增长。

Display relative line numbers before non-continuation lines which show buffer text. The line numbers are relative to the line showing point, so the numbers grow both up and down as lines become farther from the current line.

visual
visual

该值使 Emacs 直观地对行进行计数:仅对显示屏上实际显示的行进行计数(忽略文本不可见部分中的任何行),并且换行以消耗多于一个屏幕行的行将被计​​数多次。显示的数字是相对的,如relative上面的值。这在折叠文本的模式中非常方便,例如大纲模式(请参阅大纲模式),以及当您需要移动精确的屏幕行数时。

This value causes Emacs to count lines visually: only lines actually shown on the display will be counted (disregarding any lines in invisible parts of text), and lines which wrap to consume more than one screen line will be numbered that many times. The displayed numbers are relative, as with relative value above. This is handy in modes that fold text, such as Outline mode (see Outline Mode), and when you need to move by exact number of screen lines.

还要别的吗
anything else

任何其他非nil值均被视为t

Any other non-nil value is treated as t.

该命令M-x display-line-numbers-mode提供了一种打开行号显示的便捷方法。该模式有一个全球化的变体,global-display-line-numbers-mode.用户选项 display-line-numbers-type控制这些模式将激活如上所述的行号显示的子模式。

The command M-x display-line-numbers-mode provides a convenient way to turn on display of line numbers. This mode has a globalized variant, global-display-line-numbers-mode. The user option display-line-numbers-type controls which sub-mode of line-number display, described above, these modes will activate.

请注意,即使您display-line-numbers-mode 全局打开,行号也不会显示在迷你缓冲区和工具提示中。

Note that line numbers are not displayed in the minibuffer and in the tooltips, even if you turn on display-line-numbers-mode globally.

当 Emacs 显示相对行号时,可以控制当前行之前显示的数字,该行显示点。默认情况下,Emacs 显示当前行的绝对编号,即使所有其他行号都是相对的。如果将变量自定义display-line-numbers-current-absolute为一个 nil值,则当前行显示的数字将为零。如果您不关心当前行数,并且希望在大缓冲区中为文本留出更多水平空间,这会很方便。

When Emacs displays relative line numbers, you can control the number displayed before the current line, the line showing point. By default, Emacs displays the absolute number of the current line there, even though all the other line numbers are relative. If you customize the variable display-line-numbers-current-absolute to a nil value, the number displayed for the current line will be zero. This is handy if you don’t care about the number of the current line, and want to leave more horizontal space for text in large buffers.

在缩小的缓冲区中(请参阅缩小),行通常从缩小的开始处开始编号。但是,如果将变量自定义display-line-numbers-widen为非值nil ,则行号将忽略任何缩小,并将从缓冲区的第一个字符开始。

In a narrowed buffer (see Narrowing) lines are normally numbered starting at the beginning of the narrowing. However, if you customize the variable display-line-numbers-widen to a non-nil value, line numbers will disregard any narrowing and will start at the first character of the buffer.

如果 的值display-line-numbers-offset非零,则将其添加到每个绝对行号,并且从缓冲区的开头开始对行进行计数,就像display-line-numbers-widen非 一样nil。当设置为零或行号不是绝对时,它不起作用。

If the value of display-line-numbers-offset is non-zero, it is added to each absolute line number, and lines are counted from the beginning of the buffer, as if display-line-numbers-widen were non-nil. It has no effect when set to zero, or when line numbers are not absolute.

在选择性显示模式(请参阅选择性显示)和其他从显示中隐藏许多行的模式(例如大纲和组织模式)中,您可能希望自定义变量 display-line-numbers-width-startdisplay-line-numbers-grow-only,或设置 display-line-numbers-width为足够大的值,以避免偶尔错误计算为行号保留的空间。

In selective display mode (see Selective Display), and other modes that hide many lines from display (such as Outline and Org modes), you may wish to customize the variables display-line-numbers-width-start and display-line-numbers-grow-only, or set display-line-numbers-width to a large enough value, to avoid occasional miscalculations of space reserved for the line numbers.

行号以特殊的面显示line-number。当前行号以不同的面显示, line-number-current-line因此可以使当前行号具有明显的外观,这将有助于定位显示点的行。附加面line-number-major-tickline-number-minor-tick用于突出显示是某些数字的倍数的行号。分别自定义 display-line-numbers-major-tickdisplay-line-numbers-minor-tick来设置这些数字。

The line numbers are displayed in a special face line-number. The current line number is displayed in a different face, line-number-current-line, so you can make the current line’s number have a distinct appearance, which will help locating the line showing point. Additional faces line-number-major-tick and line-number-minor-tick can be used to highlight the line numbers of lines which are a multiple of certain numbers. Customize display-line-numbers-major-tick and display-line-numbers-minor-tick respectively to set those numbers.

如果该变量visible-bell不是 - nil,Emacs 会尝试使整个屏幕闪烁,而它通常会发出可听见的铃声。如果您的终端无法使屏幕闪烁,则此变量无效。

If the variable visible-bell is non-nil, Emacs attempts to make the whole screen blink when it would normally make an audible bell sound. This variable has no effect if your terminal does not have a way to make the screen blink.

该变量echo-keystrokes控制多字符按键的回显;它的值是导致回显开始所需的暂停秒数,或者为零,意味着根本不回显。当有东西需要回显时,该值就会生效。请参阅回声区域

The variable echo-keystrokes controls the echoing of multi-character keys; its value is the number of seconds of pause required to cause echoing to start, or zero, meaning don’t echo at all. The value takes effect when there is something to echo. See The Echo Area.

在图形显示上,如果 Emacs 繁忙,Emacs 将鼠标指针显示为沙漏。要禁用此功能,请将变量设置 display-hourglassnil。该变量 hourglass-delay决定了沙漏显示之前繁忙时间的秒数;默认值为 1。

On graphical displays, Emacs displays the mouse pointer as an hourglass if Emacs is busy. To disable this feature, set the variable display-hourglass to nil. The variable hourglass-delay determines the number of seconds of busy time before the hourglass is shown; the default is 1.

如果鼠标指针位于 Emacs 框架内,则每次键入字符插入文本时,Emacs 都会使其不可见,以防止其遮挡文本。 (准确地说,当您键入自插入字符时会发生隐藏。请参阅插入文本。)移动鼠标指针使其再次可见。要禁用此功能,请将变量设置make-pointer-invisiblenil

If the mouse pointer lies inside an Emacs frame, Emacs makes it invisible each time you type a character to insert text, to prevent it from obscuring the text. (To be precise, the hiding occurs when you type a self-inserting character. See Inserting Text.) Moving the mouse pointer makes it visible again. To disable this feature, set the variable make-pointer-invisible to nil.

在图形显示上,该变量underline-minimum-offset 确定带下划线的文本的基线和下划线之间的最小距离(以像素为单位)。默认值为1;增加它可能会提高某些字体的下划线文本的可读性。 (但是,Emacs 永远不会在当前行区域下方绘制下划线。)该变量x-underline-at-descent-line确定如何绘制带下划线的文本。默认为nil,表示在字体的基线水平上绘制;如果将其更改为 t,Emacs 会在与字体下降线相同的高度绘制下划线。 (如果为带下划线的文本指定了非默认行距,请参阅《Emacs Lisp 参考手册》中的行高,Emacs 会在附加间距下方绘制下划线。)

On graphical displays, the variable underline-minimum-offset determines the minimum distance between the baseline and underline, in pixels, for underlined text. By default, the value is 1; increasing it may improve the legibility of underlined text for certain fonts. (However, Emacs will never draw the underline below the current line area.) The variable x-underline-at-descent-line determines how to draw underlined text. The default is nil, which means to draw it at the baseline level of the font; if you change it to t, Emacs draws the underline at the same height as the font’s descent line. (If non-default line spacing was specified for the underlined text, see Line Height in The Emacs Lisp Reference Manual, Emacs draws the underline below the additional spacing.)

该变量overline-margin指定文本上方的上划线的垂直位置,包括上划线本身的高度(以像素为单位);默认值为 2。

The variable overline-margin specifies the vertical position of an overline above the text, including the height of the overline itself, in pixels; the default is 2.

在某些文本终端上,粗体和反色视频一起会导致文本难以阅读。在这种情况下,使用tty-suppress-bold-inverse-default-colors非参数调用该函数 nil 可以抑制粗体的影响。

On some text terminals, bold face and inverse video together result in text that is hard to read. Call the function tty-suppress-bold-inverse-default-colors with a non-nil argument to suppress the effect of bold-face in this case.

原始字节默认以八进制格式显示,例如十进制值为 128 的字节显示为\200。要将显示更改为 的十六进制格式\x80,请将变量设置display-raw-bytes-as-hext。当从包含 Emacs 会话的终端复制文本时,或者当终端的escape-glyph外观看起来像默认外观时,解释原始字节时可能需要小心 。例如,默认情况下 Emacs 显示四个字符 '\','2','0','0' 使用相同的字符,它会显示一个十进制值 128 的字节。十六进制显示时问题可能会更严重,其中原始字节 128 后面跟着字符 '7' 显示为 \x807,Emacs Lisp 将其读作单个字符 U+0807 SAMARITAN LETTER IT;这种混淆不会发生在相应的八进制显示中,\2007因为八进制转义符最多包含三位数字。

Raw bytes are displayed in octal format by default, for example a byte with a decimal value of 128 is displayed as \200. To change display to the hexadecimal format of \x80, set the variable display-raw-bytes-as-hex to t. Care may be needed when interpreting a raw byte when copying text from a terminal containing an Emacs session, or when a terminal’s escape-glyph face looks like the default face. For example, by default Emacs displays the four characters ‘\’, ‘2’, ‘0’, ‘0’ with the same characters it displays a byte with decimal value 128. The problem can be worse with hex displays, where the raw byte 128 followed by the character ‘7’ is displayed as \x807, which Emacs Lisp reads as the single character U+0807 SAMARITAN LETTER IT; this confusion does not occur with the corresponding octal display \2007 because octal escapes contain at most three digits.


17 个修复拼写错误的命令

17 Commands for Fixing Typos

在本章中,我们将描述当您在编辑时发现错误时有用的命令。这些命令中最基本的是撤消命令C-/(也绑定到C-x uC-_)。这将撤消单个命令或命令的一部分(如 的情况query-replace)或多个连续的字符插入。连续重复 C-/撤销之前和之前的更改,回到可用撤销信息的限制。

In this chapter we describe commands that are useful when you catch a mistake while editing. The most fundamental of these commands is the undo command C-/ (also bound to C-x u and C-_). This undoes a single command, or a part of a command (as in the case of query-replace), or several consecutive character insertions. Consecutive repetitions of C-/ undo earlier and earlier changes, back to the limit of the undo information available.

除了此处描述的命令之外,您还可以使用DEL( delete-backward-char) 等删除命令来删除文本。这些内容已在本手册前面进行了描述。请参阅删除文本

Aside from the commands described here, you can erase text using deletion commands such as DEL (delete-backward-char). These were described earlier in this manual. See Erasing Text.


17.1 撤消

17.1 Undo

撤消命令撤消缓冲区文本中最近的更改。每个缓冲区单独记录更改,并且撤消命令始终适用于当前缓冲区。您可以撤消缓冲区中的所有更改,直到缓冲区的记录为止。通常,每个编辑命令都会在撤消记录中创建一个单独的条目,但有些命令(如query-replace将其更改划分为多​​个条目)以实现撤消的灵活性。连续的字符插入命令通常组合在一起形成单个撤消记录,以使撤消变得不那么繁琐。

The undo command reverses recent changes in the buffer’s text. Each buffer records changes individually, and the undo command always applies to the current buffer. You can undo all the changes in a buffer for as far back as the buffer’s records go. Usually, each editing command makes a separate entry in the undo records, but some commands such as query-replace divide their changes into multiple entries for flexibility in undoing. Consecutive character insertion commands are usually grouped together into a single undo record, to make undoing less tedious.

C-/
C-/
C-x u
C-x u
C-_
C-_

撤消当前缓冲区撤消记录中的一项 ( undo)。

Undo one entry in the current buffer’s undo records (undo).

要开始撤消,请输入C-/(或其别名,C-_C-x u6。这将撤消缓冲区中最近的更改,并将点移回到更改之前的位置。连续重复C-/(或其别名)会撤消当前缓冲区中越来越早的更改。如果所有记录的更改已被撤消,则撤消命令会发出错误信号。

To begin to undo, type C-/ (or its aliases, C-_ or C-x u)6. This undoes the most recent change in the buffer, and moves point back to where it was before that change. Consecutive repetitions of C-/ (or its aliases) undo earlier and earlier changes in the current buffer. If all the recorded changes have already been undone, the undo command signals an error.

除撤消命令外的任何命令都会破坏撤消命令的顺序。从那一刻开始,您刚刚执行的整个撤消命令序列本身都会放入撤消记录中。因此,要重新应用已撤消的更改,请键入 C-f或任何其他无害地破坏撤消顺序的命令;然后键入C-/一次或多次以撤消某些撤消命令。

Any command other than an undo command breaks the sequence of undo commands. Starting from that moment, the entire sequence of undo commands that you have just performed are themselves placed into the undo record. Therefore, to re-apply changes you have undone, type C-f or any other command that harmlessly breaks the sequence of undoing; then type C-/ one or more times to undo some of the undo commands.

或者,如果您想恢复撤消而不重做以前的撤消命令,请使用M-x undo-only.这类似于 undo,但不会重做您刚刚撤消的更改。作为补充,M-x undo-redo将撤消先前的撤消命令(并且不会将其自身记录为可撤消命令)。

Alternatively, if you want to resume undoing, without redoing previous undo commands, use M-x undo-only. This is like undo, but will not redo changes you have just undone. To complement it, M-x undo-redo will undo previous undo commands (and will not record itself as an undoable command).

如果您发现缓冲区已被意外修改,最简单的恢复方法是C-/重复键入,直到星星从模式行前面消失(请参阅模式行)。每当撤消命令使星星从模式行消失时,就意味着缓冲区内容与上次读入或保存文件时的内容相同。如果您不记得是否故意更改了缓冲区,请键入C-/一次。当您看到上次撤消的更改时,您将了解这是否是有意的更改。如果这是一个意外,就不要做这件事。如果是故意的,请按照上述方式重新进行更改。

If you notice that a buffer has been modified accidentally, the easiest way to recover is to type C-/ repeatedly until the stars disappear from the front of the mode line (see The Mode Line). Whenever an undo command makes the stars disappear from the mode line, it means that the buffer contents are the same as they were when the file was last read in or saved. If you do not remember whether you changed the buffer deliberately, type C-/ once. When you see the last change you made undone, you will see whether it was an intentional change. If it was an accident, leave it undone. If it was deliberate, redo the change as described above.

或者,您可以放弃自上次访问或保存缓冲区以来的所有更改M-x revert-buffer (请参阅恢复缓冲区)。

Alternatively, you can discard all the changes since the buffer was last visited or saved with M-x revert-buffer (see Reverting a Buffer).

当存在活动区域​​时,任何使用undo都会执行 选择性撤消:它会撤消该区域内的最新更改,而不是整个缓冲区。但是,当瞬态标记模式关闭时(请参阅禁用瞬态标记模式),C-/始终对整个缓冲区进行操作,忽略该区域。在这种情况下,您可以通过向命令提供前缀参数来执行选择性撤消 undoC-u C-/。要撤消同一区域中的进一步更改,请重复该undo命令(不需要前缀参数)。

When there is an active region, any use of undo performs selective undo: it undoes the most recent change within the region, instead of the entire buffer. However, when Transient Mark mode is off (see Disabling Transient Mark Mode), C-/ always operates on the entire buffer, ignoring the region. In this case, you can perform selective undo by supplying a prefix argument to the undo command: C-u C-/. To undo further changes in the same region, repeat the undo command (no prefix argument is needed).

一些专用缓冲区不创建撤消记录。名称以空格开头的缓冲区永远不会这样做;这些缓冲区由 Emacs 内部使用来保存用户通常不查看或编辑的文本。

Some specialized buffers do not make undo records. Buffers whose names start with spaces never do; these buffers are used internally by Emacs to hold text that users don’t normally look at or edit.

当缓冲区的撤消信息变得太大时,Emacs 会不时地丢弃最旧的记录(在垃圾收集期间)。您可以通过设置变量undo-limitundo-strong-limit和 来 指定保留多少撤消信息undo-outer-limit。它们的值以字节表示。

When the undo information for a buffer becomes too large, Emacs discards the oldest records from time to time (during garbage collection). You can specify how much undo information to keep by setting the variables undo-limit, undo-strong-limit, and undo-outer-limit. Their values are expressed in bytes.

该变量undo-limit设置了一个软限制:Emacs 保留足够命令的撤消数据以达到该大小,甚至可能超过该大小,但不会保留超出该大小的任何早期命令的数据。它的默认值为 160000。该变量undo-strong-limit设置了更严格的限制:任何将大小推到超过此数量的先前命令(尽管不是最近的命令)都会被忘记。默认值为undo-strong-limit240000。

The variable undo-limit sets a soft limit: Emacs keeps undo data for enough commands to reach this size, and perhaps exceed it, but does not keep data for any earlier commands beyond that. Its default value is 160000. The variable undo-strong-limit sets a stricter limit: any previous command (though not the most recent one) that pushes the size past this amount is forgotten. The default value of undo-strong-limit is 240000.

无论这些变量的值如何,最近的更改都不会被丢弃,除非它大于undo-outer-limit (通常为 24,000,000)。此时,Emacs 会丢弃撤消数据并警告您。这是唯一无法撤消最后一个命令的情况。如果发生这种情况,您可以增加 的值 undo-outer-limit以使其将来发生的可能性更小。但是,如果您没想到该命令会创建如此大的撤消数据,那么它可能是一个错误,您应该报告它。请参阅报告错误

Regardless of the values of those variables, the most recent change is never discarded unless it gets bigger than undo-outer-limit (normally 24,000,000). At that point, Emacs discards the undo data and warns you about it. This is the only situation in which you cannot undo the last command. If this happens, you can increase the value of undo-outer-limit to make it even less likely to happen in the future. But if you didn’t expect the command to create such large undo data, then it is probably a bug and you should report it. See Reporting Bugs.


17.2 转置文本

17.2 Transposing Text

C-t
C-t

调换两个字符 ( transpose-chars)。

Transpose two characters (transpose-chars).

M-t
M-t

调换两个单词(transpose-words)。

Transpose two words (transpose-words).

C-M-t
C-M-t

转置两个平衡表达式 ( transpose-sexps)。

Transpose two balanced expressions (transpose-sexps).

C-x C-t
C-x C-t

调换两行 ( transpose-lines)。

Transpose two lines (transpose-lines).

M-x transpose-sentences
M-x transpose-sentences

将两个句子调换一下(transpose-sentences)。

Transpose two sentences (transpose-sentences).

M-x transpose-paragraphs
M-x transpose-paragraphs

调换两个段落(transpose-paragraphs)。

Transpose two paragraphs (transpose-paragraphs).

M-x transpose-regions
M-x transpose-regions

转置两个区域。

Transpose two regions.

C-t当两个字符相邻时,可以使用命令 ( )来修复调换两个字符的常见错误transpose-chars。通常, C-t调换点两侧的两个字符。当在行尾给出时,不是用换行符调换该行的最后一个字符(这将是无用的),而是C-t调换该行的最后两个字符。因此,如果您立即发现换位错误,只需使用C-t.如果您没有那么快地理解它,则必须在键入 之前将光标移回到两个转置字符之间C-t。如果您将单词的最后一个字符调换成空格,则单词运动命令(M-fM-b等)是到达该位置的好方法。否则,反向搜索 ( C-r) 通常是最好的方法。请参阅搜索和替换

The common error of transposing two characters can be fixed, when they are adjacent, with the C-t command (transpose-chars). Normally, C-t transposes the two characters on either side of point. When given at the end of a line, rather than transposing the last character of the line with the newline, which would be useless, C-t transposes the last two characters on the line. So, if you catch your transposition error right away, you can fix it with just a C-t. If you don’t catch it so fast, you must move the cursor back between the two transposed characters before you type C-t. If you transposed a space with the last character of the word before it, the word motion commands (M-f, M-b, etc.) are a good way of getting there. Otherwise, a reverse search (C-r) is often the best way. See Searching and Replacement.

M-t将点之前的单词与点 ( ) 之后的单词调换transpose-words。它将点向前移动到单词上,同时将点前面或包含点的单词也向前拖动。单词之间的标点符号不会移动。例如, '福,酒吧'转置为 '酒吧、美食'而不是 '酒吧福,' 。当point位于行尾时,它将把point之前的单词与下一行的第一个单词调换。

M-t transposes the word before point with the word after point (transpose-words). It moves point forward over a word, dragging the word preceding or containing point forward as well. The punctuation characters between the words do not move. For example, ‘FOO, BAR transposes into ‘BAR, FOO rather than ‘BAR FOO,. When point is at the end of the line, it will transpose the word before point with the first word on the next line.

C-M-t( transpose-sexps) 是一个类似的命令,用于转置两个表达式(请参阅带平衡括号的表达式),并且C-x C-t ( transpose-lines) 交换行。 M-x transpose-sentencesM-x transpose-paragraphs分别调换句子和段落。这些命令的工作方式类似 M-t,只是它们转置的文本单位不同。

C-M-t (transpose-sexps) is a similar command for transposing two expressions (see Expressions with Balanced Parentheses), and C-x C-t (transpose-lines) exchanges lines. M-x transpose-sentences and M-x transpose-paragraphs transpose sentences and paragraphs, respectively. These commands work like M-t except as regards the units of text they transpose.

转置命令的数字参数用作重复计数:它告诉转置命令将字符(或单词、表达式或行)移动到多个其他字符(或单词、表达式或行)之前或包含点的位置。例如,将点之前的角色向前移动到其他三个角色上。它会改变'C-u 3 C-tf*oobar' 进入 'oob*ar'。这相当于重复了C-t 三遍。 C-u - 4 M-t将点之前的单词向后移动四个单词。 C-u - C-M-t会取消 plain 的效果 C-M-t

A numeric argument to a transpose command serves as a repeat count: it tells the transpose command to move the character (or word or expression or line) before or containing point across several other characters (or words or expressions or lines). For example, C-u 3 C-t moves the character before point forward across three other characters. It would change ‘f∗oobar’ into ‘oobf∗ar’. This is equivalent to repeating C-t three times. C-u - 4 M-t moves the word before point backward across four words. C-u - C-M-t would cancel the effect of plain C-M-t.

零的数字参数被赋予特殊含义(因为否则重复计数为零的命令将不执行任何操作):将点后结尾的字符(或单词、表达式或行)转置为标记后结尾的字符(或单词、表达式或行)。

A numeric argument of zero is assigned a special meaning (because otherwise a command with a repeat count of zero would do nothing): to transpose the character (or word or expression or line) ending after point with the one ending after the mark.

M-x transpose-regions将点和标记之间的文本调换,并将最后两个标记之间的文本推送到标记环(请参阅设置标记)。使用数字前缀参数,它可以将点和标记之间的文本转置为两个连续标记之间的文本,即标记环中的许多条目。此命令最适合一次性调换多个字符(或单词、句子或段落)。

M-x transpose-regions transposes the text between point and mark with the text between the last two marks pushed to the mark ring (see Setting the Mark). With a numeric prefix argument, it transposes the text between point and mark with the text between two successive marks that many entries back in the mark ring. This command is best used for transposing multiple characters (or words or sentences or paragraphs) in one go.


17.3 大小写转换

17.3 Case Conversion

M-- M-l
M-- M-l

将最后一个单词转换为小写。注意Meta--是元减号。

Convert last word to lower case. Note Meta-- is Meta-minus.

M-- M-u
M-- M-u

将最后一个单词全部转换为大写。

Convert last word to all upper case.

M-- M-c
M-- M-c

将最后一个单词转换为小写,首字母大写。

Convert last word to lower case with capital initial.

一个非常常见的错误是输入错误的大小写单词。因此,单词大小写转换命令M-lM-u、 和M-c在与否定参数一起使用时具有特殊功能:它们不移动光标。一旦您发现最后一个单词输错了,您可以简单地对其进行大小写转换并继续输入。请参阅大小写转换命令

A very common error is to type words in the wrong case. Because of this, the word case-conversion commands M-l, M-u, and M-c have a special feature when used with a negative argument: they do not move the cursor. As soon as you see you have mistyped the last word, you can simply case-convert it and go on typing. See Case Conversion Commands.


17.4 检查和纠正拼写

17.4 Checking and Correcting Spelling

本节介绍用于检查单个单词或缓冲区的一部分的拼写的命令。仅当安装了拼写检查程序(Hunspell、Aspell、Ispell 或 Enchant 之一)时,这些命令才有效。这些程序不是 Emacs 的一部分,但其中之一通常安装在 GNU/Linux 和其他自由操作系统上。请参阅Aspell 手册中的Aspell

This section describes the commands to check the spelling of a single word or of a portion of a buffer. These commands only work if a spelling checker program, one of Hunspell, Aspell, Ispell or Enchant, is installed. These programs are not part of Emacs, but one of them is usually installed on GNU/Linux and other free operating systems. See Aspell in The Aspell Manual.

如果您只安装了一个拼写检查程序,当您第一次调用此处描述的命令之一时,Emacs 会找到它。如果您安装了多个,您可以通过自定义变量来控制使用哪一个 ispell-program-name

If you have only one of the spelling checker programs installed, Emacs will find it when you invoke for the first time one of the commands described here. If you have more than one of them installed, you can control which one is used by customizing the variable ispell-program-name.

M-$
M-$

检查并纠正 ( ) 处单词的拼写ispell-word。如果该区域处于活动状态,则对该区域中的所有单词执行此操作。

Check and correct spelling of the word at point (ispell-word). If the region is active, do it for all words in the region instead.

C-u M-$
C-u M-$

如果先前的拼写操作被中断,则继续该操作 ( ispell-continue)。

If a previous spelling operation was interrupted, continue that operation (ispell-continue).

M-x ispell
M-x ispell

检查并纠正缓冲区中所有单词的拼写。如果该区域处于活动状态,则对该区域中的所有单词执行此操作。

Check and correct spelling of all words in the buffer. If the region is active, do it for all words in the region instead.

M-x ispell-buffer
M-x ispell-buffer

检查并纠正缓冲区中的拼写。

Check and correct spelling in the buffer.

M-x ispell-region
M-x ispell-region

检查并纠正该地区的拼写。

Check and correct spelling in the region.

M-x ispell-message
M-x ispell-message

检查并更正邮件草稿中的拼写,不包括引用的材料。

Check and correct spelling in a draft mail message, excluding cited material.

M-x ispell-comments-and-strings
M-x ispell-comments-and-strings

检查并纠正缓冲区或区域中注释和字符串的拼写。

Check and correct spelling of comments and strings in the buffer or region.

M-x ispell-comment-or-string-at-point
M-x ispell-comment-or-string-at-point

检查该点的注释或字符串。

Check the comment or string at point.

M-x ispell-change-dictionary RET dict RET
M-x ispell-change-dictionary RET dict RET

使用dict作为字典 重新启动拼写检查程序进程。

Restart the spell-checker process, using dict as the dictionary.

M-x ispell-kill-ispell
M-x ispell-kill-ispell

终止拼写检查器子进程。

Kill the spell-checker subprocess.

M-TAB
M-TAB
ESC TAB
ESC TAB
C-M-i
C-M-i

根据拼写词典完成点之前的单词 ( ispell-complete-word)。

Complete the word before point based on the spelling dictionary (ispell-complete-word).

M-x flyspell-mode
M-x flyspell-mode

启用 Flyspell 模式,该模式会突出显示所有拼写错误的单词。

Enable Flyspell mode, which highlights all misspelled words.

M-x flyspell-prog-mode
M-x flyspell-prog-mode

仅对注释和字符串启用 Flyspell 模式。

Enable Flyspell mode for comments and strings only.

要检查 point 周围或之前的单词的拼写,并可选择更正它,请键入M-$( ispell-word)。如果某个区域处于活动状态,则M-$检查该区域内所有单词的拼写。请参阅“标记”和“区域”。 (当瞬态标记模式关闭时, M-$始终作用于点周围或之前的单词,忽略该区域;请参阅禁用瞬态标记模式。)当使用前缀参数 调用时,C-u M-$此函数会调用ispell-continue,它会继续拼写操作(如果有),其中被 X或打断C-g

To check the spelling of the word around or before point, and optionally correct it as well, type M-$ (ispell-word). If a region is active, M-$ checks the spelling of all words within the region. See The Mark and the Region. (When Transient Mark mode is off, M-$ always acts on the word around or before point, ignoring the region; see Disabling Transient Mark Mode.) When invoked with a prefix argument, C-u M-$, this calls ispell-continue, which continues the spelling operation, if any, which was interrupted with X or C-g.

类似地,如果该区域处于活动状态,则该命令M-x ispell将在该区域中执行拼写检查,否则将在整个缓冲区中执行拼写检查。命令和 分别对整个缓冲区或区域显式执行拼写检查。要检查您正在编写的电子邮件中的拼写,请使用;该命令检查整个缓冲区,缩进的材料或似乎从其他消息引用的材料除外。请参阅发送邮件。处理源代码时,您可以使用或来仅检查注释或字符串文字。 M-x ispell-bufferM-x ispell-regionM-x ispell-messageM-x ispell-comments-and-stringsM-x ispell-comment-or-string-at-point

Similarly, the command M-x ispell performs spell-checking in the region if one is active, or in the entire buffer otherwise. The commands M-x ispell-buffer and M-x ispell-region explicitly perform spell-checking on the entire buffer or the region respectively. To check spelling in an email message you are writing, use M-x ispell-message; that command checks the whole buffer, except for material that is indented or appears to be cited from other messages. See Sending Mail. When dealing with source code, you can use M-x ispell-comments-and-strings or M-x ispell-comment-or-string-at-point to check only comments or string literals.

当这些命令之一遇到看似不正确的单词时,它会询问您该怎么做。它通常会显示一个已编号的未命中单词列表,即接近错误单词的单词。然后您必须输入单字符响应。以下是有效回复:

When one of these commands encounters what appears to be an incorrect word, it asks you what to do. It usually displays a list of numbered near-misses—words that are close to the incorrect word. Then you must type a single-character response. Here are the valid responses:

digit
digit

就在这一次,将这个词替换为显示的未遂事件之一。每个险些发生的事件都用一个数字列出;输入该数字以选择它。

Replace the word, just this time, with one of the displayed near-misses. Each near-miss is listed with a digit; type that digit to select it.

SPC
SPC

跳过这个词——继续认为它不正确,但不要在这里改变它。

Skip this word—continue to consider it incorrect, but don’t change it here.

r new RET
r new RET

这次将这个词替换为new。 (将重新扫描替换字符串是否有更多拼写错误。)

Replace the word, just this time, with new. (The replacement string will be rescanned for more spelling errors.)

R new RET
R new RET

将单词替换为new,然后执行 a ,query-replace以便您可以根据需要将其替换到缓冲区中的其他位置。 (将重新扫描替换内容是否有更多拼写错误。)

Replace the word with new, and do a query-replace so you can replace it elsewhere in the buffer if you wish. (The replacements will be rescanned for more spelling errors.)

a
a

接受不正确的单词——将其视为正确的,但仅限于本次编辑会话。

Accept the incorrect word—treat it as correct, but only in this editing session.

A
A

接受不正确的单词 - 将其视为正确的单词,但仅限于此编辑会话和此缓冲区。

Accept the incorrect word—treat it as correct, but only in this editing session and for this buffer.

i
i

将此单词插入您的私人词典文件中,以便从现在开始,甚至在以后的会话中,它都被认为是正确的。

Insert this word in your private dictionary file so that it will be considered correct from now on, even in future sessions.

m
m

与 类似i,但您也可以指定字典补全信息。

Like i, but you can also specify dictionary completion information.

u
u

将该单词的小写版本插入您的私人词典文件中。

Insert the lower-case version of this word in your private dictionary file.

l word RET
l word RET

在字典中查找与word匹配的单词。这些词成为新的未遂事件清单;您可以通过键入数字来选择其中一个作为替换。您可以使用 '*' 在单词中作为通配符。

Look in the dictionary for words that match word. These words become the new list of near-misses; you can select one of them as the replacement by typing a digit. You can use ‘*’ in word as a wildcard.

C-g
C-g
X
X

中断交互式拼写检查,将光标留在正在检查的单词上。您可以随后使用 重新开始检查 。 C-u M-$

Interrupt the interactive spell-checking, leaving point at the word that was being checked. You can restart checking again afterward with C-u M-$.

x
x

退出交互式拼写检查并将指针移回到开始拼写检查时的位置。

Quit interactive spell-checking and move point back to where it was when you started spell-checking.

q
q

退出交互式拼写检查并终止拼写检查器子进程。

Quit interactive spell-checking and kill the spell-checker subprocess.

C-r
C-r

输入 recursive-edit(请参阅递归编辑级别)。当您使用 退出递归编辑时C-M-c,交互式拼写检查将恢复。这使您可以在不中断拼写检查的情况下查阅缓冲区文本。不要在递归编辑中修改缓冲区,尤其不要修改拼写错误的单词,因为退出递归编辑时编辑将被撤消。如果您需要编辑拼写错误的单词,请使用rR代替,或者使用X编辑缓冲区,然后使用 恢复。 C-u M-$

Enter recursive-edit (see Recursive Editing Levels). When you exit recursive-edit with C-M-c, the interactive spell-checking will resume. This allows you to consult the buffer text without interrupting the spell-checking. Do not modify the buffer in the recursive editing, and especially don’t modify the misspelled word, as the edits will be undone when you exit recursive-edit. If you need to edit the misspelled word, use r or R instead, or use X, edit the buffer, then resume with C-u M-$.

C-z
C-z

暂停 Emacs 或图标化所选框架。

Suspend Emacs or iconify the selected frame.

?
?

显示选项列表。

Show the list of options.

在文本模式和相关模式下, ( ) 基于拼写纠正执行缓冲区内完成。插入单词的开头,然后键入 ;这显示了已完成的列表。 (如果您的窗口管理器拦截,请键入或。)每个完成都列出一个数字或字符;输入该数字或字符以选择它。 M-TABispell-complete-wordM-TABM-TABESC TABC-M-i

In Text mode and related modes, M-TAB (ispell-complete-word) performs in-buffer completion based on spelling correction. Insert the beginning of a word, and then type M-TAB; this shows a list of completions. (If your window manager intercepts M-TAB, type ESC TAB or C-M-i.) Each completion is listed with a digit or character; type that digit or character to choose it.

一旦启动,拼写检查器子进程就会继续运行,等待执行某些操作,以便后续的拼写检查命令更快地完成。如果您想摆脱该进程,请使用.这通常是不必要的,因为除非进行拼写更正,否则该过程不使用处理器时间。 M-x ispell-kill-ispell

Once started, the spell-checker subprocess continues to run, waiting for something to do, so that subsequent spell-checking commands complete more quickly. If you want to get rid of the process, use M-x ispell-kill-ispell. This is not usually necessary, since the process uses no processor time except when you do spelling correction.

拼写检查器在两个词典中查找拼写:标准词典和您的个人词典。标准字典由变量指定ispell-local-dictionary ,或者,如果是nil,则由变量指定ispell-dictionary。如果两者都是nil,则使用拼写程序的默认词典。该命令为缓冲区设置标准字典,然后重新启动子进程,以便它将使用不同的标准字典。您的个人词典由变量指定 。如果是,则拼写程序会在默认位置查找个人词典,该位置特定于每个拼写检查器。 M-x ispell-change-dictionaryispell-personal-dictionarynil

Spell-checkers look up spelling in two dictionaries: the standard dictionary and your personal dictionary. The standard dictionary is specified by the variable ispell-local-dictionary or, if that is nil, by the variable ispell-dictionary. If both are nil, the spelling program’s default dictionary is used. The command M-x ispell-change-dictionary sets the standard dictionary for the buffer and then restarts the subprocess, so that it will use a different standard dictionary. Your personal dictionary is specified by the variable ispell-personal-dictionary. If that is nil, the spelling program looks for a personal dictionary in a default location, which is specific to each spell-checker.

使用单独的词典来完成单词。该变量 ispell-complete-word-dict指定该字典的文件名。补全字典必须不同,因为它不能使用有关单词词根和词缀的信息,而拼写检查则使用这些信息来检测单词的变体。对于某些语言,有拼写检查词典,但没有单词补全词典。

A separate dictionary is used for word completion. The variable ispell-complete-word-dict specifies the file name of this dictionary. The completion dictionary must be different because it cannot use the information about roots and affixes of the words, which spell-checking uses to detect variations of words. For some languages, there is a spell-checking dictionary but no word completion dictionary.

Flyspell 模式是一种次要模式,可在您键入文本时自动对您键入的文本进行拼写检查。当它发现一个它不认识的单词时,它会突出显示该单词。键入以在当前缓冲区中切换 Flyspell 模式。要在所有文本模式缓冲区中启用 Flyspell 模式,请添加 到.请参阅钩子。请注意,由于 Flyspell 模式需要检查您移动的每个单词,因此它会减慢光标移动和滚动命令的速度。它也不会自动检查您未输入或未移动的文本;使用或用于该目的。 M-x flyspell-modeflyspell-modetext-mode-hookflyspell-regionflyspell-buffer

Flyspell mode is a minor mode that performs automatic spell-checking of the text you type as you type it. When it finds a word that it does not recognize, it highlights that word. Type M-x flyspell-mode to toggle Flyspell mode in the current buffer. To enable Flyspell mode in all text mode buffers, add flyspell-mode to text-mode-hook. See Hooks. Note that, as Flyspell mode needs to check each word across which you move, it will slow down cursor motion and scrolling commands. It also doesn’t automatically check the text you didn’t type or move across; use flyspell-region or flyspell-buffer for that.

当 Flyspell 模式突出显示拼写错误的单词时,您可以使用mouse-2( flyspell-correct-word) 单击该单词以显示可能的更正和操作的菜单。如果您想打开此菜单 mouse-3,请启用context-menu-mode。另外, C-.ESC TAB( flyspell-auto-correct-word) 会针对该点的单词提出各种连续的更正, C-c $( flyspell-correct-word-before-point) 会弹出可能更正的菜单。当然,您始终可以通过以您喜欢的任何方式手动编辑来纠正拼写错误的单词。

When Flyspell mode highlights a word as misspelled, you can click on it with mouse-2 (flyspell-correct-word) to display a menu of possible corrections and actions. If you want this menu on mouse-3 instead, enable context-menu-mode. In addition, C-. or ESC TAB (flyspell-auto-correct-word) will propose various successive corrections for the word at point, and C-c $ (flyspell-correct-word-before-point) will pop up a menu of possible corrections. Of course, you can always correct the misspelled word by editing it manually in any way you like.

Flyspell Prog 模式的工作方式与普通 Flyspell 模式类似,只是它仅检查注释中的单词和字符串常量。此功能对于编辑程序很有用。键入以在当前缓冲区中启用或禁用此模式。要在所有编程模式缓冲区中启用此模式,请添加 到(请参阅Hooks)。 M-x flyspell-prog-modeflyspell-prog-modeprog-mode-hook

Flyspell Prog mode works just like ordinary Flyspell mode, except that it only checks words in comments and string constants. This feature is useful for editing programs. Type M-x flyspell-prog-mode to enable or disable this mode in the current buffer. To enable this mode in all programming mode buffers, add flyspell-prog-mode to prog-mode-hook (see Hooks).


18 个键盘宏

18 Keyboard Macros

在本章中,我们将描述如何记录一系列编辑命令,以便您以后可以方便地重复它。

In this chapter we describe how to record a sequence of editing commands so you can repeat it conveniently later.

键盘是 Emacs 用户定义的命令,用于代表另一个按键序列。例如,如果您发现要键入C-n M-d C-d四十次,则可以通过定义一个键盘宏 do 来加快工作速度C-n M-d C-d,然后再执行 39 次。

A keyboard macro is a command defined by an Emacs user to stand for another sequence of keys. For example, if you discover that you are about to type C-n M-d C-d forty times, you can speed your work by defining a keyboard macro to do C-n M-d C-d, and then executing it 39 more times.

您可以通过执行和记录定义键盘宏的命令来定义键盘宏。换句话说,当您定义键盘宏时,该定义是第一次执行。这样,您就可以看到命令的效果,这样您就不必在头脑中弄清楚它们。当您关闭定义时,键盘宏被定义并且实际上也被执行一次。然后,您可以通过调用宏重新执行整个操作。

You define a keyboard macro by executing and recording the commands which are its definition. Put differently, as you define a keyboard macro, the definition is being executed for the first time. This way, you can see the effects of your commands, so that you don’t have to figure them out in your head. When you close the definition, the keyboard macro is defined and also has been, in effect, executed once. You can then do the whole thing over again by invoking the macro.

键盘宏与普通 Emacs 命令的不同之处在于它们是用 Emacs 命令语言而不是 Lisp 编写的。这使得新手更容易编写它们,并且使它们作为临时黑客更方便。然而,Emacs 命令语言作为一种编程语言还不够强大,无法用于编写任何智能或通用的内容。对于这样的事情,必须使用 Lisp。

Keyboard macros differ from ordinary Emacs commands in that they are written in the Emacs command language rather than in Lisp. This makes it easier for the novice to write them, and makes them more convenient as temporary hacks. However, the Emacs command language is not powerful enough as a programming language to be useful for writing anything intelligent or general. For such things, Lisp must be used.


18.1 基本使用

18.1 Basic Use

F3
F3

开始定义键盘宏 ( kmacro-start-macro-or-insert-counter)。

Start defining a keyboard macro (kmacro-start-macro-or-insert-counter).

F4
F4

如果正在定义键盘宏,则结束定义;否则,执行最近的键盘宏( kmacro-end-or-call-macro)。

If a keyboard macro is being defined, end the definition; otherwise, execute the most recent keyboard macro (kmacro-end-or-call-macro).

C-u F3
C-u F3

重新执行最后一个键盘宏,然后将键附加到其定义中。

Re-execute last keyboard macro, then append keys to its definition.

C-u C-u F3
C-u C-u F3

将按键附加到最后一个键盘宏而不重新执行它。

Append keys to the last keyboard macro without re-executing it.

C-x C-k r
C-x C-k r

运行从区域 ( apply-macro-to-region-lines) 开始的每行上的最后一个键盘宏。

Run the last keyboard macro on each line that begins in the region (apply-macro-to-region-lines).

C-x (
C-x (

开始定义键盘宏(旧式)(kmacro-start-macro);使用前缀参数,将键附加到最后一个宏。

Start defining a keyboard macro (old style) (kmacro-start-macro); with a prefix argument, append keys to the last macro.

C-x )
C-x )

结束宏定义(旧式)( kmacro-end-macro);前缀参数用作执行宏的重复计数。

End a macro definition (old style) (kmacro-end-macro); prefix argument serves as the repeat count for executing the macro.

C-x e
C-x e

执行最近定义的键盘宏(kmacro-end-and-call-macro);前缀参数用作重复计数。

Execute the most recently defined keyboard macro (kmacro-end-and-call-macro); prefix argument serves as repeat count.

要开始定义键盘宏,请键入F3。从那时起,你的按键继续被执行,而且也成为宏定义的一部分。 '定义' 出现在模式行中以提醒您正在发生的事情。完成后,键入F4 ( kmacro-end-or-call-macro) 终止定义。例如,

To start defining a keyboard macro, type F3. From then on, your keys continue to be executed, but also become part of the definition of the macro. ‘Def’ appears in the mode line to remind you of what is going on. When you are finished, type F4 (kmacro-end-or-call-macro) to terminate the definition. For example,

F3富夫F4
F3 M-f foo F4

定义一个宏来向前移动一个单词,然后插入 ''。请注意,F3F4不要成为宏的一部分。

defines a macro to move forward a word and then insert ‘foo’. Note that F3 and F4 do not become part of the macro.

定义宏后,您可以使用 来调用它F4。对于上面的示例,这与M-f foo再次键入具有相同的效果。 (请注意该命令的两个角色F4:如果您正在定义宏,则它会结束宏,否则调用最后一个宏。)您还可以提供F4数字前缀参数 'n',表示调用宏'n'次。参数为零会无限期地重复宏,直到出现错误或您键入C-g(或者,在 MS-DOS 上,)。 C-Break

After defining the macro, you can call it with F4. For the above example, this has the same effect as typing M-f foo again. (Note the two roles of the F4 command: it ends the macro if you are in the process of defining one, or calls the last macro otherwise.) You can also supply F4 with a numeric prefix argument ‘n’, which means to invoke the macro ‘n’ times. An argument of zero repeats the macro indefinitely, until it gets an error or you type C-g (or, on MS-DOS, C-Break).

上面的示例演示了一个可以与键盘宏一起使用的便捷技巧:如果您希望在文本中规则间隔的位置重复操作,请在宏中包含运动命令。在这种情况下,重复宏会插入字符串 '' 在每个连续的单词之后。

The above example demonstrates a handy trick that you can employ with keyboard macros: if you wish to repeat an operation at regularly spaced places in the text, include a motion command as part of the macro. In this case, repeating the macro inserts the string ‘foo’ after each successive word.

终止键盘宏的定义后,您可以通过键入 向其定义追加更多击键。这相当于简单地重新输入到目前为止的整个定义。结果,它重新执行先前定义的宏。如果将变量更改 为,则在附加到它之前不会重新执行现有的宏(默认为 )。您还可以添加到最后一个键盘宏定义的末尾,而无需通过键入 重新执行它。 C-u F3F3kmacro-execute-before-appendniltC-u C-u F3

After terminating the definition of a keyboard macro, you can append more keystrokes to its definition by typing C-u F3. This is equivalent to plain F3 followed by retyping the whole definition so far. As a consequence, it re-executes the macro as previously defined. If you change the variable kmacro-execute-before-append to nil, the existing macro will not be re-executed before appending to it (the default is t). You can also add to the end of the definition of the last keyboard macro without re-executing it by typing C-u C-u F3.

当命令使用迷你缓冲区读取参数时,您的迷你缓冲区输入将与命令一起成为宏的一部分。因此,当您重播宏时,该命令将获得与输入宏时相同的参数。例如,

When a command reads an argument with the minibuffer, your minibuffer input becomes part of the macro along with the command. So when you replay the macro, the command gets the same argument as when you entered the macro. For example,

F3Ca Ck Cx b foo RETCy Cx bRET F4
F3 C-a C-k C-x b foo RET C-y C-x b RET F4

定义一个宏来杀死当前行,将其拉入缓冲区'',然后返回到原始缓冲区。

defines a macro that kills the current line, yanks it into the buffer ‘foo’, then returns to the original buffer.

大多数键盘命令在键盘宏定义中照常工作,但有一些例外。键入C-g( keyboard-quit) 退出键盘宏定义。键入C-M-c ( exit-recursive-edit) 可能不可靠:如果退出在宏内开始的递归编辑,它会按照您的预期工作,但如果它退出在调用键盘宏之前开始的递归编辑,它也必然会退出键盘宏。鼠标事件也是不可靠的,即使您可以在键盘宏中使用它们:当宏重播鼠标事件时,它使用该事件的原始鼠标位置,即定义宏时鼠标所处的位置。其效果可能很难预测。

Most keyboard commands work as usual in a keyboard macro definition, with some exceptions. Typing C-g (keyboard-quit) quits the keyboard macro definition. Typing C-M-c (exit-recursive-edit) can be unreliable: it works as you’d expect if exiting a recursive edit that started within the macro, but if it exits a recursive edit that started before you invoked the keyboard macro, it also necessarily exits the keyboard macro too. Mouse events are also unreliable, even though you can use them in a keyboard macro: when the macro replays the mouse event, it uses the original mouse position of that event, the position that the mouse had while you were defining the macro. The effect of this may be hard to predict.

命令C-x C-k r( apply-macro-to-region-lines) 在该区域开始的每一行上重复最后定义的键盘宏。它通过将点移动到行的开头然后执行宏来逐行执行此操作。

The command C-x C-k r (apply-macro-to-region-lines) repeats the last defined keyboard macro on each line that begins in the region. It does this line by line, by moving point to the beginning of the line and then executing the macro.

除了上述F3F4命令之外,Emacs 还支持一组较旧的键绑定来定义和执行键盘宏。要开始宏定义,请键入C-x (( kmacro-start-macro);与 一样F3,前缀参数将此定义附加到最后一个键盘宏。要结束宏定义,请键入C-x )( kmacro-end-macro)。要执行最近的宏,请键入C-x e ( kmacro-end-and-call-macro)。如果在定义宏时输入C-x e,宏将立即终止并执行。键入 后C-x e,您可以立即e重复键入以立即重复宏一次或多次。您还可以给出 C-x e重复参数,就像F4(当它用于执行宏时)一样。

In addition to the F3 and F4 commands described above, Emacs also supports an older set of key bindings for defining and executing keyboard macros. To begin a macro definition, type C-x ( (kmacro-start-macro); as with F3, a prefix argument appends this definition to the last keyboard macro. To end a macro definition, type C-x ) (kmacro-end-macro). To execute the most recent macro, type C-x e (kmacro-end-and-call-macro). If you enter C-x e while defining a macro, the macro is terminated and executed immediately. Immediately after typing C-x e, you can type e repeatedly to immediately repeat the macro one or more times. You can also give C-x e a repeat argument, just like F4 (when it is used to execute a macro).

C-x )可以给出重复计数作为参数。这意味着定义宏后立即重复它。宏定义本身算作第一次重复,因为它是按照您定义的方式执行的,因此C-u 4 C-x )立即执行该宏 3 次。

C-x ) can be given a repeat count as an argument. This means to repeat the macro right after defining it. The macro definition itself counts as the first repetition, since it is executed as you define it, so C-u 4 C-x ) executes the macro immediately 3 additional times.

在执行长时间运行的键盘宏时,触发重新显示有时会很有用(以显示我们已经走了多远)。该 C-x C-k d命令可用于此目的。作为一个不太有用的示例,C-x ( M-f C-x C-k d C-x )将创建一个宏,当说 时,该宏将在每次迭代时重新显示一次C-u 42 C-x e

While executing a long-running keyboard macro, it can sometimes be useful to trigger a redisplay (to show how far we’ve gotten). The C-x C-k d command can be used for this. As a not very useful example, C-x ( M-f C-x C-k d C-x ) will create a macro that will redisplay once per iteration when saying C-u 42 C-x e.


18.2 键盘宏环

18.2 The Keyboard Macro Ring

所有定义的键盘宏都记录在键盘宏环中。只有一个键盘宏环,由所有缓冲区共享。

All defined keyboard macros are recorded in the keyboard macro ring. There is only one keyboard macro ring, shared by all buffers.

C-x C-k C-k
C-x C-k C-k

执行环开头的键盘宏 ( kmacro-end-or-call-macro-repeat)。

Execute the keyboard macro at the head of the ring (kmacro-end-or-call-macro-repeat).

C-x C-k C-n
C-x C-k C-n

将键盘宏环旋转到下一个宏(之前定义的)( kmacro-cycle-ring-next)。

Rotate the keyboard macro ring to the next macro (defined earlier) (kmacro-cycle-ring-next).

C-x C-k C-p
C-x C-k C-p

将键盘宏环旋转到上一个宏(稍后定义)( kmacro-cycle-ring-previous)。

Rotate the keyboard macro ring to the previous macro (defined later) (kmacro-cycle-ring-previous).

所有在键盘宏环上运行的命令都使用相同的C-x C-k前缀。这些命令中的大多数都可以立即执行和重复,而无需重复前缀C-x C-k。例如,

All commands which operate on the keyboard macro ring use the same C-x C-k prefix. Most of these commands can be executed and repeated immediately after each other without repeating the C-x C-k prefix. For example,

Cx Ck Cp Cp Ck Ck Ck Cn Cn Ck Cp Ck Cd
C-x C-k C-p C-p C-k C-k C-k C-n C-n C-k C-p C-k C-d

将键盘宏环旋转到前第二个宏,执行生成的头宏三次,旋转回原始头宏,执行一次,旋转到上一个宏,执行该宏,最后将其从宏环中删除。

will rotate the keyboard macro ring to the second-previous macro, execute the resulting head macro three times, rotate back to the original head macro, execute that once, rotate to the previous macro, execute that, and finally delete it from the macro ring.

命令C-x C-k C-k( kmacro-end-or-call-macro-repeat) 执行宏环开头的键盘宏。您可以通过键入另一个宏立即重复宏,也可以通过键入或C-k立即旋转宏环。 C-nC-p

The command C-x C-k C-k (kmacro-end-or-call-macro-repeat) executes the keyboard macro at the head of the macro ring. You can repeat the macro immediately by typing another C-k, or you can rotate the macro ring immediately by typing C-n or C-p.

定义键盘宏时,C-x C-k C-k其行为类似F4,但紧接着,您可以使用本节的大多数键绑定而不带前缀C-x C-k。例如,另一个C-k将重新执行宏。

When a keyboard macro is being defined, C-x C-k C-k behaves like F4 except that, immediately afterward, you can use most key bindings of this section without the C-x C-k prefix. For instance, another C-k will re-execute the macro.

命令C-x C-k C-n( kmacro-cycle-ring-next) 和 C-x C-k C-p( kmacro-cycle-ring-previous) 旋转宏环,将下一个或上一个键盘宏带到宏环的头部。新头宏的定义显示在回显区域中。您可以立即继续旋转宏环,只需重复C-nC-p直到所需的宏位于环的顶部。要立即执行新的宏环头,只需键入C-k

The commands C-x C-k C-n (kmacro-cycle-ring-next) and C-x C-k C-p (kmacro-cycle-ring-previous) rotate the macro ring, bringing the next or previous keyboard macro to the head of the macro ring. The definition of the new head macro is displayed in the echo area. You can continue to rotate the macro ring immediately by repeating just C-n and C-p until the desired macro is at the head of the ring. To execute the new macro ring head immediately, just type C-k.

请注意,Emacs 将宏环的头部视为最后定义的键盘宏。例如,F4将执行该宏,并C-x C-k n为其命名。

Note that Emacs treats the head of the macro ring as the last defined keyboard macro. For instance, F4 will execute that macro, and C-x C-k n will give it a name.

键盘宏环中存储的宏的最大数量由可定制变量决定kmacro-ring-max

The maximum number of macros stored in the keyboard macro ring is determined by the customizable variable kmacro-ring-max.


18.3 键盘宏计数器

18.3 The Keyboard Macro Counter

每个键盘宏都有一个关联的计数器,当您开始定义宏时,该计数器被初始化为 0。当前计数器 允许您根据宏被调用的次数向缓冲区插入一个数字。每次将其值插入缓冲区时,计数器通常都会递增。

Each keyboard macro has an associated counter, which is initialized to 0 when you start defining the macro. This current counter allows you to insert a number into the buffer that depends on the number of times the macro has been called. The counter is normally incremented each time its value is inserted into the buffer.

除了当前计数器之外,键盘宏还维护 先前的计数器,它记录当前计数器上次递增或设置时的值。请注意,将当前计数器递增零(例如使用)也会将当前计数器的值记录为先前的计数器值。 C-u 0 C-x C-k C-i

In addition to the current counter, keyboard macros also maintain the previous counter, which records the value the current counter had last time it was incremented or set. Note that incrementing the current counter by zero, e.g., with C-u 0 C-x C-k C-i, also records the value of the current counter as the previous counter value.

F3
F3

在键盘宏定义中,将键盘宏计数器值插入缓冲区 ( kmacro-start-macro-or-insert-counter)。

In a keyboard macro definition, insert the keyboard macro counter value in the buffer (kmacro-start-macro-or-insert-counter).

C-x C-k C-i
C-x C-k C-i

将键盘宏计数器值插入缓冲区 ( kmacro-insert-counter)。

Insert the keyboard macro counter value in the buffer (kmacro-insert-counter).

C-x C-k C-c
C-x C-k C-c

设置键盘宏计数器 ( kmacro-set-counter)。

Set the keyboard macro counter (kmacro-set-counter).

C-x C-k C-a
C-x C-k C-a

将前缀 arg 添加到键盘宏计数器 ( kmacro-add-counter)。

Add the prefix arg to the keyboard macro counter (kmacro-add-counter).

C-x C-k C-f
C-x C-k C-f

指定插入键盘宏计数器的格式 ( kmacro-set-format)。

Specify the format for inserting the keyboard macro counter (kmacro-set-format).

当您定义键盘宏时,命令F3 ( kmacro-start-macro-or-insert-counter) 将键盘宏计数器的当前值插入到缓冲区中,并将计数器加 1。(如果您没有定义宏,则F3开始宏定义。请参阅基本使用.) 您可以使用数字前缀参数来指定不同的增量。如果您仅指定C-u前缀,则会插入先前的计数器值,并且不会更改当前值。

When you are defining a keyboard macro, the command F3 (kmacro-start-macro-or-insert-counter) inserts the current value of the keyboard macro’s counter into the buffer, and increments the counter by 1. (If you are not defining a macro, F3 begins a macro definition instead. See Basic Use.) You can use a numeric prefix argument to specify a different increment. If you just specify a C-u prefix, that inserts the previous counter value, and doesn’t change the current value.

作为示例,让我们展示如何使用键盘宏计数器来构建编号列表。考虑以下按键顺序:

As an example, let us show how the keyboard macro counter can be used to build a numbered list. Consider the following key sequence:

F3F3SPC F4
F3 C-a F3 . SPC F4

作为此键盘宏定义的一部分,字符串 '0。' 被插入到当前行的开头。如果您现在移动到缓冲区中的其他位置并键入F4以调用宏,则字符串 '1.' 被插入到该行的开头。后续调用插入 '2.','3.”,等等。

As part of this keyboard macro definition, the string ‘0. ’ was inserted into the beginning of the current line. If you now move somewhere else in the buffer and type F4 to invoke the macro, the string ‘1. ’ is inserted at the beginning of that line. Subsequent invocations insert ‘2. ’, ‘3. ’, and so forth.

命令C-x C-k C-i( kmacro-insert-counter) 的作用与 相同F3,但它可以在键盘宏定义之外使用。当没有定义或执行键盘宏时,它会在键盘宏环的头部插入并递增宏的计数器。

The command C-x C-k C-i (kmacro-insert-counter) does the same thing as F3, but it can be used outside a keyboard macro definition. When no keyboard macro is being defined or executed, it inserts and increments the counter of the macro at the head of the keyboard macro ring.

命令C-x C-k C-c( kmacro-set-counter) 将当前宏计数器设置为数字参数的值。如果您在宏内部使用它,它将对宏的每次重复进行操作。如果您在执行宏时指定C-u为前缀,则会将计数器重置为宏当前重复开始时的值(撤消本次重复中迄今为止的任何增量)。

The command C-x C-k C-c (kmacro-set-counter) sets the current macro counter to the value of the numeric argument. If you use it inside the macro, it operates on each repetition of the macro. If you specify just C-u as the prefix, while executing the macro, that resets the counter to the value it had at the beginning of the current repetition of the macro (undoing any increments so far in this repetition).

命令C-x C-k C-a( kmacro-add-counter) 将前缀参数添加到当前宏计数器。作为C-u参数,它将计数器重置为任何键盘宏插入的最后一个值。 (通常,当您使用它时,最后的插入将在同一个宏中,并且它将是同一个计数器。)

The command C-x C-k C-a (kmacro-add-counter) adds the prefix argument to the current macro counter. With just C-u as argument, it resets the counter to the last value inserted by any keyboard macro. (Normally, when you use this, the last insertion will be in the same macro and it will be the same counter.)

命令C-x C-k C-f( kmacro-set-format) 提示输入插入宏计数器时要使用的格式。默认格式是 '%d',这意味着以十进制形式插入数字,不进行任何填充。您可以使用空迷你缓冲区退出以将格式重置为此默认值。您可以指定 format函数接受的任何格式字符串,并且使用单个整数额外参数有意义(请参阅Emacs Lisp 参考手册中的格式化字符串)。将格式字符串插入迷你缓冲区时,请勿将其放在双引号内。

The command C-x C-k C-f (kmacro-set-format) prompts for the format to use when inserting the macro counter. The default format is ‘%d’, which means to insert the number in decimal without any padding. You can exit with empty minibuffer to reset the format to this default. You can specify any format string that the format function accepts and that makes sense with a single integer extra argument (see Formatting Strings in The Emacs Lisp Reference Manual). Do not put the format string inside double quotes when you insert it in the minibuffer.

如果在没有定义或执行键盘宏时使用此命令,则新格式会影响所有后续宏定义。现有宏继续使用定义时有效的格式。如果您在定义键盘宏时设置格式,则会影响从该点开始定义的宏,但不会影响后续宏。宏的执行将在每个步骤中使用在其定义期间该步骤有效的格式。宏执行期间对宏格式的更改,就像其定义期间的相应更改一样,不会影响后续宏。

If you use this command while no keyboard macro is being defined or executed, the new format affects all subsequent macro definitions. Existing macros continue to use the format in effect when they were defined. If you set the format while defining a keyboard macro, this affects the macro being defined from that point on, but it does not affect subsequent macros. Execution of the macro will, at each step, use the format in effect at that step during its definition. Changes to the macro format during execution of a macro, like the corresponding changes during its definition, have no effect on subsequent macros.

设置的格式C-x C-k C-f不影响寄存器中存储的数字的插入。

The format set by C-x C-k C-f does not affect insertion of numbers stored in registers.

如果您使用寄存器作为计数器,在宏的每次重复时递增它,则可以完成与键盘宏计数器相同的操作。请参阅将数字保存在寄存器中。对于大多数用途,使用键盘宏计数器更简单。

If you use a register as a counter, incrementing it on each repetition of the macro, that accomplishes the same thing as a keyboard macro counter. See Keeping Numbers in Registers. For most purposes, it is simpler to use a keyboard macro counter.


18.4 执行具有变体的宏

18.4 Executing Macros with Variations

在键盘宏中,您可以创建与 类似的效果 query-replace,因为宏每次都会询问您是否进行更改。

In a keyboard macro, you can create an effect similar to that of query-replace, in that the macro asks you each time around whether to make a change.

C-x q
C-x q

当宏执行期间到达此点时,要求确认 ( kbd-macro-query)。

When this point is reached during macro execution, ask for confirmation (kbd-macro-query).

定义宏时,C-x q在您希望发生查询的位置键入。在宏定义期间,C-x q 不执行任何操作,但是当您稍后运行宏时,C-x q会以交互方式询问您是否继续。

While defining the macro, type C-x q at the point where you want the query to occur. During macro definition, the C-x q does nothing, but when you run the macro later, C-x q asks you interactively whether to continue.

询问时的有效答复C-x q是:

The valid responses when C-x q asks are:

SPC(或者y
SPC (or y)

继续执行键盘宏。

Continue executing the keyboard macro.

DEL(或者n
DEL (or n)

跳过宏重复的剩余部分,并立即开始下一次重复。

Skip the remainder of this repetition of the macro, and start right away with the next repetition.

RET(或者q
RET (or q)

跳过本次重复的剩余部分并取消进一步的重复。

Skip the remainder of this repetition and cancel further repetitions.

C-r
C-r

输入递归编辑级别,您可以在其中执行不属于宏的编辑。当您使用 退出递归编辑时C-M-c,系统会再次询问您如何继续使用键盘宏。如果SPC此时输入 a ,则执行宏定义的其余部分。您可以将点和文本保持在某种状态,以便宏的其余部分可以执行您想要的操作。

Enter a recursive editing level, in which you can perform editing which is not part of the macro. When you exit the recursive edit using C-M-c, you are asked again how to continue with the keyboard macro. If you type a SPC at this time, the rest of the macro definition is executed. It is up to you to leave point and the text in a state such that the rest of the macro will do what you want.

C-u C-x q带有C-x q前缀参数,执行完全不同的功能。当您在宏定义期间键入它时以及从宏执行它时,它都会进入递归编辑,从键盘读取输入。在定义期间,您在递归编辑中所做的编辑不会成为宏的一部分。在宏执行期间,递归编辑使您有机会对每次重复进行一些特定的编辑。请参阅递归编辑级别

C-u C-x q, which is C-x q with a prefix argument, performs a completely different function. It enters a recursive edit reading input from the keyboard, both when you type it during the definition of the macro, and when it is executed from the macro. During definition, the editing you do inside the recursive edit does not become part of the macro. During macro execution, the recursive edit gives you a chance to do some particularized editing on each repetition. See Recursive Editing Levels.


18.5 命名和保存键盘宏

18.5 Naming and Saving Keyboard Macros

C-x C-k n
C-x C-k n

为最近定义的键盘宏 ( ) 指定命令名称(在 Emacs 会话期间)kmacro-name-last-macro

Give a command name (for the duration of the Emacs session) to the most recently defined keyboard macro (kmacro-name-last-macro).

C-x C-k b
C-x C-k b

将最近定义的键盘宏绑定到按键序列(在会话期间)( kmacro-bind-to-key)。

Bind the most recently defined keyboard macro to a key sequence (for the duration of the session) (kmacro-bind-to-key).

M-x insert-kbd-macro
M-x insert-kbd-macro

在缓冲区中插入键盘宏的定义,作为 Lisp 代码。

Insert in the buffer a keyboard macro’s definition, as Lisp code.

C-x C-k n如果您希望保存键盘宏以供以后使用,您可以使用( )为其命名kmacro-name-last-macro。这使用迷你缓冲区读取名称作为参数,并定义该名称以当前形式执行最后一个键盘宏。 (如果您稍后添加到此宏的定义,则不会改变该名称作为宏的定义。)宏名称是一个 Lisp 符号,以这种方式定义它使其成为用于调用 M-x或绑定的有效命令名称with 的键keymap-global-set (参见Keymaps)。如果您指定的名称具有除键盘宏之外的先前定义,则会显示一条错误消息,并且不会发生任何更改。

If you wish to save a keyboard macro for later use, you can give it a name using C-x C-k n (kmacro-name-last-macro). This reads a name as an argument using the minibuffer and defines that name to execute the last keyboard macro, in its current form. (If you later add to the definition of this macro, that does not alter the name’s definition as a macro.) The macro name is a Lisp symbol, and defining it in this way makes it a valid command name for calling with M-x or for binding a key to with keymap-global-set (see Keymaps). If you specify a name that has a prior definition other than a keyboard macro, an error message is shown and nothing is changed.

C-x C-k b您还可以使用( kmacro-bind-to-key) 后跟要绑定的按键序列将最后一个键盘宏(以其当前形式)绑定到按键。您可以绑定到全局键映射中的任何键序列,但由于大多数键序列已经有其他绑定,因此您应该仔细选择键序列。如果您尝试使用现有绑定(在任何键盘映射中)绑定到按键序列,则此命令会在替换现有绑定之前要求您确认。

You can also bind the last keyboard macro (in its current form) to a key, using C-x C-k b (kmacro-bind-to-key) followed by the key sequence you want to bind. You can bind to any key sequence in the global keymap, but since most key sequences already have other bindings, you should select the key sequence carefully. If you try to bind to a key sequence with an existing binding (in any keymap), this command asks you for confirmation before replacing the existing binding.

为了避免因覆盖现有绑定而导致的问题,按键序列C-x C-k 0throughC-x C-k 9C-x C-k A throughC-x C-k Z保留给您自己的键盘宏绑定。事实上,要绑定到这些按键序列之一,您只需键入数字或字母,而不是整个按键序列。例如,

To avoid problems caused by overriding existing bindings, the key sequences C-x C-k 0 through C-x C-k 9 and C-x C-k A through C-x C-k Z are reserved for your own keyboard macro bindings. In fact, to bind to one of these key sequences, you only need to type the digit or letter rather than the whole key sequences. For example,

CX CK b 4
C-x C-k b 4

将把最后一个键盘宏绑定到按键序列C-x C-k 4

will bind the last keyboard macro to the key sequence C-x C-k 4.

一旦宏有了命令名称,您就可以将其定义保存在文件中。然后它可以在另一个编辑会话中使用。首先,访问要保存定义的文件。然后使用以下命令:

Once a macro has a command name, you can save its definition in a file. Then it can be used in another editing session. First, visit the file you want to save the definition in. Then use this command:

Mx insert-kbd-macroRET 宏名 RET
M-x insert-kbd-macro RET macroname RET

这会插入一些 Lisp 代码,当稍后执行时,这些代码将使用与现在相同的定义来定义相同的宏。 (您不需要了解 Lisp 代码即可执行此操作,因为系统会insert-kbd-macro为您编写 Lisp 代码。)然后保存文件。您可以稍后使用load-file(请参阅Libraries of Lisp Code for Emacs)加载该文件。如果您保存的文件是您的初始化文件〜/.emacs(请参阅Emacs 初始化文件),然后每次运行 Emacs 时都会定义宏。

This inserts some Lisp code that, when executed later, will define the same macro with the same definition it has now. (You don’t need to understand Lisp code to do this, because insert-kbd-macro writes the Lisp code for you.) Then save the file. You can load the file later with load-file (see Libraries of Lisp Code for Emacs). If the file you save in is your init file ~/.emacs (see The Emacs Initialization File) then the macro will be defined each time you run Emacs.

如果你给出insert-kbd-macro一个前缀参数,它会生成额外的 Lisp 代码来记录你绑定到Macroname 的键(如果有的话) ,这样当你加载文件时,宏就会被重新分配相同的键。

If you give insert-kbd-macro a prefix argument, it makes additional Lisp code to record the keys (if any) that you have bound to macroname, so that the macro will be reassigned the same keys when you load the file.


18.6 编辑键盘宏

18.6 Editing a Keyboard Macro

C-x C-k C-e
C-x C-k C-e

编辑最后定义的键盘宏 ( kmacro-edit-macro)。

Edit the last defined keyboard macro (kmacro-edit-macro).

C-x C-k e name RET
C-x C-k e name RET

编辑先前定义的键盘宏名称( edit-kbd-macro)。

Edit a previously defined keyboard macro name (edit-kbd-macro).

C-x C-k l
C-x C-k l

将最后 300 个击键编辑为键盘宏 ( kmacro-edit-lossage)。

Edit the last 300 keystrokes as a keyboard macro (kmacro-edit-lossage).

C-x C-k C-e您可以通过键入或 ( )来编辑最后一个键盘宏。这会格式化缓冲区中的宏定义,并进入专门的主要模式进行编辑。在该缓冲区中键入一次即可显示如何编辑宏的详细信息。完成编辑后,输入 。 C-x C-k RETkmacro-edit-macroC-h mC-c C-c

You can edit the last keyboard macro by typing C-x C-k C-e or C-x C-k RET (kmacro-edit-macro). This formats the macro definition in a buffer and enters a specialized major mode for editing it. Type C-h m once in that buffer to display details of how to edit the macro. When you are finished editing, type C-c C-c.

C-x C-k e您可以通过键入( )来编辑已命名的键盘宏或绑定到某个键的宏 edit-kbd-macro。随后使用键盘输入来调用宏C-x e或 其他一些按键序列。 M-x name

You can edit a named keyboard macro or a macro bound to a key by typing C-x C-k e (edit-kbd-macro). Follow that with the keyboard input that you would use to invoke the macro—C-x e or M-x name or some other key sequence.

C-x C-k l您可以通过键入( kmacro-edit-lossage) 将最后 300 个击键编辑为宏 。

You can edit the last 300 keystrokes as a macro by typing C-x C-k l (kmacro-edit-lossage).


18.7 逐步编辑键盘宏

18.7 Stepwise Editing a Keyboard Macro

您可以通过键入( )以交互方式重播和编辑上一个键盘宏,一次一个命令。除非您使用或退出宏 ,否则编辑的宏将替换宏环上的最后一个宏。 C-x C-k SPCkmacro-step-edit-macroqC-g

You can interactively replay and edit the last keyboard macro, one command at a time, by typing C-x C-k SPC (kmacro-step-edit-macro). Unless you quit the macro using q or C-g, the edited macro replaces the last macro on the macro ring.

此宏编辑功能显示迷你缓冲区中的最后一个宏以及要执行的第一个(或下一个)命令,并提示您执行操作。您可以输入?以获取选项摘要。可以执行以下操作:

This macro editing feature shows the last macro in the minibuffer together with the first (or next) command to be executed, and prompts you for an action. You can enter ? to get a summary of your options. These actions are available:

  • SPCy执行当前命令,并前进到键盘宏中的下一个命令。
  • SPC and y execute the current command, and advance to the next command in the keyboard macro.
  • nd、 并DEL跳过并删除当前命令。
  • n, d, and DEL skip and delete the current command.
  • f在此执行键盘宏时跳过当前命令,但不会将其从宏中删除。
  • f skips the current command in this execution of the keyboard macro, but doesn’t delete it from the macro.
  • TAB执行当前命令以及紧随当前命令之后的所有类似命令;例如,TAB 可用于插入字符序列(对应于self-insert-command命令序列)。
  • TAB executes the current command, as well as all similar commands immediately following the current command; for example, TAB may be used to insert a sequence of characters (corresponding to a sequence of self-insert-command commands).
  • c继续执行(无需进一步编辑)直到键盘宏结束。如果执行正常终止,则编辑后的宏将替换原始键盘宏。
  • c continues execution (without further editing) until the end of the keyboard macro. If execution terminates normally, the edited macro replaces the original keyboard macro.
  • C-k跳过并删除键盘宏的其余部分,终止分步编辑,并用编辑后的宏替换原始键盘宏。
  • C-k skips and deletes the rest of the keyboard macro, terminates step-editing, and replaces the original keyboard macro with the edited macro.
  • qC-g取消键盘宏的步进编辑;放弃对键盘宏所做的任何更改。
  • q and C-g cancels the step-editing of the keyboard macro; discarding any changes made to the keyboard macro.
  • i key… C-j读取并执行一系列按键序列(不包括final C-j),并将它们插入到键盘宏中的当前命令之前,而不前进到当前命令。
  • i key… C-j reads and executes a series of key sequences (not including the final C-j), and inserts them before the current command in the keyboard macro, without advancing over the current command.
  • I key读取一个按键序列,执行它,并将其插入到键盘宏中的当前命令之前,而不前进到当前命令。
  • I key reads one key sequence, executes it, and inserts it before the current command in the keyboard macro, without advancing over the current command.
  • r key… C-j读取并执行一系列按键序列(不包括最后的C-j),并用它们替换键盘宏中的当前命令,在插入的按键序列上前进。
  • r key… C-j reads and executes a series of key sequences (not including the final C-j), and replaces the current command in the keyboard macro with them, advancing over the inserted key sequences.
  • R key读取一个按键序列,执行它,然后用该按键序列替换键盘宏中的当前命令,并在插入的按键序列上前进。
  • R key reads one key sequence, executes it, and replaces the current command in the keyboard macro with that key sequence, advancing over the inserted key sequence.
  • a key… C-j执行当前命令,然后读取并执行一系列按键序列(不包括最后的 C-j),并将它们插入到键盘宏中的当前命令之后;然后它会前进到当前命令和插入的按键序列。
  • a key… C-j executes the current command, then reads and executes a series of key sequences (not including the final C-j), and inserts them after the current command in the keyboard macro; it then advances over the current command and the inserted key sequences.
  • A key… C-j执行键盘宏中的其余命令,然后读取并执行一系列键序列(不包括final C-j),并将它们附加到键盘宏的末尾;然后它终止分步编辑并用编辑后的宏替换原始键盘宏。
  • A key… C-j executes the rest of the commands in the keyboard macro, then reads and executes a series of key sequences (not including the final C-j), and appends them at the end of the keyboard macro; it then terminates the step-editing and replaces the original keyboard macro with the edited macro.

19 文件处理

19 File Handling

操作系统将数据永久存储在命名文件中,因此您使用 Emacs 编辑的大部分文本都来自文件并最终存储在文件中。

The operating system stores data permanently in named files, so most of the text you edit with Emacs comes from a file and is ultimately stored in a file.

要编辑文件,您必须告诉 Emacs 读取该文件并准备一个包含文件文本副本的缓冲区。这称为 访问文件。编辑命令直接应用于缓冲区中的文本;也就是复制到Emacs内部。仅当您将缓冲区保存回文件 时,您的更改才会出现在文件本身中。

To edit a file, you must tell Emacs to read the file and prepare a buffer containing a copy of the file’s text. This is called visiting the file. Editing commands apply directly to text in the buffer; that is, to the copy inside Emacs. Your changes appear in the file itself only when you save the buffer back into the file.

除了访问和保存文件之外,Emacs 还可以删除、复制、重命名和附加文件、保留文件的多个版本以及对文件目录进行操作。

In addition to visiting and saving files, Emacs can delete, copy, rename, and append to files, keep multiple versions of them, and operate on file directories.


19.1 文件名

19.1 File Names

许多对文件进行操作的 Emacs 命令要求您使用迷你缓冲区指定文件名(请参阅文件名的迷你缓冲区)。

Many Emacs commands that operate on a file require you to specify the file name, using the minibuffer (see Minibuffers for File Names).

在迷你缓冲区中时,您可以使用常用的完成和历史命令(请参阅迷你缓冲区)。请注意,文件名完成会忽略扩展名出现在变量中的文件名 completion-ignored-extensions(请参阅完成选项)。另请注意,大多数命令使用允许完成并确认读取文件名:允许您提交不存在的文件名,但如果您RET在完成不存在的文件名后立即键入,Emacs 会打印 '[确认]' 并且您必须输入第二个字符RET来确认。有关详细信息,请参阅完成退出

While in the minibuffer, you can use the usual completion and history commands (see The Minibuffer). Note that file name completion ignores file names whose extensions appear in the variable completion-ignored-extensions (see Completion Options). Note also that most commands use permissive completion with confirmation for reading file names: you are allowed to submit a nonexistent file name, but if you type RET immediately after completing up to a nonexistent file name, Emacs prints ‘[Confirm]’ and you must type a second RET to confirm. See Completion Exit, for details.

迷你缓冲区历史命令提供了一些用于读取文件名的特殊功能,请参阅迷你缓冲区历史记录

Minibuffer history commands offer some special features for reading file names, see Minibuffer History.

每个缓冲区都有一个默认目录,存储在缓冲区局部变量中default-directory。每当 Emacs 使用迷你缓冲区读取文件名时,它通常会将默认目录插入到迷你缓冲区中作为初始内容。您可以通过将变量更改 insert-default-directorynil(请参阅文件名的迷你缓冲区)来禁止此插入。无论如何,Emacs 始终假定任何相对文件名都是相对于默认目录的,例如,输入不带目录的文件名指定默认目录中的文件。

Each buffer has a default directory, stored in the buffer-local variable default-directory. Whenever Emacs reads a file name using the minibuffer, it usually inserts the default directory into the minibuffer as the initial contents. You can inhibit this insertion by changing the variable insert-default-directory to nil (see Minibuffers for File Names). Regardless, Emacs always assumes that any relative file name is relative to the default directory, e.g., entering a file name without a directory specifies a file in the default directory.

当您访问一个文件时,Emacs 将default-directory访问缓冲区设置为该文件的目录。当您通过类似命令创建不访问文件的新缓冲区时,C-x b通常会从当时的当前缓冲区复制其默认目录(请参阅创建和选择缓冲区)。您可以使用该命令 M-x pwd查看default-directory当前缓冲区中的值。该命令M-x cd提示输入目录名称,并将缓冲区设置default-directory为该目录(这样做不会更改缓冲区的文件名(如果有))。

When you visit a file, Emacs sets default-directory in the visiting buffer to the directory of its file. When you create a new buffer that is not visiting a file, via a command like C-x b, its default directory is usually copied from the buffer that was current at the time (see Creating and Selecting Buffers). You can use the command M-x pwd to see the value of default-directory in the current buffer. The command M-x cd prompts for a directory’s name, and sets the buffer’s default-directory to that directory (doing this does not change the buffer’s file name, if any).

例如,当您访问文件时/u/rms/gnu/gnu.tasks,默认目录设置为/u/rms/gnu/。如果您调用读取文件名的命令,只需输入 '' 在迷你缓冲区中,省略目录,指定文件 /u/rms/gnu/foo;进入'../。登录' 指定 /u/rms/.login;并输入 '新/富' 指定 /u/rms/gnu/new/foo

As an example, when you visit the file /u/rms/gnu/gnu.tasks, the default directory is set to /u/rms/gnu/. If you invoke a command that reads a file name, entering just ‘foo’ in the minibuffer, with a directory omitted, specifies the file /u/rms/gnu/foo; entering ‘../.login’ specifies /u/rms/.login; and entering ‘new/foo’ specifies /u/rms/gnu/new/foo.

在迷你缓冲区中输入文件名时,您可以使用几个快捷方式:双斜杠会忽略成对的第二个斜杠之前的所有内容,并且 '〜/' 是您的主目录。有关文件名,请参阅迷你缓冲区。

When typing a file name into the minibuffer, you can make use of a couple of shortcuts: a double slash ignores everything before the second slash in the pair, and ‘~/’ is your home directory. See Minibuffers for File Names.

人物 '$' 用于将环境变量替换为文件名。环境变量的名称由 ' 后面的所有字母数字字符组成$';或者,可以在 ' 之后将其括在大括号中$'。例如,如果您使用 shell 命令 export FOO=rms/hacks设置了名为 的环境变量 FOO,则两者/u/$FOO/test.c/u/${FOO}/test.c是缩写 /u/rms/hacks/test.c。如果未定义环境变量,则不会发生替换,因此字符 '$' 代表它自己。请注意,在 Emacs 外部设置的环境变量只有在 Emacs 启动之前应用时才会影响 Emacs。

The character ‘$’ is used to substitute an environment variable into a file name. The name of the environment variable consists of all the alphanumeric characters after the ‘$’; alternatively, it can be enclosed in braces after the ‘$’. For example, if you have used the shell command export FOO=rms/hacks to set up an environment variable named FOO, then both /u/$FOO/test.c and /u/${FOO}/test.c are abbreviations for /u/rms/hacks/test.c. If the environment variable is not defined, no substitution occurs, so that the character ‘$’ stands for itself. Note that environment variables set outside Emacs affect Emacs only if they are applied before Emacs is started.

使用 ' 访问文件$' 在其名称中,如果 '$' 导致扩展,输入 '$$'。该对被转换为单个 '$' 同时对单个 ' 执行变量替换$'。或者,用 ' 引用整个文件名/:'(参见引用的文件名)。以文字 ' 开头的文件名' 也应该用 ' 引用/:'。

To access a file with ‘$’ in its name, if the ‘$’ causes expansion, type ‘$$’. This pair is converted to a single ‘$’ at the same time that variable substitution is performed for a single ‘$’. Alternatively, quote the whole file name with ‘/:’ (see Quoted File Names). File names which begin with a literal ‘~’ should also be quoted with ‘/:’.

您可以在文件名中包含非ASCII字符。请参阅文件名编码系统

You can include non-ASCII characters in file names. See Coding Systems for File Names.


19.2 访问文件

19.2 Visiting Files

C-x C-f
C-x C-f

访问文件 ( find-file)。

Visit a file (find-file).

C-x C-r
C-x C-r

访问文件进行查看,但不允许对其进行更改 ( find-file-read-only)。

Visit a file for viewing, without allowing changes to it (find-file-read-only).

C-x C-v
C-x C-v

访问不同的文件而不是上次访问的文件 ( find-alternate-file)。

Visit a different file instead of the one visited last (find-alternate-file).

C-x 4 f
C-x 4 f

在另一个窗口中访问文件 ( find-file-other-window)。不要更改所选窗口中显示的内容。

Visit a file, in another window (find-file-other-window). Don’t alter what is displayed in the selected window.

C-x 5 f
C-x 5 f

在新框架 ( ) 中访问文件find-file-other-frame。不要更改所选框架中显示的内容。

Visit a file, in a new frame (find-file-other-frame). Don’t alter what is displayed in the selected frame.

M-x find-file-literally
M-x find-file-literally

访问不转换内容的文件。

Visit a file with no conversion of the contents.

访问文件意味着将其内容读入 Emacs 缓冲区,以便您可以编辑它们。 Emacs 为您访问的每个文件创建一个新的缓冲区。

Visiting a file means reading its contents into an Emacs buffer so you can edit them. Emacs makes a new buffer for each file that you visit.

要访问文件,请键入C-x C-f( find-file) 并使用迷你缓冲区输入所需文件的名称。在迷你缓冲区中时,您可以通过键入 来中止命令C-g。有关将文件名输入迷你缓冲区的详细信息, 请参阅文件名。

To visit a file, type C-x C-f (find-file) and use the minibuffer to enter the name of the desired file. While in the minibuffer, you can abort the command by typing C-g. See File Names, for details about entering file names into minibuffers.

如果指定的文件存在,但系统不允许您读取它,则会在回显区域中显示一条错误消息(在 GNU 和 Unix 系统上,您可以使用 '' 或者 '须藤' 方法;请参阅远程文件)。否则,您可以C-x C-f通过屏幕上新文本的出现以及模式行中显示的缓冲区名称来判断已成功完成(请参阅模式行)。 Emacs 通常根据文件名构造缓冲区名称,省略目录名。例如,一个名为/usr/rms/emacs.tex在名为 ' 的缓冲区中被访问emacs.tex'。如果已经存在具有该名称的缓冲区,Emacs 会构造一个唯一的名称;正常的方法是根据目录名添加后缀(例如,'<有效值>','<临时>'等),但您可以选择其他方法。请参阅使缓冲区名称唯一

If the specified file exists but the system does not allow you to read it, an error message is displayed in the echo area (on GNU and Unix systems you might be able to visit such a file using the ‘su’ or ‘sudo’ methods; see Remote Files). Otherwise, you can tell that C-x C-f has completed successfully by the appearance of new text on the screen, and by the buffer name shown in the mode line (see The Mode Line). Emacs normally constructs the buffer name from the file name, omitting the directory name. For example, a file named /usr/rms/emacs.tex is visited in a buffer named ‘emacs.tex’. If there is already a buffer with that name, Emacs constructs a unique name; the normal method is to add a suffix based on the directory name (e.g., ‘<rms>’, ‘<tmp>’, and so on), but you can select other methods. See Making Buffer Names Unique.

要创建新文件,只需使用相同的命令C-x C-f. Emacs 显示 '(新文件)' 在回显区域,但在其他方面的行为就好像您访问了现有的空文件一样。

To create a new file, just visit it using the same command, C-x C-f. Emacs displays ‘(New file)’ in the echo area, but in other respects behaves as if you had visited an existing empty file.

访问文件后,您使用编辑命令所做的更改将在 Emacs 缓冲区中进行。它们不会在访问的文件中生效,直到您保存缓冲区(请参阅保存文件)。如果缓冲区包含尚未保存的更改,我们称该缓冲区已 修改。这意味着如果不保存缓冲区,一些更改将会丢失。模式行在左边距附近显示两颗星,表示缓冲区已修改。

After visiting a file, the changes you make with editing commands are made in the Emacs buffer. They do not take effect in the visited file, until you save the buffer (see Saving Files). If a buffer contains changes that have not been saved, we say the buffer is modified. This implies that some changes will be lost if the buffer is not saved. The mode line displays two stars near the left margin to indicate that the buffer is modified.

如果您访问 Emacs 中已有的文件,C-x C-f请切换到现有缓冲区,而不是制作另一个副本。在此之前,它会检查该文件自您上次访问或保存以来是否已更改。如果文件已更改,Emacs 会重新读取它。

If you visit a file that is already in Emacs, C-x C-f switches to the existing buffer instead of making another copy. Before doing so, it checks whether the file has changed since you last visited or saved it. If the file has changed, Emacs offers to reread it.

如果您尝试访问大于 large-file-warning-threshold(默认为 10000000,大约 10 兆字节)的文件,Emacs 会首先要求您确认。您可以选择y继续访问该文件或l直接访问该文件(见下文)。访问大文件确实可以加快此类文件的导航和编辑速度,因为各种可能昂贵的功能都被关闭。但请注意,Emacs 无法访问大于最大 Emacs 缓冲区大小的文件,该大小受到 Emacs 可以分配的内存量以及 Emacs 可以表示的整数的限制(请参阅使用多个缓冲区)。如果您尝试,Emacs 会显示一条错误消息,指出已超出最大缓冲区大小。

If you try to visit a file larger than large-file-warning-threshold (the default is 10000000, which is about 10 megabytes), Emacs asks you for confirmation first. You can answer y to proceed with visiting the file or l to visit the file literally (see below). Visiting large files literally speeds up navigation and editing of such files, because various potentially-expensive features are turned off. Note, however, that Emacs cannot visit files that are larger than the maximum Emacs buffer size, which is limited by the amount of memory Emacs can allocate and by the integers that Emacs can represent (see Using Multiple Buffers). If you try, Emacs displays an error message saying that the maximum buffer size has been exceeded.

如果您尝试访问其主要模式(请参阅主要模式)使用 tree-sitter 解析库的文件,如果文件的大小(以字节为单位)大于变量的值,Emacs 将显示警告 treesit-max-buffer-size。 64 位 Emacs 的默认值为 40 MB,32 位 Emacs 的默认值为 15 MB。这样可以防止在如此大的缓冲区中激活基于树驻留者的主要模式,从而避免 Emacs 耗尽内存的危险,因为典型的树驻留者解析器需要的内存大约是它解析的文本的 10 倍。

If you try to visit a file whose major mode (see Major Modes) uses the tree-sitter parsing library, Emacs will display a warning if the file’s size in bytes is larger than the value of the variable treesit-max-buffer-size. The default value is 40 megabytes for 64-bit Emacs and 15 megabytes for 32-bit Emacs. This avoids the danger of having Emacs run out of memory by preventing the activation of major modes based on tree-sitter in such large buffers, because a typical tree-sitter parser needs about 10 times as much memory as the text it parses.

如果您指定的文件名包含 shell 样式的通配符,Emacs 会访问与其匹配的所有文件。 (在不区分大小写的文件系统上,Emacs 匹配通配符时不考虑字母大小写。)通配符包括 '','*', 和 '[…]' 序列。输入通配符'' 在迷你缓冲区的文件名中,您需要输入C-q ?.有关如何访问名称实际上包含通配符的文件的信息,请参阅引用的文件名。您可以通过自定义禁用通配符功能find-file-wildcards

If the file name you specify contains shell-style wildcard characters, Emacs visits all the files that match it. (On case-insensitive filesystems, Emacs matches the wildcards disregarding the letter case.) Wildcards include ‘?’, ‘*’, and ‘[…]’ sequences. To enter the wild card ‘?’ in a file name in the minibuffer, you need to type C-q ?. See Quoted File Names, for information on how to visit a file whose name actually contains wildcard characters. You can disable the wildcard feature by customizing find-file-wildcards.

如果您要求访问缓冲区中已访问过的文件,但该文件已在外部发生更改,Emacs 通常会询问您是否要从磁盘重新读取该文件。但如果您设置 query-about-changed-filenil,Emacs 不会查询您,而只会显示更改之前的缓冲区内容,并显示一条回显区域消息,告诉您如何从文件恢复缓冲区。

If you’re asking to visit a file that’s already visited in a buffer, but the file has changed externally, Emacs normally asks you whether you want to re-read the file from disk. But if you set query-about-changed-file to nil, Emacs won’t query you, but will instead just display the buffer’s contents before the changes, and show an echo-area message telling you how to revert the buffer from the file.

如果您由于输入错误的名称而无意中访问了错误的文件,请输入C-x C-v( find-alternate-file) 以访问您真正想要的文件。 C-x C-v与 类似C-x C-f,但它会杀死当前缓冲区(在第一次提出如果修改则保存它之后)。当C-x C-v读取要访问的文件名时,将整个默认文件名插入到缓冲区中,在目录部分后面加上点;如果您在输入姓名时犯了轻微错误,这会很方便。

If you visit the wrong file unintentionally by typing its name incorrectly, type C-x C-v (find-alternate-file) to visit the file you really wanted. C-x C-v is similar to C-x C-f, but it kills the current buffer (after first offering to save it if it is modified). When C-x C-v reads the file name to visit, it inserts the entire default file name in the buffer, with point just after the directory part; this is convenient if you made a slight error in typing the name.

如果您访问的文件实际上是一个目录,Emacs 会调用 Dired,即 Emacs 目录浏览器。请参阅Dired,目录编辑器。您可以通过将变量设置find-file-run-dired为来 禁用此行为nil;在这种情况下,尝试访问目录是错误的。

If you visit a file that is actually a directory, Emacs invokes Dired, the Emacs directory browser. See Dired, the Directory Editor. You can disable this behavior by setting the variable find-file-run-dired to nil; in that case, it is an error to try to visit a directory.

文件实际上是其他文件或文件档案的集合,以特殊模式访问,该模式调用类似 Dired 的环境以允许对档案成员进行操作。有关这些功能的更多信息, 请参阅文件档案。

Files which are actually collections of other files, or file archives, are visited in special modes which invoke a Dired-like environment to allow operations on archive members. See File Archives, for more about these features.

如果您访问操作系统不允许您修改的文件,或者标记为只读的文件,Emacs 也会将缓冲区设置为只读,这样您就不会继续进行可能会遇到麻烦的更改之后保存。您可以使用C-x C-q ( )使缓冲区可写read-only-mode。请参阅其他缓冲区操作

If you visit a file that the operating system won’t let you modify, or that is marked read-only, Emacs makes the buffer read-only too, so that you won’t go ahead and make changes that you’ll have trouble saving afterward. You can make the buffer writable with C-x C-q (read-only-mode). See Miscellaneous Buffer Operations.

如果您想以只读方式访问文件以防止意外输入更改,请使用命令 C-x C-r( find-file-read-only) 而不是 来访问它C-x C-f

If you want to visit a file as read-only in order to protect yourself from entering changes accidentally, visit it with the command C-x C-r (find-file-read-only) instead of C-x C-f.

C-x 4 f( find-file-other-window) 类似C-x C-f ,只是在另一个窗口中选择了包含指定文件的缓冲区。之前选择的窗口C-x 4 f继续显示它已经显示的相同缓冲区。如果仅显示一个窗口时使用此命令,则该窗口将一分为二,一个窗口显示与之前相同的缓冲区,另一个窗口显示新请求的文件。请参阅多个窗口

C-x 4 f (find-file-other-window) is like C-x C-f except that the buffer containing the specified file is selected in another window. The window that was selected before C-x 4 f continues to show the same buffer it was already showing. If this command is used when only one window is being displayed, that window is split in two, with one window showing the same buffer as before, and the other one showing the newly requested file. See Multiple Windows.

C-x 5 f( find-file-other-frame) 类似,但打开一个新框架,或选择显示指定文件的任何现有框架。请参阅框架和图形显示

C-x 5 f (find-file-other-frame) is similar, but opens a new frame, or selects any existing frame showing the specified file. See Frames and Graphical Displays.

在图形显示上,还有两种访问文件的附加方法。首先,当使用合适的 GUI 工具包构建 Emacs 时,用鼠标调用的命令(通过单击菜单栏或工具栏)使用工具包的标准文件选择对话框,而不是提示输入迷你缓冲区中的文件名。在 GNU/Linux 和 Unix 平台上,Emacs 在使用 GTK+、LessTif 和 Motif 工具包构建时可以做到这一点;在 MS-Windows 和 Mac 上,GUI 版本默认执行此操作。有关如何自定义此功能的信息,请参阅使用对话框

On graphical displays, there are two additional methods for visiting files. Firstly, when Emacs is built with a suitable GUI toolkit, commands invoked with the mouse (by clicking on the menu bar or tool bar) use the toolkit’s standard file selection dialog instead of prompting for the file name in the minibuffer. On GNU/Linux and Unix platforms, Emacs does this when built with GTK+, LessTif, and Motif toolkits; on MS-Windows and Mac, the GUI version does that by default. For information on how to customize this, see Using Dialog Boxes.

其次,Emacs 支持拖放:将文件拖放到普通的 Emacs 窗口中可以使用该窗口访问该文件。作为例外,将文件拖放到显示 Dired 缓冲区的窗口中会将文件移动或复制到显示的目录中。有关详细信息,请参阅拖放其他 Dired 功能

Secondly, Emacs supports drag and drop: dropping a file into an ordinary Emacs window visits the file using that window. As an exception, dropping a file into a window displaying a Dired buffer moves or copies the file into the displayed directory. For details, see Drag and Drop, and Other Dired Features.

在文本模式终端和图形显示器上,当 Emacs 是在没有 GUI 工具包的情况下构建时,您可以通过菜单栏 '文件' 菜单,其中有 '访问新文件' 和 '打开文件' 项目。

On text-mode terminals and on graphical displays when Emacs was built without a GUI toolkit, you can visit files via the menu-bar ‘File’ menu, which has the ‘Visit New File’ and the ‘Open File’ items.

每次访问文件时,Emacs 都会自动扫描其内容以检测它使用的字符编码和行结束约定,并将它们转换为缓冲区内 Emacs 的内部编码和行结束约定。当您保存缓冲区时,Emacs 会执行逆转换,将文件以其原始编码和行尾约定写入磁盘。请参阅编码系统

Each time you visit a file, Emacs automatically scans its contents to detect what character encoding and end-of-line convention it uses, and converts these to Emacs’s internal encoding and end-of-line convention within the buffer. When you save the buffer, Emacs performs the inverse conversion, writing the file to disk with its original encoding and end-of-line convention. See Coding Systems.

如果您希望将文件编辑为ASCII字符序列而 无需特殊编码或转换,请使用该M-x find-file-literally命令。这会访问一个文件,例如C-x C-f,但不会进行格式转换(请参阅Emacs Lisp 参考手册中的格式转换)、字符代码转换(请参阅编码系统)或自动解压缩(请参阅访问压缩文件),并且不添加最终的因为换行(请参阅自定义文件保存)。如果您已经以通常(非字面)方式访问过同一文件,则此命令会询问您是否按字面访问它。 require-final-newline

If you wish to edit a file as a sequence of ASCII characters with no special encoding or conversion, use the M-x find-file-literally command. This visits a file, like C-x C-f, but does not do format conversion (see Format Conversion in the Emacs Lisp Reference Manual), character code conversion (see Coding Systems), or automatic uncompression (see Accessing Compressed Files), and does not add a final newline because of require-final-newline (see Customizing Saving of Files). If you have already visited the same file in the usual (non-literal) manner, this command asks you whether to visit it literally instead.

文件有时(松散地)与其他文件绑定,您可以将这些文件称为同级文件。例如,在编辑 C 文件时,如果您有一个名为 '“foo.c”',您通常还有一个名为 '“foo.h”',这可能是它的同级文件。或者您可能有不同版本的文件,例如'“src/emacs/emacs-27/lisp/allout.el”' 和 '“src/emacs/emacs-28/lisp/allout.el”' 可能会被视为兄弟姐妹。 Emacs 提供了find-sibling-file在同级文件之间跳转的命令,但不可能猜测用户可能希望将哪些文件视为同级文件,因此 Emacs 允许您通过更改find-sibling-rules用户选项来自由配置它。这是匹配/扩展元素的列表。

Files are sometimes (loosely) tied to other files, and you could call these files sibling files. For instance, when editing C files, if you have a file called ‘"foo.c"’, you often also have a file called ‘"foo.h"’, and that could be its sibling file. Or you may have different versions of a file, for instance ‘"src/emacs/emacs-27/lisp/allout.el"’ and ‘"src/emacs/emacs-28/lisp/allout.el"’ might be considered siblings. Emacs provides the find-sibling-file command to jump between sibling files, but it’s impossible to guess at which files a user might want to be considered siblings, so Emacs lets you configure this freely by altering the find-sibling-rules user option. This is a list of match/expansion elements.

例如,要做'“。C”' 到 '“。H”' 映射,你可以说:

For instance, to do the ‘".c"’ to ‘".h"’ mapping, you could say:

(setq 查找兄弟规则
      '(("\\([^/]+\\)\\.c\\'" "\\1.h")))
(setq find-sibling-rules
      '(("\\([^/]+\\)\\.c\\'" "\\1.h")))

ff-find-related-file提供类似的功能,特别是针对 C 文件,请参阅C 模式的其他命令。)

(ff-find-related-file offers similar functionality especially geared towards C files, see Other Commands for C Mode.)

或者,如果您想考虑 ' 下的所有文件“src/emacs/DIR/文件名”' 要成为其他dir的兄弟姐妹,你可以说:

Or, if you want to consider all files under ‘"src/emacs/DIR/file-name"’ to be siblings of other dirs, you could say:

(setq 查找兄弟规则
      '(("src/emacs/[^/]+/\\(.*\\)\\'" "src/emacs/.*/\\1")))
(setq find-sibling-rules
      '(("src/emacs/[^/]+/\\(.*\\)\\'" "src/emacs/.*/\\1")))

正如您所看到的,这是一个(MATCH EXPANSION...)元素的列表。匹配是匹配访问的文件名的正则表达式,每个扩展可以通过使用 ' 来引用匹配组\\1' 等等。然后将生成的扩展字符串应用于文件系统,以查看是否有任何文件与此扩展匹配(解释为正则表达式)。

As you can see, this is a list of (MATCH EXPANSION...) elements. The match is a regular expression that matches the visited file name, and each expansion may refer to match groups by using ‘\\1’ and so on. The resulting expansion string is then applied to the file system to see if any files match this expansion (interpreted as a regexp).

两个特殊的钩子变量允许扩展修改访问文件的操作。访问不存在的文件会运行find-file-not-found-functions;中的函数。该变量保存一个函数列表,这些函数被一一调用(不带参数),直到其中一个返回非- nil。这不是一个普通的钩子,名称以 ' 结尾-功能' 而不是 '-钩'来表明这一事实。

Two special hook variables allow extensions to modify the operation of visiting files. Visiting a file that does not exist runs the functions in find-file-not-found-functions; this variable holds a list of functions, which are called one by one (with no arguments) until one of them returns non-nil. This is not a normal hook, and the name ends in ‘-functions’ rather than ‘-hook’ to indicate that fact.

成功访问任何文件,无论是否存在,都会调用 中的函数find-file-hook,不带参数。这个变量是一个普通的钩子。如果文件不存在,则 find-file-not-found-functions首先运行。请参阅钩子

Successful visiting of any file, whether existing or not, calls the functions in find-file-hook, with no arguments. This variable is a normal hook. In the case of a nonexistent file, the find-file-not-found-functions are run first. See Hooks.

有多种方法可以自动指定编辑文件的主要模式(请参阅选择文件模式),以及指定为该文件定义的局部变量(请参阅文件中的局部变量)。

There are several ways to specify automatically the major mode for editing the file (see Choosing File Modes), and to specify local variables defined for that file (see Local Variables in Files).


19.3 保存文件

19.3 Saving Files

在 Emacs 中保存缓冲区意味着将其内容写回到缓冲区中访问过的文件中。

Saving a buffer in Emacs means writing its contents back into the file that was visited in the buffer.


19.3.1 保存文件命令

19.3.1 Commands for Saving Files

这些是与保存和写入文件相关的命令。

These are the commands that relate to saving and writing files.

C-x C-s
C-x C-s

将当前缓冲区保存到其文件 ( save-buffer)。

Save the current buffer to its file (save-buffer).

C-x s
C-x s

将任何或所有缓冲区保存到其文件中 ( save-some-buffers)。

Save any or all buffers to their files (save-some-buffers).

M-~
M-~

忘记当前缓冲区已更改 ( not-modified)。使用前缀参数 ( C-u),将当前缓冲区标记为已更改。

Forget that the current buffer has been changed (not-modified). With prefix argument (C-u), mark the current buffer as changed.

C-x C-w
C-x C-w

write-file使用指定的文件名 ( ) 保存当前缓冲区。

Save the current buffer with a specified file name (write-file).

M-x set-visited-file-name
M-x set-visited-file-name

更改保存当前缓冲区的文件名。

Change the file name under which the current buffer will be saved.

M-x rename-visited-file
M-x rename-visited-file

与 相同M-x set-visited-file-name,但也重命名缓冲区正在访问的文件(如果有)。

The same as M-x set-visited-file-name, but also rename the file the buffer is visiting (if any).

当您希望保存文件并使更改永久生效时,请键入 C-x C-s( save-buffer)。保存完成后,C-x C-s 显示如下消息:

When you wish to save the file and make your changes permanent, type C-x C-s (save-buffer). After saving is finished, C-x C-s displays a message like this:

写入/u/rms/gnu/gnu.tasks
Wrote /u/rms/gnu/gnu.tasks

如果当前缓冲区未被修改(自缓冲区创建或上次保存以来未对其进行任何更改),则保存并未真正完成,因为它不会产生任何效果。相反,C-x C-s 在回显区域显示如下消息:

If the current buffer is not modified (no changes have been made in it since the buffer was created or last saved), saving is not really done, because it would have no effect. Instead, C-x C-s displays a message like this in the echo area:

(无需保存任何更改)
(No changes need to be saved)

通过前缀参数C-u C-x C-s,Emacs 还会标记下一次保存完成时要备份的缓冲区。请参阅备份文件

With a prefix argument, C-u C-x C-s, Emacs also marks the buffer to be backed up when the next save is done. See Backup Files.

命令C-x s( save-some-buffers) 可以保存任何或所有修改的缓冲区。它询问您如何处理每个缓冲区。可能的响应类似于query-replace

The command C-x s (save-some-buffers) offers to save any or all modified buffers. It asks you what to do with each buffer. The possible responses are analogous to those of query-replace:

y
y
SPC
SPC

保存该缓冲区并询问其余缓冲区的情况。

Save this buffer and ask about the rest of the buffers.

n
n
DEL
DEL

不要保存此缓冲区,但询问其余缓冲区。

Don’t save this buffer, but ask about the rest of the buffers.

!
!

保存此缓冲区和所有其余内容,不再有任何问题。

Save this buffer and all the rest with no more questions.

q
q
RET
RET

终止save-some-buffers而不进行任何保存。

Terminate save-some-buffers without any more saving.

.
.

保存此缓冲区,然后退出,save-some-buffers甚至不询问其他缓冲区。

Save this buffer, then exit save-some-buffers without even asking about other buffers.

C-r
C-r

查看当前询问您的缓冲区。当您退出“查看”模式时,您将返回到save-some-buffers,它会再次询问该问题。

View the buffer that you are currently being asked about. When you exit View mode, you get back to save-some-buffers, which asks the question again.

C-f
C-f

退出save-some-buffers并访问当前询问您的缓冲区。

Exit save-some-buffers and visit the buffer that you are currently being asked about.

d
d

将缓冲区与其相应的文件进行比较,以便您可以看到将保存哪些更改。这将调用该命令 diff-buffer-with-file(请参阅比较文件)。

Diff the buffer against its corresponding file, so you can see what changes you would be saving. This calls the command diff-buffer-with-file (see Comparing Files).

C-h
C-h

显示有关这些选项的帮助消息。

Display a help message about these options.

您可以自定义 的值 save-some-buffers-default-predicate来控制 Emacs 将询问哪些缓冲区。

You can customize the value of save-some-buffers-default-predicate to control which buffers Emacs will ask about.

C-x C-c,退出 Emacs 的按键序列,调用 save-some-buffers并因此询问相同的问题。

C-x C-c, the key sequence to exit Emacs, invokes save-some-buffers and therefore asks the same questions.

如果您更改了缓冲区但不希望保存更改,则应该采取一些措施来阻止它。否则,每次使用C-x s或 时C-x C-c,您都有可能错误地保存该缓冲区。您可以做的一件事是键入M-~ ( not-modified),它会清除缓冲区已修改的指示。如果这样做,则所有保存命令都不会认为需要保存缓冲区。 ('' 通常用作“not”的数学符号;或者M-~,您可以通过再次读取文件中的文本来取消自访问或保存文件以来所做的所有更改。这称为恢复。请参阅恢复缓冲区。 (您也可以通过重复撤消命令来撤消所有更改,C-x u直到撤消所有更改;但恢复更容易。)

If you have changed a buffer but do not wish to save the changes, you should take some action to prevent it. Otherwise, each time you use C-x s or C-x C-c, you are liable to save this buffer by mistake. One thing you can do is type M-~ (not-modified), which clears out the indication that the buffer is modified. If you do this, none of the save commands will believe that the buffer needs to be saved. (‘~’ is often used as a mathematical symbol for “not”; thus M-~ is “not”, metafied.) Alternatively, you can cancel all the changes made since the file was visited or saved, by reading the text from the file again. This is called reverting. See Reverting a Buffer. (You could also undo all the changes by repeating the undo command C-x u until you have undone all the changes; but reverting is easier.)

M-x set-visited-file-name更改当前缓冲区正在访问的文件的名称。它使用迷你缓冲区读取新文件名。然后它将缓冲区标记为访问该文件名,并相应地更改缓冲区名称。 set-visited-file-name 不将缓冲区保存在新访问的文件中;它只是更改 Emacs 内的记录,以防您稍后保存。它还将缓冲区标记为已修改,以便C-x C-s在该缓冲区中 进行保存。

M-x set-visited-file-name alters the name of the file that the current buffer is visiting. It reads the new file name using the minibuffer. Then it marks the buffer as visiting that file name, and changes the buffer name correspondingly. set-visited-file-name does not save the buffer in the newly visited file; it just alters the records inside Emacs in case you do save later. It also marks the buffer as modified so that C-x C-s in that buffer will save.

如果您希望将缓冲区标记为访问不同的文件并立即保存,请使用C-x C-w( write-file)。这相当于set-visited-file-name后跟C-x C-s,只不过C-x C-w要求确认文件是否存在。 C-x C-s在不访问文件的缓冲区上使用与 ; 具有相同的效果C-x C-w。也就是说,它读取文件名,将缓冲区标记为访问该文件,并将其保存在那里。未访问文件的缓冲区中的默认文件名是通过将缓冲区名称与缓冲区的默认目录组合而成的(请参阅文件名)。

If you wish to mark the buffer as visiting a different file and save it right away, use C-x C-w (write-file). This is equivalent to set-visited-file-name followed by C-x C-s, except that C-x C-w asks for confirmation if the file exists. C-x C-s used on a buffer that is not visiting a file has the same effect as C-x C-w; that is, it reads a file name, marks the buffer as visiting that file, and saves it there. The default file name in a buffer that is not visiting a file is made by combining the buffer name with the buffer’s default directory (see File Names).

如果新文件名暗示主模式,则C-x C-w在大多数情况下切换到该主模式。该命令 set-visited-file-name也执行此操作。请参阅选择文件模式

If the new file name implies a major mode, then C-x C-w switches to that major mode, in most cases. The command set-visited-file-name also does this. See Choosing File Modes.

如果您希望将当前缓冲区保存到另一个文件而不访问该文件,请使用mark-whole-buffer( C-x h),然后 (请参阅其他文件操作)。 M-x write-region

If you wish to save the current buffer to a different file without visiting that file, use mark-whole-buffer (C-x h), then M-x write-region (see Miscellaneous File Operations).

如果 Emacs 即将保存文件并发现磁盘上最新版本的日期与 Emacs 最后读取或写入的日期不匹配,Emacs 会通知您这一事实,因为这可能表明存在由同时编辑引起的问题,需要您立即进行修复。注意力。请参阅同时编辑

If Emacs is about to save a file and sees that the date of the latest version on disk does not match what Emacs last read or wrote, Emacs notifies you of this fact, because it probably indicates a problem caused by simultaneous editing and requires your immediate attention. See Simultaneous Editing.


19.3.2 备份文件

19.3.2 Backup Files

在大多数操作系统上,重写文件会自动销毁该文件曾经包含的所有记录。因此,从 Emacs 保存文件会丢弃文件的旧内容,或者会丢弃文件的旧内容,除非 Emacs 在实际保存之前 小心地将旧内容复制到另一个文件(称为备份文件)。

On most operating systems, rewriting a file automatically destroys all record of what the file used to contain. Thus, saving a file from Emacs throws away the old contents of the file—or it would, except that Emacs carefully copies the old contents to another file, called the backup file, before actually saving.

Emacs 仅在第一次从缓冲区保存文件时才对文件进行备份。无论您随后保存该文件多少次,其备份都保持不变。但是,如果您终止缓冲区然后再次访问该文件,则会创建一个新的备份文件。

Emacs makes a backup for a file only the first time the file is saved from a buffer. No matter how many times you subsequently save the file, its backup remains unchanged. However, if you kill the buffer and then visit the file again, a new backup file will be made.

对于大多数文件来说,该变量make-backup-files决定是否制作备份文件。在大多数操作系统上,其默认值为t,以便 Emacs 确实写入备份文件。

For most files, the variable make-backup-files determines whether to make backup files. On most operating systems, its default value is t, so that Emacs does write backup files.

对于由版本控制系统管理的文件(请参阅版本控制),该变量vc-make-backup-files决定是否制作备份文件。默认情况下是这样nil,因为当您将所有以前的版本存储在版本控制系统中时,备份文件是多余的。请参阅常规选项

For files managed by a version control system (see Version Control), the variable vc-make-backup-files determines whether to make backup files. By default it is nil, since backup files are redundant when you store all the previous versions in a version control system. See General Options.

根据您的选择,Emacs 可以为每个文件保留一个备份,也可以为您编辑的每个文件创建一系列编号的备份文件。请参阅单个备份或编号备份

At your option, Emacs can keep either a single backup for each file, or make a series of numbered backup files for each file that you edit. See Single or Numbered Backups.

该变量的默认值防止为由或 backup-enable-predicate指定的临时文件目录中的文件写入备份文件。 temporary-file-directorysmall-temporary-file-directory

The default value of the backup-enable-predicate variable prevents backup files being written for files in the directories used for temporary files, specified by temporary-file-directory or small-temporary-file-directory.

您可以明确地告诉 Emacs 从缓冲区创建另一个备份文件,即使该缓冲区之前已保存过。如果用 保存缓冲区C-u C-x C-s,则再次保存缓冲区时,保存的版本将成为备份文件。 C-u C-u C-x C-s保存缓冲区,但首先将以前的文件内容放入新的备份文件中。 C-u C-u C-u C-x C-s做两件事:它从以前的内容中进行备份,并在您再次保存时安排从新保存的内容中进行另一个备份。

You can explicitly tell Emacs to make another backup file from a buffer, even though that buffer has been saved before. If you save the buffer with C-u C-x C-s, the version thus saved will be made into a backup file if you save the buffer again. C-u C-u C-x C-s saves the buffer, but first makes the previous file contents into a new backup file. C-u C-u C-u C-x C-s does both things: it makes a backup from the previous contents, and arranges to make another from the newly saved contents if you save again.

您可以自定义该变量backup-directory-alist以指定应将匹配某些模式的文件备份到特定目录中。典型的用途是添加一个元素来制作具有绝对名称dir的目录中的所有备份 。 Emacs 修改备份文件名以避免不同目录中的同名文件之间发生冲突。或者,添加,将在不可见的子目录中进行备份("." . dir)("." . ".~").~原始文件的目录。如果需要,Emacs 会创建目录来进行备份。

You can customize the variable backup-directory-alist to specify that files matching certain patterns should be backed up in specific directories. A typical use is to add an element ("." . dir) to make all backups in the directory with absolute name dir. Emacs modifies the backup file names to avoid clashes between files with the same names originating in different directories. Alternatively, adding, ("." . ".~") would make backups in the invisible subdirectory .~ of the original file’s directory. Emacs creates the directory, if necessary, to make the backup.


19.3.2.1 单个或编号备份

19.3.2.1 Single or Numbered Backups

当 Emacs 制作备份文件时,其名称通常是通过附加 '' 到正在编辑的文件名;因此,备份文件为评估程序将会评估.c~

When Emacs makes a backup file, its name is normally constructed by appending ‘~’ to the file name being edited; thus, the backup file for eval.c would be eval.c~.

如果访问控制阻止 Emacs 以常用名称写入备份文件,则会将备份文件写入为〜/.emacs.d/%backup%〜。此类文件只能存在一个,因此只有最近制作的此类备份可用。

If access control stops Emacs from writing backup files under the usual names, it writes the backup file as ~/.emacs.d/%backup%~. Only one such file can exist, so only the most recently made such backup is available.

Emacs 还可以制作编号备份文件。编号的备份文件名包含 '.~'、数字和另一个 '' 在原始文件名之后。因此,备份文件评估程序会被称为评估.c.~1~,评估.c.~2~等等,一直到像这样的名字评估.c.~259~超越。

Emacs can also make numbered backup files. Numbered backup file names contain ‘.~’, the number, and another ‘~’ after the original file name. Thus, the backup files of eval.c would be called eval.c.~1~, eval.c.~2~, and so on, all the way through names like eval.c.~259~ and beyond.

该变量version-control决定是制作单个备份文件还是多个编号的备份文件。其可能的值为:

The variable version-control determines whether to make single backup files or multiple numbered backup files. Its possible values are:

nil
nil

对已编号备份的文件进行编号备份。否则,进行单个备份。这是默认设置。

Make numbered backups for files that have numbered backups already. Otherwise, make single backups. This is the default.

t
t

进行编号备份。

Make numbered backups.

never
never

切勿进行编号备份;始终进行单个备份。

Never make numbered backups; always make single backups.

设置此变量的常用方法是通过初始化文件或自定义缓冲区进行全局设置。但是,您可以 version-control在单个缓冲区中进行本地设置,以控制该缓冲区文件的备份(请参阅局部变量)。某些模式(例如 Rmail 模式)会设置此变量。version-control每当您访问给定文件时,您还可以在本地设置 Emacs (请参阅文件中的本地变量)。

The usual way to set this variable is globally, through your init file or the customization buffer. However, you can set version-control locally in an individual buffer to control the making of backups for that buffer’s file (see Local Variables). Some modes, such as Rmail mode, set this variable. You can also have Emacs set version-control locally whenever you visit a given file (see Local Variables in Files).

如果您设置环境变量VERSION_CONTROL,以告诉各种 GNU 实用程序如何处理备份文件,Emacs 也会通过version-control 在启动时相应地设置 Lisp 变量来遵守环境变量。如果环境变量的值为 't' 或者 '编号的',则version-control变为t;如果值为 '' 或者 '现存的',则version-control 变为nil;如果是 '绝不' 或者 '简单的',则 version-control变为never

If you set the environment variable VERSION_CONTROL, to tell various GNU utilities what to do with backup files, Emacs also obeys the environment variable by setting the Lisp variable version-control accordingly at startup. If the environment variable’s value is ‘t’ or ‘numbered’, then version-control becomes t; if the value is ‘nil’ or ‘existing’, then version-control becomes nil; if it is ‘never’ or ‘simple’, then version-control becomes never.

如果将该变量设置make-backup-file-name-function为合适的 Lisp 函数,则可以覆盖 Emacs 构造备份文件名的常用方式。

If you set the variable make-backup-file-name-function to a suitable Lisp function, you can override the usual way Emacs constructs backup file names.


19.3.2.2 自动删除备份

19.3.2.2 Automatic Deletion of Backups

为了防止过度消耗磁盘空间,Emacs 可以自动删除编号的备份版本。通常,Emacs 会保留前几个备份和最新的几个备份,并删除中间的任何备份。每次进行新备份时都会发生这种情况。

To prevent excessive consumption of disk space, Emacs can delete numbered backup versions automatically. Generally Emacs keeps the first few backups and the latest few backups, deleting any in between. This happens every time a new backup is made.

kept-old-versions和 两个变量kept-new-versions控制此删除。它们的值分别是每次进行新备份时要保留的最旧(编号最小)备份的数量和要保留的最新(编号最大)备份的数量。中间的备份(不包括最旧和最新的)是多余的中间版本 - 这些备份将被删除。当需要删除多余的版本时,即在创建新的备份版本之后,将使用这些变量的值;新制作的备份包含在 中的计数中kept-new-versions。默认情况下,两个变量均为 2。

The two variables kept-old-versions and kept-new-versions control this deletion. Their values are, respectively, the number of oldest (lowest-numbered) backups to keep and the number of newest (highest-numbered) ones to keep, each time a new backup is made. The backups in the middle (excluding those oldest and newest) are the excess middle versions—those backups are deleted. These variables’ values are used when it is time to delete excess versions, just after a new backup version is made; the newly made backup is included in the count in kept-new-versions. By default, both variables are 2.

如果delete-old-versionst,Emacs 会静默删除多余的备份文件。如果是nil,默认情况下,Emacs 会询问您是否应该删除多余的备份版本。如果它有任何其他值,那么 Emacs 永远不会自动删除备份。

If delete-old-versions is t, Emacs deletes the excess backup files silently. If it is nil, the default, Emacs asks you whether it should delete the excess backup versions. If it has any other value, then Emacs never automatically deletes backups.

Dired 的.(Period)命令也可用于删除旧版本。请参阅同时标记多个文件

Dired’s . (Period) command can also be used to delete old versions. See Flagging Many Files at Once.


19.3.2.3 复制与重命名

19.3.2.3 Copying vs. Renaming

可以通过复制旧文件或重命名它来制作备份文件。当旧文件有多个名称(硬链接)时,这会产生影响。如果旧文件被重命名为备份文件,则备用名称将成为备份文件的名称。如果复制旧文件,则备用名称仍然是您正在编辑的文件的名称,并且通过这些名称访问的内容将是新内容。

Backup files can be made by copying the old file or by renaming it. This makes a difference when the old file has multiple names (hard links). If the old file is renamed into the backup file, then the alternate names become names for the backup file. If the old file is copied instead, then the alternate names remain names for the file that you are editing, and the contents accessed by those names will be the new contents.

制作备份文件的方法也可能会影响文件的所有者和组。如果使用复制,这些不会改变。如果使用重命名,您将成为文件的所有者,并且文件的组将成为默认组(不同的操作系统有不同的默认组)。

The method of making a backup file may also affect the file’s owner and group. If copying is used, these do not change. If renaming is used, you become the file’s owner, and the file’s group becomes the default (different operating systems have different defaults for the group).

重命名或复制的选择如下:

The choice of renaming or copying is made as follows:

  • 如果变量backup-by-copying为非nil(默认为nil),则使用复制。
  • If the variable backup-by-copying is non-nil (the default is nil), use copying.
  • 否则,如果变量backup-by-copying-when-linked为非nil(默认为nil),并且文件有多个名称,则使用复制。
  • Otherwise, if the variable backup-by-copying-when-linked is non-nil (the default is nil), and the file has multiple names, use copying.
  • 否则,如果变量backup-by-copying-when-mismatch为非nil(默认为t),并且重命名会更改文件的所有者或组,请使用复制。

    如果更改backup-by-copying-when-mismatchnil,Emacs 将检查文件所有者的数字用户 ID 和文件组的数字组 ID。如果其中任何一个不大于backup-by-copying-when-privileged-mismatch,那么它的行为就好像backup-by-copying-when-mismatch是非-nil无论如何。

  • Otherwise, if the variable backup-by-copying-when-mismatch is non-nil (the default is t), and renaming would change the file’s owner or group, use copying.

    If you change backup-by-copying-when-mismatch to nil, Emacs checks the numeric user-id of the file’s owner and the numeric group-id of the file’s group. If either is no greater than backup-by-copying-when-privileged-mismatch, then it behaves as though backup-by-copying-when-mismatch is non-nil anyway.

  • 否则,重命名是默认选择。
  • Otherwise, renaming is the default choice.

当使用版本控制系统管理文件时(请参阅版本控制),Emacs 通常不会以通常的方式对该文件进行备份。但是提交(也称为签入,请参阅版本控制概念)文件的新版本在某些方面与制作备份类似。一个不幸的相似之处是,这些操作通常会破坏硬链接,从而断开您访问的文件名与同一文件的任何备用名称的连接。这与 Emacs 无关——是版本控制系统来做的。

When a file is managed with a version control system (see Version Control), Emacs does not normally make backups in the usual way for that file. But committing (a.k.a. checking in, see Concepts of Version Control) new versions of files is similar in some ways to making backups. One unfortunate similarity is that these operations typically break hard links, disconnecting the file name you visited from any alternate names for the same file. This has nothing to do with Emacs—the version control system does it.


19.3.3 自定义文件保存

19.3.3 Customizing Saving of Files

如果变量的值为require-final-newlinet则静默保存或写入文件时会在末尾添加换行符(如果那里还没有换行符)。如果值为visit,Emacs 会在任何没有换行符的文件末尾添加一个换行符,紧接着它访问该文件。 (这将缓冲区标记为已修改,您可以撤消它。)如果值为visit-save,Emacs 在访问和保存时都会添加此类换行符。如果值为nil,Emacs 将保留文件末尾不变;任何其他非nil 值表示 Emacs 询问您是否添加换行符。默认为 nil.

If the value of the variable require-final-newline is t, saving or writing a file silently puts a newline at the end if there isn’t already one there. If the value is visit, Emacs adds a newline at the end of any file that doesn’t have one, just after it visits the file. (This marks the buffer as modified, and you can undo it.) If the value is visit-save, Emacs adds such newlines both on visiting and on saving. If the value is nil, Emacs leaves the end of the file unchanged; any other non-nil value means Emacs asks you whether to add a newline. The default is nil.

一些主要模式是为特定类型的文件设计的,这些文件总是以换行符结尾。这些主要模式将变量设置 require-final-newline为 的值 mode-require-final-newline,默认为t。通过设置后一个变量,您可以控制这些模式如何处理最终换行符。

Some major modes are designed for specific kinds of files that are always supposed to end in newlines. Such major modes set the variable require-final-newline to the value of mode-require-final-newline, which defaults to t. By setting the latter variable, you can control how these modes handle final newlines.

如果此选项为非,nil并且您通过符号链接访问文件,则 Emacs 将在保存缓冲区时中断符号链接,并将缓冲区写入与符号链接同名的文件中,如果file-precious-flag是非nil(请参阅Emacs Lisp 参考手册中的file-precious-flag)。如果您希望 Emacs 在这些情况下将缓冲区保存到符号链接指向的文件(从而保留链接),请将变量自定义 为. file-preserve-symlinks-on-savet

If this option is non-nil and you’re visiting a file via a symbolic link, Emacs will break the symbolic link upon saving the buffer, and will write the buffer to a file with the same name as the symbolic link, if the value of file-precious-flag is non-nil (see file-precious-flag in The Emacs Lisp Reference Manual). If you want Emacs to save the buffer to the file the symbolic link points to (thereby preserving the link) in these cases, customize the variable file-preserve-symlinks-on-save to t.

通常,当程序写入文件时,操作系统会在将数据提交到磁盘之前将文件的数据短暂缓存在主内存中。这样可以大大提高性能;例如,当在笔记本电脑上运行时,它可以避免每次写入文件时磁盘旋转。但是,如果操作系统在将缓存提交到磁盘之前崩溃,则存在数据丢失的风险。

Normally, when a program writes a file, the operating system briefly caches the file’s data in main memory before committing the data to disk. This can greatly improve performance; for example, when running on laptops, it can avoid a disk spin-up each time a file is written. However, it risks data loss if the operating system crashes before committing the cache to disk.

为了降低这种风险,Emacs 可以fsync在保存文件后调用系统调用。使用fsync并不能消除数据丢失的风险,部分原因是许多系统未正确实现 ,部分原因是 Emacs 的文件保存过程通常还依赖于目录更新,即使工作正常, fsync目录更新也可能无法幸存。fsync

To lessen this risk, Emacs can invoke the fsync system call after saving a file. Using fsync does not eliminate the risk of data loss, partly because many systems do not implement fsync properly, and partly because Emacs’s file-saving procedure typically relies also on directory updates that might not survive a crash even if fsync works properly.

write-region-inhibit-fsync变量控制 Emacs 是否fsync在保存文件后调用。该变量的默认值是nil当 Emacs 处于交互式状态并且t Emacs 以批处理模式运行时(请参阅批处理模式)。

The write-region-inhibit-fsync variable controls whether Emacs invokes fsync after saving a file. The variable’s default value is nil when Emacs is interactive, and t when Emacs runs in batch mode (see Batch Mode).

fsyncEmacs在编写自动保存文件时 从不使用,因为这些文件无论如何都可能会丢失数据。

Emacs never uses fsync when writing auto-save files, as these files might lose data anyway.


19.3.4 防止同时编辑

19.3.4 Protection against Simultaneous Editing

当两个用户访问同一个文件,都进行更改,然后都保存它们时,就会发生同时编辑。如果没有人知道发生了这种情况,则无论哪个用户先保存,稍后都会发现他们的更改丢失了。

Simultaneous editing occurs when two users visit the same file, both make changes, and then both save them. If nobody is informed that this is happening, whichever user saves first would later find that their changes were lost.

在某些系统上,当第二个用户开始更改文件时,Emacs 会立即注意到,并立即发出警告。在所有系统上,Emacs 都会在您保存文件时进行检查,并在您要覆盖其他用户的更改时发出警告。您可以通过采取适当的纠正措施而不是保存文件来防止丢失其他用户的工作。

On some systems, Emacs notices immediately when the second user starts to change the file, and issues an immediate warning. On all systems, Emacs checks when you save the file, and warns if you are about to overwrite another user’s changes. You can prevent loss of the other user’s work by taking the proper corrective action instead of saving the file.

当您在访问文件的 Emacs 缓冲区中进行第一次修改时,Emacs 会记录该文件已被您锁定。 (它通过在同一目录中创建一个具有特殊内容的特殊命名的符号链接7来实现这一点。有关更多详细信息,请参阅(elisp)文件锁。)当您保存更改时,Emacs 会删除锁定。这个想法是,只要访问该文件的 Emacs 缓冲区有未保存的更改,该文件就会被锁定。

When you make the first modification in an Emacs buffer that is visiting a file, Emacs records that the file is locked by you. (It does this by creating a specially-named symbolic link7 with special contents in the same directory. See (elisp)File Locks, for more details.) Emacs removes the lock when you save the changes. The idea is that the file is locked whenever an Emacs buffer visiting it has unsaved changes.

create-lockfiles您可以通过将变量设置为 来防止创建锁定文件 nil注意:这样做您将失去此功能提供的好处。您还可以使用该变量控制锁定文件的写入位置 lock-file-name-transforms

You can prevent the creation of lock files by setting the variable create-lockfiles to nil. Caution: by doing so you will lose the benefits that this feature provides. You can also control where lock files are written by using the lock-file-name-transforms variable.

如果您在访问的文件被其他人锁定时开始修改缓冲区,则会构成冲突。当 Emacs 检测到冲突时,它会通过调用 Lisp 函数来询问您要做什么 ask-user-about-lock。您可以重新定义此函数以进行定制。此函数的标准定义会问您一个问题并接受三个可能的答案:

If you begin to modify the buffer while the visited file is locked by someone else, this constitutes a collision. When Emacs detects a collision, it asks you what to do, by calling the Lisp function ask-user-about-lock. You can redefine this function for the sake of customization. The standard definition of this function asks you a question and accepts three possible answers:

s
s

偷锁。已经更改文件的人将失去锁定,而您将获得锁定。

Steal the lock. Whoever was already changing the file loses the lock, and you gain the lock.

p
p

继续。尽管该文件已被其他人锁定,但仍可以继续编辑该文件。

Proceed. Go ahead and edit the file despite its being locked by someone else.

q
q

辞职。这会导致错误 ( file-locked),并且缓冲区内容保持不变 — 您尝试进行的修改实际上并未发生。

Quit. This causes an error (file-locked), and the buffer contents remain unchanged—the modification you were trying to make does not actually take place.

如果 Emacs 或操作系统崩溃,这可能会留下过时的锁定文件,因此您可能偶尔会收到有关虚假冲突的警告。当您确定碰撞是虚假的时,只需p告诉 Emacs 无论如何都要继续。

If Emacs or the operating system crashes, this may leave behind lock files which are stale, so you may occasionally get warnings about spurious collisions. When you determine that the collision is spurious, just use p to tell Emacs to go ahead anyway.

请注意,锁定是基于文件名进行的;如果一个文件有多个名称,Emacs 不会阻止两个用户以不同的名称同时编辑该文件。

Note that locking works on the basis of a file name; if a file has multiple names, Emacs does not prevent two users from editing it simultaneously under different names.

在某些情况下,锁定文件无法写入,例如,如果 Emacs 缺乏系统权限或由于某些其他原因无法创建锁定文件。在这些情况下,当您尝试保存文件时,Emacs 仍然可以通过检查文件的上次修改日期来检测冲突。如果文件自上次 Emacs 访问或保存以来已发生更改,则意味着已通过其他方式进行了更改,并且如果 Emacs 继续保存,这些更改将会丢失。然后,Emacs 会显示一条警告消息,并要求在保存之前进行确认;回答 yes保存,和no/或C-g取消保存。

A lock file cannot be written in some circumstances, e.g., if Emacs lacks the system permissions or cannot create lock files for some other reason. In these cases, Emacs can still detect the collision when you try to save a file, by checking the file’s last-modification date. If the file has changed since the last time Emacs visited or saved it, that implies that changes have been made in some other way, and will be lost if Emacs proceeds with saving. Emacs then displays a warning message and asks for confirmation before saving; answer yes to save, and no or C-g cancel the save.

如果通知您已进行同时编辑,则将缓冲区与其文件进行比较的一种方法是使用命令M-x diff-buffer-with-file。请参阅比较文件

If you are notified that simultaneous editing has already taken place, one way to compare the buffer to its file is the M-x diff-buffer-with-file command. See Comparing Files.

remote-file-name-inhibit-locks您可以通过将变量设置为 来防止创建远程锁定文件t

You can prevent the creation of remote lock files by setting the variable remote-file-name-inhibit-locks to t.

次要模式(以交互方式调用)会切换当前缓冲区中 lock-file-mode的本地值。create-lockfiles

The minor mode lock-file-mode, called interactively, toggles the local value of create-lockfiles in the current buffer.


19.3.5 隐藏文件

19.3.5 Shadowing Files

您可以安排将某些文件的相同卷影副本保留在多个位置(可能在不同的计算机上)。为此,首先必须设置影子文件组,它是在站点列表之间共享的一组同名文件。该文件组是永久性的,适用于以后的 Emacs 会话以及当前的 Emacs 会话。一旦组设置完毕,每次退出 Emacs 时,它都会将您编辑的文件复制到该组中的其他文件中。您还可以在不退出 Emacs 的情况下通过键入 来进行复制。 M-x shadow-copy-files

You can arrange to keep identical shadow copies of certain files in more than one place—possibly on different machines. To do this, first you must set up a shadow file group, which is a set of identically-named files shared between a list of sites. The file group is permanent and applies to further Emacs sessions as well as the current one. Once the group is set up, every time you exit Emacs, it will copy the file you edited to the other files in its group. You can also do the copying without exiting Emacs, by typing M-x shadow-copy-files.

影子集群是一组共享目录的主机,因此向其中一个主机复制或从其中一个主机复制足以更新所有主机上的文件。每个影子集群都有一个名称,并指定主主机(我们将文件复制到的主机)的网络地址,以及与集群中所有其他主机的主机名匹配的正则表达式。您可以使用 定义影子集群。 M-x shadow-define-cluster

A shadow cluster is a group of hosts that share directories, so that copying to or from one of them is sufficient to update the file on all of them. Each shadow cluster has a name, and specifies the network address of a primary host (the one we copy files to), and a regular expression that matches the host names of all the other hosts in the cluster. You can define a shadow cluster with M-x shadow-define-cluster.

M-x shadow-initialize
M-x shadow-initialize

设置文件阴影。

Set up file shadowing.

M-x shadow-define-literal-group
M-x shadow-define-literal-group

声明要在站点之间共享的单个文件。

Declare a single file to be shared between sites.

M-x shadow-define-regexp-group
M-x shadow-define-regexp-group

使与一组文件中的每一个文件匹配的所有文件在主机之间共享。

Make all files that match each of a group of files be shared between hosts.

M-x shadow-define-cluster RET name RET
M-x shadow-define-cluster RET name RET

定义影子文件簇名称

Define a shadow file cluster name.

M-x shadow-copy-files
M-x shadow-copy-files

复制所有挂起的影子文件。

Copy all pending shadow files.

M-x shadow-cancel
M-x shadow-cancel

取消隐藏某些文件的指令。

Cancel the instruction to shadow some files.

要设置影子文件组,请使用或。请参阅他们的文档字符串以获取更多信息。 M-x shadow-define-literal-groupM-x shadow-define-regexp-group

To set up a shadow file group, use M-x shadow-define-literal-group or M-x shadow-define-regexp-group. See their documentation strings for further information.

在将文件复制到其影子之前,Emacs 会要求确认。这次您可以回答“否”以绕过此文件的复制。如果要永久取消某个文件的影子,请使用 消除或更改影子文件组。 M-x shadow-cancel

Before copying a file to its shadows, Emacs asks for confirmation. You can answer “no” to bypass copying of this file, this time. If you want to cancel the shadowing permanently for a certain file, use M-x shadow-cancel to eliminate or change the shadow file group.

文件隐藏在 MS Windows 上不可用。

File Shadowing is not available on MS Windows.


19.3.6 自动更新时间戳

19.3.6 Updating Time Stamps Automatically

您可以安排在文件中添加时间戳,以便每次编辑和保存文件时时间戳都会自动更新。时间戳必须位于文件的前八行,您应该像这样插入它:

You can arrange to put a time stamp in a file, so that it is updated automatically each time you edit and save the file. The time stamp must be in the first eight lines of the file, and you should insert it like this:

时间戳:<>
Time-stamp: <>

或者像这样:

or like this:

时间戳:“”
Time-stamp: " "

然后将该函数添加time-stamp到挂钩 before-save-hook(请参阅Hooks)。当您保存文件时,此功能会自动用当前日期和时间更新时间戳。您也可以使用该命令M-x time-stamp手动更新时间戳。默认情况下,时间戳的格式根据您的区域设置(请参阅环境变量)和时区(请参阅《Emacs Lisp 参考手册》中的“时间”)。有关自定义,请参阅自定义组。 time-stamp

Then add the function time-stamp to the hook before-save-hook (see Hooks). When you save the file, this function then automatically updates the time stamp with the current date and time. You can also use the command M-x time-stamp to update the time stamp manually. By default the time stamp is formatted according to your locale setting (see Environment Variables) and time zone (see Time of Day in The Emacs Lisp Reference Manual). For customizations, see the Custom group time-stamp.


19.4 恢复缓冲区

19.4 Reverting a Buffer

如果您对文件访问缓冲区进行了大量更改,然后又改变了主意,则可以恢复更改并返回到文件的保存版本。为此,请键入C-x x g.由于无意中恢复可能会丢失大量工作,因此如果缓冲区被修改,Emacs 会首先要求确认。

If you have made extensive changes to a file-visiting buffer and then change your mind, you can revert the changes and go back to the saved version of the file. To do this, type C-x x g. Since reverting unintentionally could lose a lot of work, Emacs asks for confirmation first if the buffer is modified.

revert-buffer命令尝试以这样的方式定位点:如果仅对文件进行了轻微编辑,您将处于与以前大致相同的文本部分。但如果您进行了重大更改,点可能会出现在完全不同的位置。

The revert-buffer command tries to position point in such a way that, if the file was edited only slightly, you will be at approximately the same part of the text as before. But if you have made major changes, point may end up in a totally different location.

恢复将缓冲区标记为未修改。但是,它将恢复的更改作为单个修改添加到缓冲区的撤消历史记录中(请参阅撤消)。因此,在恢复后,如果您碰巧改变主意,可以键入C-/或其别名来恢复恢复的更改。

Reverting marks the buffer as not modified. However, it adds the reverted changes as a single modification to the buffer’s undo history (see Undo). Thus, after reverting, you can type C-/ or its aliases to bring the reverted changes back, if you happen to change your mind.

要更保守地恢复缓冲区,可以使用命令 revert-buffer-with-fine-grain。该命令的作用类似于 revert-buffer,但它尝试尽可能非破坏性,努力保留缓冲区中的所有标记、属性和覆盖。由于当您进行大量更改时,以这种方式恢复可能会非常慢,因此您可以修改该变量revert-buffer-with-fine-grain-max-seconds以指定以这种方式替换缓冲区内容所需的最大秒数。请注意,不能确保整个执行时间revert-buffer-with-fine-grain不会超过此时间。

To revert a buffer more conservatively, you can use the command revert-buffer-with-fine-grain. This command acts like revert-buffer, but it tries to be as non-destructive as possible, making an effort to preserve all markers, properties and overlays in the buffer. Since reverting this way can be very slow when you have made a large number of changes, you can modify the variable revert-buffer-with-fine-grain-max-seconds to specify a maximum amount of seconds that replacing the buffer contents this way should take. Note that it is not ensured that the whole execution of revert-buffer-with-fine-grain won’t take longer than this.

某些与文件无关的缓冲区(例如 Dired 缓冲区)也可以恢复。对他们来说,恢复意味着重新计算其内容。显式创建的缓冲区 C-x b无法恢复;revert-buffer如果您尝试,则会报告错误。

Some kinds of buffers that are not associated with files, such as Dired buffers, can also be reverted. For them, reverting means recalculating their contents. Buffers created explicitly with C-x b cannot be reverted; revert-buffer reports an error if you try.

当您编辑自动且频繁更改的文件时(例如,持续运行的进程的输出日志),Emacs 无需询问您即可恢复该文件可能会很有用。要请求此行为,请将变量设置revert-without-query为正则表达式列表。当文件名与这些正则表达式之一匹配时,如果文件名已更改,find-file则将revert-buffer自动恢复它 - 前提是缓冲区本身未修改。 (如果您编辑了文本,则放弃所做的更改是错误的。)

When you edit a file that changes automatically and frequently—for example, a log of output from a process that continues to run—it may be useful for Emacs to revert the file without querying you. To request this behavior, set the variable revert-without-query to a list of regular expressions. When a file name matches one of these regular expressions, find-file and revert-buffer will revert it automatically if it has changed—provided the buffer itself is not modified. (If you have edited the text, it would be wrong to discard your changes.)

击键C-x x g与命令绑定 revert-buffer-quick。这类似于 revert-buffer命令,但提示较少。与 不同的是 revert-buffer,它不会提示当前缓冲区是否访问文件,并且缓冲区没有被修改。它还尊重 revert-buffer-quick-short-answers用户的选择。如果此选项为非nil,则使用较短的y/n查询而不是较长的 yes/no查询。

The C-x x g keystroke is bound to the revert-buffer-quick command. This is like the revert-buffer command, but prompts less. Unlike revert-buffer, it will not prompt if the current buffer visits a file, and the buffer is not modified. It also respects the revert-buffer-quick-short-answers user option. If this option is non-nil, use a shorter y/n query instead of a longer yes/no query.

您还可以告诉 Emacs 当其访问的文件在磁盘上发生更改时自动恢复缓冲区;请参阅自动恢复:自动保持缓冲区最新

You can also tell Emacs to revert buffers automatically when their visited files change on disk; see Auto Revert: Keeping buffers automatically up-to-date.


19.5 自动恢复:自动保持缓冲区最新

19.5 Auto Revert: Keeping buffers automatically up-to-date

如果该文件被另一个程序更改,则缓冲区可能会与磁盘上其访问的文件不同步。要使其保持最新,您可以通过键入 来启用自动恢复模式M-x auto-revert-mode。当磁盘上访问的文件发生更改时,这会自动恢复缓冲区。要对所有文件缓冲区执行相同的操作,请键入 M-x global-auto-revert-mode以启用全局自动恢复模式。

A buffer can get out of sync with respect to its visited file on disk if that file is changed by another program. To keep it up to date, you can enable Auto Revert mode by typing M-x auto-revert-mode. This automatically reverts the buffer when its visited file changes on disk. To do the same for all file buffers, type M-x global-auto-revert-mode to enable Global Auto Revert mode.

如果缓冲区有未保存的更改,或者磁盘上的文件被删除或重命名,“自动恢复”将不会恢复缓冲区。

Auto Revert will not revert a buffer if it has unsaved changes, or if its file on disk is deleted or renamed.

自动恢复模式的一种用途是“拖尾”文件(例如系统日志),以便连续显示其他程序对该文件所做的更改。为此,只需将点移动到缓冲区的末尾,当文件内容发生变化时它将保留在那里。但是,如果您确定文件只会在最后增长而更改,请改用“自动恢复尾部”模式 ( auto-revert-tail-mode)。这样做效率更高。自动恢复尾部模式也适用于远程文件。

One use of Auto Revert mode is to “tail” a file such as a system log, so that changes made to that file by other programs are continuously displayed. To do this, just move the point to the end of the buffer, and it will stay there as the file contents change. However, if you are sure that the file will only change by growing at the end, use Auto Revert Tail mode instead (auto-revert-tail-mode). It is more efficient for this. Auto Revert Tail mode also works for remote files.

当缓冲区自动恢复时,会生成一条消息。这可以通过设置auto-revert-verbose为来抑制nil

When a buffer is auto-reverted, a message is generated. This can be suppressed by setting auto-revert-verbose to nil.

自动恢复模式不会检查或恢复远程文件,因为这通常太慢。可以通过将变量设置auto-revert-remote-files为非来更改此行为nil

The Auto Revert modes do not check or revert remote files, because that is usually too slow. This behavior can be changed by setting the variable auto-revert-remote-files to non-nil.

默认情况下,自动恢复模式使用文件通知来工作,文件系统中的更改由操作系统报告给 Emacs。您可以通过将变量自定义 auto-revert-use-notify为一个nil值来禁用文件通知,然后 Emacs 将通过每五秒轮询一次来检查文件更改。您可以通过变量更改轮询间隔auto-revert-interval

By default, Auto Revert mode works using file notifications, whereby changes in the filesystem are reported to Emacs by the OS. You can disable use of file notifications by customizing the variable auto-revert-use-notify to a nil value, then Emacs will check for file changes by polling every five seconds. You can change the polling interval through the variable auto-revert-interval.

并非所有系统都支持文件通知;如果不支持,auto-revert-use-notifynil默认为支持。

Not all systems support file notifications; where they are not supported, auto-revert-use-notify will be nil by default.

默认情况下,即使使用文件通知,自动恢复模式也会定期轮询文件是否发生更改。在许多情况下轮询是不必要的,关闭轮询可能仅依靠通知来节省电量。为此,请将变量设置 auto-revert-avoid-polling为非nil。然而,通知在某些文件系统上无效;主要是类 Unix 机器上的网络文件系统,可以从其他机器上更改文件。对于这样的文件系统,轮询可能是必要的。要在auto-revert-avoid-polling非时强制轮询 nil,请设置 auto-revert-notify-exclude-dir-regexp为匹配应从使用通知中排除的文件。

By default, Auto Revert mode will poll files for changes periodically even when file notifications are used. Polling is unnecessary in many cases, and turning it off may save power by relying on notifications only. To do so, set the variable auto-revert-avoid-polling to non-nil. However, notification is ineffective on certain file systems; mainly network file system on Unix-like machines, where files can be altered from other machines. For such file systems, polling may be necessary. To force polling when auto-revert-avoid-polling is non-nil, set auto-revert-notify-exclude-dir-regexp to match files that should be excluded from using notification.

在 Dired 缓冲区(请参阅Dired,目录编辑器)中,当在缓冲区目录中创建或删除文件时,自动恢复模式会刷新缓冲区。

In Dired buffers (see Dired, the Directory Editor), Auto Revert mode refreshes the buffer when a file is created or deleted in the buffer’s directory.

请参阅撤消版本控制操作,了解在版本控制下恢复到文件早期版本的命令。请参阅版本控制和模式行,了解访问版本控制下的文件时的自动恢复特性。

See Undoing Version Control Actions, for commands to revert to earlier versions of files under version control. See Version Control and the Mode Line, for Auto Revert peculiarities when visiting files under version control.


19.5.1 自动恢复非文件缓冲区

19.5.1 Auto Reverting Non-File Buffers

全局自动恢复模式通常仅恢复文件缓冲区。有两种方法可以自动恢复某些非文件缓冲区: 在这些缓冲区中启用自动恢复模式(使用M-x auto-revert-mode);并设置global-auto-revert-non-file-buffers为非值nil。后者为实现它的所有类型的缓冲区启用自动恢复(在下面的菜单中列出)。

Global Auto Revert Mode normally only reverts file buffers. There are two ways to auto-revert certain non-file buffers: by enabling Auto Revert Mode in those buffers (using M-x auto-revert-mode); and by setting global-auto-revert-non-file-buffers to a non-nil value. The latter enables Auto Reverting for all types of buffers for which it is implemented (listed in the menu below).

与文件缓冲区一样,非文件缓冲区通常不应在您处理它们时或它们包含恢复后可能丢失的信息时恢复。因此,如果它们被修改,它们不会恢复。这可能会很棘手,因为决定何时应将非文件缓冲区标记为已修改通常比文件缓冲区更困难。

Like file buffers, non-file buffers should normally not revert while you are working on them, or while they contain information that might get lost after reverting. Therefore, they do not revert if they are modified. This can get tricky, because deciding when a non-file buffer should be marked modified is usually more difficult than for file buffers.

另一个棘手的细节是,出于效率原因,自动恢复通常不会尝试检测缓冲区中所有可能的更改,而只会检测主要或易于检测的更改。因此,启用非文件缓冲区的自动恢复并不总是保证缓冲区中的所有信息都是最新的,并且不一定使手动恢复变得无用。

Another tricky detail is that, for efficiency reasons, Auto Revert often does not try to detect all possible changes in the buffer, only changes that are major or easy to detect. Hence, enabling auto-reverting for a non-file buffer does not always guarantee that all information in the buffer is up-to-date, and does not necessarily make manual reverts useless.

在另一个极端,某些缓冲区每秒自动恢复 auto-revert-interval。 (这当前仅适用于缓冲区菜单。)在这种情况下,自动恢复在恢复时不会打印任何消息,即使auto-revert-verbose是非nil

At the other extreme, certain buffers automatically revert every auto-revert-interval seconds. (This currently only applies to the Buffer Menu.) In this case, Auto Revert does not print any messages while reverting, even when auto-revert-verbose is non-nil.

一些非文件缓冲区可以通过其默认目录上的文件通知可靠地更新; Dired 缓冲区就是一个例子。主模式可以通过在该缓冲区中设置buffer-auto-revert-by-notification 为非nil值来指示这一点,从而允许自动恢复以避免定期轮询。此类通知不包括对该目录中的文件的更改,仅包括对该目录本身的更改。

Some non-file buffers can be updated reliably by file notification on their default directory; Dired buffers is an example. The major mode can indicate this by setting buffer-auto-revert-by-notification to a non-nil value in that buffer, allowing Auto Revert to avoid periodic polling. Such notification does not include changes to files in that directory, only to the directory itself.

详细信息取决于缓冲区的特定类型,并在相应部分中进行了解释。

The details depend on the particular types of buffers and are explained in the corresponding sections.


19.5.1.1 自动恢复缓冲区菜单

19.5.1.1 Auto Reverting the Buffer Menu

如果启用了非文件缓冲区的自动恢复,则缓冲区菜单(请参阅对多个缓冲区进行操作)每秒都会自动恢复 auto-revert-interval,无论是否需要。 (检查是否需要比实际恢复可能需要更长的时间。)

If auto-reverting of non-file buffers is enabled, the Buffer Menu (see Operating on Several Buffers) automatically reverts every auto-revert-interval seconds, whether there is a need for it or not. (It would probably take longer to check whether there is a need than to actually revert.)

如果缓冲区菜单被不恰当地标记为修改,只需使用手动恢复它g,自动恢复就会恢复。但是,如果您将某些缓冲区标记为要删除或要显示,则必须小心,因为恢复会删除所有标记。添加标记会设置缓冲区的修改标志,这一事实会阻止“自动恢复”自动删除标记。

If the Buffer Menu inappropriately gets marked modified, just revert it manually using g and auto-reverting will resume. However, if you marked certain buffers to get deleted or to be displayed, you have to be careful, because reverting erases all marks. The fact that adding marks sets the buffer’s modified flag prevents Auto Revert from automatically erasing the marks.


19.5.1.2 自动恢复 Dired 缓冲区

19.5.1.2 Auto Reverting Dired buffers

Dired 缓冲区仅在缓冲区主目录的文件列表更改时(例如,添加或删除新文件时)自动恢复。当有关特定文件的信息发生变化(例如,当大小发生变化时)或插入的子目录发生变化时,它们不会自动恢复。为了确保所有列出的信息都是最新的,即使在 Dired 缓冲区中启用了自动恢复g,您也必须使用 手动恢复。有时,您可能会觉得修改或保存主目录中列出的文件实际上确实会导致自动恢复。这是因为对文件进行更改或保存文件通常会导致目录本身发生更改;例如,通过备份文件或自动保存文件。然而,这并不能得到保证。

Dired buffers only auto-revert when the file list of the buffer’s main directory changes (e.g., when a new file is added or deleted). They do not auto-revert when information about a particular file changes (e.g., when the size changes) or when inserted subdirectories change. To be sure that all listed information is up to date, you have to manually revert using g, even if auto-reverting is enabled in the Dired buffer. Sometimes, you might get the impression that modifying or saving files listed in the main directory actually does cause auto-reverting. This is because making changes to a file, or saving it, very often causes changes in the directory itself; for instance, through backup files or auto-save files. However, this is not guaranteed.

如果 Dired 缓冲区被标记为已修改并且没有您想要保护的更改,那么大多数时候您可以通过使用 手动恢复缓冲区来恢复自动恢复g。有一个例外。如果您标记或标记文件,则可以安全地恢复缓冲区。这不会删除标志或标记(当然,除非标记的文件已被删除)。但是,即使在恢复之后,缓冲区仍将保持修改状态,并且自动恢复将不会恢复。这是因为,如果您标记或标记文件,您可能正在处理缓冲区,并且您可能不希望缓冲区在没有警告的情况下发生更改。如果您希望在存在标记和标志的情况下恢复自动恢复,请使用 标记缓冲区未修改M-~。但是,添加、删除或更改标记或标志将再次标记其已修改。

If the Dired buffer is marked modified and there are no changes you want to protect, then most of the time you can make auto-reverting resume by manually reverting the buffer using g. There is one exception. If you flag or mark files, you can safely revert the buffer. This will not erase the flags or marks (unless the marked file has been deleted, of course). However, the buffer will stay modified, even after reverting, and auto-reverting will not resume. This is because, if you flag or mark files, you may be working on the buffer and you might not want the buffer to change without warning. If you want auto-reverting to resume in the presence of marks and flags, mark the buffer non-modified using M-~. However, adding, deleting or changing marks or flags will mark it modified again.

远程 Dired 缓冲区当前无法自动恢复。您使用 shell 通配符或文件参数仅列出部分文件的 Dired 缓冲区也不是。 *寻找**定位* 缓冲区也不会自动恢复。

Remote Dired buffers are currently not auto-reverted. Neither are Dired buffers for which you used shell wildcards or file arguments to list only some of the files. *Find* and *Locate* buffers do not auto-revert either.

请注意,自动恢复 Dired 缓冲区在某些系统上可能无法令人满意地工作。

Note that auto-reverting Dired buffers may not work satisfactorily on some systems.


19.6 自动保存:防灾

19.6 Auto-Saving: Protection Against Disasters

有时,Emacs 会自动将每个访问过的文件保存在单独的文件中,而不更改您实际使用的文件。这称为自动保存。如果系统崩溃,它可以防止您丢失超过有限数量的工作。

From time to time, Emacs automatically saves each visited file in a separate file, without altering the file you actually use. This is called auto-saving. It prevents you from losing more than a limited amount of work if the system crashes.

当 Emacs 确定到了自动保存的时间时,它会考虑每个缓冲区,如果启用了自动保存并且自上次自动保存以来它已被更改,则每个缓冲区都会自动保存。当auto-save-no-message变量设置为nil(默认)时,消息 '自动保存...如果确实有文件被自动保存,则自动保存时回显区域会显示 ';要禁用这些消息,请将变量自定义为非值nil 。自动保存期间发生的错误会被捕获,这样它们就不会干扰您正在输入的命令的执行。

When Emacs determines that it is time for auto-saving, it considers each buffer, and each is auto-saved if auto-saving is enabled for it and it has been changed since the last time it was auto-saved. When the auto-save-no-message variable is set to nil (the default), the message ‘Auto-saving...’ is displayed in the echo area during auto-saving, if any files are actually auto-saved; to disable these messages, customize the variable to a non-nil value. Errors occurring during auto-saving are caught so that they do not interfere with the execution of commands you have been typing.


19.6.1 自动保存文件

19.6.1 Auto-Save Files

自动保存通常不会保存在您访问过的文件中,因为保存您不想永久保存的更改可能是非常不希望的。相反,自动保存是在称为自动保存文件的不同文件中完成的,并且仅当您明确请求保存时(例如 with C-x C-s),访问的文件才会更改。

Auto-saving does not normally save in the files that you visited, because it can be very undesirable to save a change that you did not want to make permanent. Instead, auto-saving is done in a different file called the auto-save file, and the visited file is changed only when you request saving explicitly (such as with C-x C-s).

通常,自动保存文件名是通过附加 '#' 到访问的文件名的前面和后面。因此,缓冲区访问文件 foo.c自动保存在文件中#foo.c#。大多数不访问文件的缓冲区只有在您明确请求时才会自动保存;当它们自动保存时,自动保存文件名是通过附加 '#' 添加到缓冲区名称的前面和后面,然后在末尾添加数字和字母以确保唯一性。例如,*邮件*您在其中编写要发送的消息的缓冲区可能会自动保存在名为的文件中#*邮件*#704juu。自动保存文件名就是以这种方式生成的,除非您重新编程 Emacs 的某些部分以执行不同的操作(函数make-auto-save-file-nameauto-save-file-name-p)。当在该缓冲区中打开自动保存时,将计算用于在缓冲区中自动保存的文件名。

Normally, the auto-save file name is made by appending ‘#’ to the front and rear of the visited file name. Thus, a buffer visiting file foo.c is auto-saved in a file #foo.c#. Most buffers that are not visiting files are auto-saved only if you request it explicitly; when they are auto-saved, the auto-save file name is made by appending ‘#’ to the front and rear of buffer name, then adding digits and letters at the end for uniqueness. For example, the *mail* buffer in which you compose messages to be sent might be auto-saved in a file named #*mail*#704juu. Auto-save file names are made this way unless you reprogram parts of Emacs to do something different (the functions make-auto-save-file-name and auto-save-file-name-p). The file name to be used for auto-saving in a buffer is calculated when auto-saving is turned on in that buffer.

该变量auto-save-file-name-transforms允许对自动保存文件名进行一定程度的控制。它允许您指定一系列正则表达式和替换来转换自动保存文件名。默认值将远程文件的自动保存文件(请参阅远程文件)放入本地计算机上的临时文件目录中。

The variable auto-save-file-name-transforms allows a degree of control over the auto-save file name. It lets you specify a series of regular expressions and replacements to transform the auto save file name. The default value puts the auto-save files for remote files (see Remote Files) into the temporary file directory on the local machine.

当您删除大缓冲区中的大部分文本时,该缓冲区中的自动保存功能会暂时关闭。这是因为,如果您无意中删除了文本,您可能会发现自动保存文件包含已删除的文本会更有用。要在发生这种情况后重新启用自动保存,请使用 保存缓冲区C-x C-s,或使用C-u 1 M-x auto-save-mode

When you delete a substantial part of the text in a large buffer, auto save turns off temporarily in that buffer. This is because if you deleted the text unintentionally, you might find the auto-save file more useful if it contains the deleted text. To reenable auto-saving after this happens, save the buffer with C-x C-s, or use C-u 1 M-x auto-save-mode.

如果您希望在访问的文件中而不是在单独的自动保存文件中完成自动保存,请启用全局次要模式 auto-save-visited-mode。在此模式下,自动保存与显式保存相同。注意,该模式与auto-save上述模式正交 ;您可以同时启用两者。但是,如果auto-save某些缓冲区中的模式处于活动状态并且过时的auto-save-visited-file-name变量设置为非值nil,则该缓冲区将不会受到 的影响 auto-save-visited-mode

If you want auto-saving to be done in the visited file rather than in a separate auto-save file, enable the global minor mode auto-save-visited-mode. In this mode, auto-saving is identical to explicit saving. Note that this mode is orthogonal to the auto-save mode described above; you can enable both at the same time. However, if auto-save mode is active in some buffer and the obsolete auto-save-visited-file-name variable is set to a non-nil value, that buffer won’t be affected by auto-save-visited-mode.

您可以使用该变量auto-save-visited-interval来自定义自动保存操作之间的间隔 auto-save-visited-mode;默认为五秒。 auto-save-interval并且auto-save-timeout对 没有影响auto-save-visited-mode。有关这些变量的详细信息, 请参阅控制自动保存。

You can use the variable auto-save-visited-interval to customize the interval between auto-save operations in auto-save-visited-mode; by default it’s five seconds. auto-save-interval and auto-save-timeout have no effect on auto-save-visited-mode. See Controlling Auto-Saving, for details on these variables.

当您将缓冲区保存在其访问的文件中时,缓冲区的自动保存文件将被删除。 (您可以通过将变量设置 delete-auto-save-files为 来禁止这种情况nil。)使用 更改访问的文件名C-x C-wset-visited-file-name重命名任何自动保存文件以使用新的访问名称。

A buffer’s auto-save file is deleted when you save the buffer in its visited file. (You can inhibit this by setting the variable delete-auto-save-files to nil.) Changing the visited file name with C-x C-w or set-visited-file-name renames any auto-save file to go with the new visited name.

默认情况下,终止缓冲区不会删除缓冲区的自动保存文件。如果kill-buffer-delete-auto-save-files为非nil,则杀死具有自动保存文件的缓冲区将使 Emacs 提示用户是否应删除自动保存文件。 (如果delete-auto-save-files是,则会被禁止nil。)

Killing a buffer, by default, doesn’t remove the buffer’s auto-save file. If kill-buffer-delete-auto-save-files is non-nil, killing a buffer that has an auto-save file will make Emacs prompt the user for whether the auto-save file should be deleted. (This is inhibited if delete-auto-save-files is nil.)


19.6.2 控制自动保存

19.6.2 Controlling Auto-Saving

auto-save-default每次访问文件时,如果变量为非nil(但不在批处理模式下;请参阅初始选项),则会为该文件的缓冲区打开自动保存。该变量的默认值为t,因此自动保存是文件访问缓冲区的常见做法。要在当前缓冲区中切换自动保存,请键入M-x auto-save-mode。自动保存模式充当缓冲区本地次要模式(请参阅次要模式)。

Each time you visit a file, auto-saving is turned on for that file’s buffer if the variable auto-save-default is non-nil (but not in batch mode; see Initial Options). The default for this variable is t, so auto-saving is the usual practice for file-visiting buffers. To toggle auto-saving in the current buffer, type M-x auto-save-mode. Auto Save mode acts as a buffer-local minor mode (see Minor Modes).

Emacs 会根据自上次自动保存以来您输入的字符数定期自动保存。该变量 auto-save-interval指定自动保存之间有多少个字符。默认情况下,它是 300。Emacs 不接受太小的值:如果您自定义auto-save-interval 一个小于 20 的值,Emacs 的行为就像该值是 20 一样。

Emacs auto-saves periodically based on how many characters you have typed since the last auto-save. The variable auto-save-interval specifies how many characters there are between auto-saves. By default, it is 300. Emacs doesn’t accept values that are too small: if you customize auto-save-interval to a value less than 20, Emacs will behave as if the value is 20.

当您停止打字一段时间时,也会自动保存。默认情况下,它会在空闲 30 秒后执行此操作(此时,Emacs 也可能执行垃圾收集;请参阅《Emacs Lisp 参考手册》中的垃圾收集)。要更改此间隔,请自定义变量。如果当前缓冲区较长,则实际时间周期较长;这是一种启发式方法,旨在在您编辑长缓冲区时避免妨碍您,因为自动保存会花费相当长的时间。空闲期间自动保存可以完成两件事:首先,如果您离开终端一段时间,它可以确保保存您的所有工作;其次,它可以避免在您实际打字时进行一些自动保存。 auto-save-timeout

Auto-saving also takes place when you stop typing for a while. By default, it does this after 30 seconds of idleness (at this time, Emacs may also perform garbage collection; see Garbage Collection in The Emacs Lisp Reference Manual). To change this interval, customize the variable auto-save-timeout. The actual time period is longer if the current buffer is long; this is a heuristic which aims to keep out of your way when you are editing long buffers, in which auto-save takes an appreciable amount of time. Auto-saving during idle periods accomplishes two things: first, it makes sure all your work is saved if you go away from the terminal for a while; second, it may avoid some auto-saving while you are actually typing.

启用后auto-save-visited-mode,Emacs 将在五秒空闲时间后自动保存文件访问缓冲区。您可以自定义变量auto-save-visited-interval来更改空闲时间间隔。

When auto-save-visited-mode is enabled, Emacs will auto-save file-visiting buffers after five seconds of idle time. You can customize the variable auto-save-visited-interval to change the idle time interval.

当 Emacs 遇到致命错误时,它也会自动保存。这包括使用 shell 命令终止 Emacs 作业,例如 '杀掉%emacs',或断开电话线或网络连接。

Emacs also does auto-saving whenever it gets a fatal error. This includes killing the Emacs job with a shell command such as ‘kill %emacs’, or disconnecting a phone line or network connection.

您可以使用命令显式执行自动保存M-x do-auto-save

You can perform an auto-save explicitly with the command M-x do-auto-save.


19.6.3 从自动保存中恢复数据

19.6.3 Recovering Data from Auto-Saves

您可以使用自动保存文件的内容通过命令从丢失的数据中恢复。这将访问文件,然后(在您确认后)从其自动保存文件中恢复内容M-x recover-file RET file RET文件。然后,您可以保存以C-x C-s将恢复的文本放入 文件本身。例如,要恢复文件foo.c从它的自动保存文件#foo.c#, 做:

You can use the contents of an auto-save file to recover from a loss of data with the command M-x recover-file RET file RET. This visits file and then (after your confirmation) restores the contents from its auto-save file #file#. You can then save with C-x C-s to put the recovered text into file itself. For example, to recover file foo.c from its auto-save file #foo.c#, do:

Mx 恢复文件RETfoo.cRETRET
铯Cx
M-x recover-file RET foo.c RET
yes RET
C-x C-s

在要求确认之前,M-x recover-file显示描述指定文件和自动保存文件的目录列表,以便您可以比较它们的大小和日期。如果自动保存文件较旧,M-x recover-file则不提供读取它。

Before asking for confirmation, M-x recover-file displays a directory listing describing the specified file and the auto-save file, so you can compare their sizes and dates. If the auto-save file is older, M-x recover-file does not offer to read it.

如果 Emacs 或计算机崩溃,您可以使用命令从自动保存文件中恢复您正在编辑的所有文件M-x recover-session。这首先向您显示记录的中断会话的列表。将光标移至您选择的位置,然后键入C-c C-c

If Emacs or the computer crashes, you can recover all the files you were editing from their auto save files with the command M-x recover-session. This first shows you a list of recorded interrupted sessions. Move point to the one you choose, and type C-c C-c.

然后recover-session询问该会话期间正在编辑的每个文件,询问是否恢复该文件。如果您接听y,它就会呼叫recover-file,这按正常方式工作。它显示原始文件及其自动保存文件的日期,并再次询问是否恢复该文件。

Then recover-session asks about each of the files that were being edited during that session, asking whether to recover that file. If you answer y, it calls recover-file, which works in its normal fashion. It shows the dates of the original file and its auto-save file, and asks once again whether to recover that file.

完成后recover-session,您选择恢复的文件将出现在 Emacs 缓冲区中。然后你应该保存它们。只有这样——保存它们——才能更新文件本身。

When recover-session is done, the files you’ve chosen to recover are present in Emacs buffers. You should then save them. Only this—saving them—updates the files themselves.

Emacs 在名为的文件中记录有关中断会话的信息 .saves- pid -主机名~在目录中 〜/.emacs.d/自动保存列表/。该目录由变量确定auto-save-list-file-prefix。如果设置 auto-save-list-file-prefixnil,则不会记录会话以进行恢复。

Emacs records information about interrupted sessions in files named .saves-pid-hostname~ in the directory ~/.emacs.d/auto-save-list/. This directory is determined by the variable auto-save-list-file-prefix. If you set auto-save-list-file-prefix to nil, sessions are not recorded for recovery.


19.7 文件名别名

19.7 File Name Aliases

符号链接和硬链接都使得多个文件名可以引用同一个文件。硬链接是直接引用文件的备用名称;所有名字都同等有效,没有一个是优先的。相比之下,符号链接是一种定义的别名:是一个符号链接酒吧,您可以使用任一名称来引用该文件,但是酒吧是真实姓名,而 只是一个别名。当符号链接指向目录时,会出现更复杂的情况。

Symbolic links and hard links both make it possible for several file names to refer to the same file. Hard links are alternate names that refer directly to the file; all the names are equally valid, and no one of them is preferred. By contrast, a symbolic link is a kind of defined alias: when foo is a symbolic link to bar, you can use either name to refer to the file, but bar is the real name, while foo is just an alias. More complex cases occur when symbolic links point to directories.

通常,如果您访问 Emacs 已经以不同名称访问的文件,Emacs 会在回显区域中显示一条消息,并使用访问该文件的现有缓冲区。在支持硬链接或符号链接的系统上,或者在截断长文件名的系统上或在不区分大小写的文件系统上使用长文件名时,可能会发生这种情况。您可以通过将变量设置 find-file-suppress-same-file-warnings为非值来抑制该消息nil 。您可以通过将变量设置 find-file-existing-other-name为 来完全禁用此功能nil:然后,如果您以两个不同的名称访问同一文件,则每个文件名都会获得一个单独的缓冲区。

Normally, if you visit a file which Emacs is already visiting under a different name, Emacs displays a message in the echo area and uses the existing buffer visiting that file. This can happen on systems that support hard or symbolic links, or if you use a long file name on a system that truncates long file names, or on a case-insensitive file system. You can suppress the message by setting the variable find-file-suppress-same-file-warnings to a non-nil value. You can disable this feature entirely by setting the variable find-file-existing-other-name to nil: then if you visit the same file under two different names, you get a separate buffer for each file name.

如果变量find-file-visit-truename为 non- nil,则为缓冲区记录的文件名是文件的真实名称 (通过将所有符号链接替换为其目标名称而生成),而不是您指定的名称。设置find-file-visit-truename也意味着 的效果find-file-existing-other-name

If the variable find-file-visit-truename is non-nil, then the file name recorded for a buffer is the file’s truename (made by replacing all symbolic links with their target names), rather than the name you specify. Setting find-file-visit-truename also implies the effect of find-file-existing-other-name.

有时,目录通常是通过符号链接访问的,您可能希望 Emacs 优先显示其链接名称。为此,请自定义directory-abbrev-alist.此列表中的每个元素都应采用 形式,这意味着只要 目录名称中出现from ,就将from替换为to 。 from字符串是正则表达式(请参阅正则表达式语法)。它与锚定在第一个字符的目录名称相匹配,并且应以 ' 开头(from . to)\`' (支持带有嵌入换行符的目录名称,这会击败 '^')。to字符串应该是指向同一目录的普通绝对目录名称。不使用 '' 代表 to 字符串中的主目录; Emacs 单独执行这些替换。这是一个来自系统的示例/home/fsf通常通过名为的符号链接访问/fsf:

Sometimes, a directory is ordinarily accessed through a symbolic link, and you may want Emacs to preferentially show its linked name. To do this, customize directory-abbrev-alist. Each element in this list should have the form (from . to), which means to replace from with to whenever from appears in a directory name. The from string is a regular expression (see Syntax of Regular Expressions). It is matched against directory names anchored at the first character, and should start with ‘\`’ (to support directory names with embedded newlines, which would defeat ‘^’). The to string should be an ordinary absolute directory name pointing to the same directory. Do not use ‘~’ to stand for a home directory in the to string; Emacs performs these substitutions separately. Here’s an example, from a system on which /home/fsf is normally accessed through a symbolic link named /fsf:

((“\\`/home/fsf”。“/fsf”))
(("\\`/home/fsf" . "/fsf"))

19.8 文件目录

19.8 File Directories

文件系统将文件分组到目录中。目录列表是目录中所有文件的列表。 Emacs 提供了创建和删除目录的命令,以及以简短格式(仅文件名)和详细格式(包括大小、日期和其他属性)制作目录列表的命令。 Emacs 还包括一个名为 Dired 的目录浏览器功能,您可以使用 C-x d;调用它。请参阅Dired,目录编辑器

The file system groups files into directories. A directory listing is a list of all the files in a directory. Emacs provides commands to create and delete directories, and to make directory listings in brief format (file names only) and verbose format (sizes, dates, and other attributes included). Emacs also includes a directory browser feature called Dired, which you can invoke with C-x d; see Dired, the Directory Editor.

C-x C-d dir-or-pattern RET
C-x C-d dir-or-pattern RET

显示简短的目录列表 ( list-directory)。

Display a brief directory listing (list-directory).

C-u C-x C-d dir-or-pattern RET
C-u C-x C-d dir-or-pattern RET

显示详细的目录列表。

Display a verbose directory listing.

M-x make-directory RET dirname RET
M-x make-directory RET dirname RET

创建一个名为dirname的新目录。

Create a new directory named dirname.

M-x delete-directory RET dirname RET
M-x delete-directory RET dirname RET

删除名为dirname 的目录。如果不为空,系统会询问您是否要递归删除它。

Delete the directory named dirname. If it isn’t empty, you will be asked whether you want to delete it recursively.

显示目录列表的命令是C-x C-d ( list-directory)。它使用迷你缓冲区读取文件名,该文件名可以是要列出的目录,也可以是要列出的文件的包含通配符的模式。例如,

The command to display a directory listing is C-x C-d (list-directory). It reads using the minibuffer a file name which is either a directory to be listed or a wildcard-containing pattern for the files to be listed. For example,

Cx Cd /u2/emacs/etcRET
C-x C-d /u2/emacs/etc RET

列出目录中的所有文件/u2/emacs/等。以下是指定文件名模式的示例:

lists all the files in directory /u2/emacs/etc. Here is an example of specifying a file name pattern:

Cx Cd /u2/emacs/src/*.cRET
C-x C-d /u2/emacs/src/*.c RET

通常,C-x C-d显示仅包含文件名的简短目录列表。数字参数(无论值如何)告诉它制作一个详细的列表,包括大小、日期和所有者(例如“ls-l')。

Normally, C-x C-d displays a brief directory listing containing just file names. A numeric argument (regardless of value) tells it to make a verbose listing including sizes, dates, and owners (like ‘ls -l’).

目录列表的文本主要是通过 ls在较低的进程中运行来获得的。两个 Emacs 变量控制传递给 的开关lslist-directory-brief-switches是一个字符串,给出在简短列表中使用的开关("-CF"默认情况下),list-directory-verbose-switches是一个字符串,给出在详细列表中使用的开关("-l"默认情况下)。

The text of a directory listing is mostly obtained by running ls in an inferior process. Two Emacs variables control the switches passed to ls: list-directory-brief-switches is a string giving the switches to use in brief listings ("-CF" by default), and list-directory-verbose-switches is a string giving the switches to use in a verbose listing ("-l" by default).

在详细目录列表中,Emacs 添加有关包含该目录的磁盘上的可用空间量的信息。

In verbose directory listings, Emacs adds information about the amount of free space on the disk that contains the directory.

该命令M-x delete-directory使用迷你缓冲区提示输入目录名称,如果该目录为空,则删除该目录。如果目录不为空,系统会询问您是否要递归删除它。在具有“垃圾箱”(或“回收站”)功能的系统上,您可以通过将变量更改 delete-by-moving-to-trash为,使此命令将指定目录移动到垃圾箱,而不是直接删除它t。有关使用垃圾箱的更多信息, 请参阅其他文件操作。

The command M-x delete-directory prompts for a directory’s name using the minibuffer, and deletes the directory if it is empty. If the directory is not empty, you will be asked whether you want to delete it recursively. On systems that have a “Trash” (or “Recycle Bin”) feature, you can make this command move the specified directory to the Trash instead of deleting it outright, by changing the variable delete-by-moving-to-trash to t. See Miscellaneous File Operations, for more information about using the Trash.


19.9 比较文件

19.9 Comparing Files

该命令M-x diff使用迷你缓冲区提示输入两个文件名,并在名为的缓冲区中显示两个文件之间的差异*差异*。这是通过diff 使用从变量 中获取的选项来运行程序来实现的diff-switches。的值diff-switches应该是一个字符串;默认是 "-u"指定统一的上下文差异。有关该程序的更多信息,请参阅比较和合并文件中的Diffdiff

The command M-x diff prompts for two file names, using the minibuffer, and displays the differences between the two files in a buffer named *diff*. This works by running the diff program, using options taken from the variable diff-switches. The value of diff-switches should be a string; the default is "-u" to specify a unified context diff. See Diff in Comparing and Merging Files, for more information about the diff program.

该命令的输出diff使用称为 Diff 模式的主要模式显示。请参阅差异模式

The output of the diff command is shown using a major mode called Diff mode. See Diff Mode.

一个(更复杂的)替代方案是M-x ediff (请参阅《Ediff 手册》中的Ediff)。

A (much more sophisticated) alternative is M-x ediff (see Ediff in The Ediff Manual).

该命令M-x diff-backup将指定文件与其最近的备份进行比较。如果指定备份文件的名称, diff-backup请将其与作为备份的源文件进行比较。在所有其他方面,这都表现得像M-x diff

The command M-x diff-backup compares a specified file with its most recent backup. If you specify the name of a backup file, diff-backup compares it with the source file that it is a backup of. In all other respects, this behaves like M-x diff.

该命令M-x diff-buffer-with-file将指定的缓冲区与其相应的文件进行比较。这显示了如果保存缓冲区将对文件进行哪些更改。

The command M-x diff-buffer-with-file compares a specified buffer with its corresponding file. This shows you what changes you would make to the file if you save the buffer.

该命令M-x diff-buffers比较两个指定缓冲区的内容。

The command M-x diff-buffers compares the contents of two specified buffers.

该命令M-x compare-windows将当前窗口中的文本与选择当前窗口之前所选窗口中的文本进行比较。 (有关 Emacs 中窗口的更多信息,请参阅多个窗口。)在将标记环(请参阅标记环)上的每个初始点值推入其各自的缓冲区后,比较从每个窗口中的点开始。然后它在每个窗口中向前移动点,一次一个字符,直到到达不匹配的字符。然后命令退出。

The command M-x compare-windows compares the text in the current window with that in the window that was the selected window before you selected the current one. (For more information about windows in Emacs, see Multiple Windows.) Comparison starts at point in each window, after pushing each initial point value on the mark ring (see The Mark Ring) in its respective buffer. Then it moves point forward in each window, one character at a time, until it reaches characters that don’t match. Then the command exits.

如果命令启动时两个窗口中的 point 后面跟着不匹配的文本,则M-x compare-windows试探性地尝试前进到两个窗口中的匹配文本,然后退出。因此,如果您M-x compare-windows重复使用(请参阅重复命令),每次它都会跳过一个匹配范围或找到另一个匹配范围的开头。

If point in the two windows is followed by non-matching text when the command starts, M-x compare-windows tries heuristically to advance up to matching text in the two windows, and then exits. So if you use M-x compare-windows repeatedly (see Repeating a Command), each time it either skips one matching range or finds the start of another.

使用数字参数时,compare-windows忽略空格的变化。如果变量compare-ignore-case为非nil,则比较也会忽略大小写差异。如果变量compare-ignore-whitespace为 non- nilcompare-windows则默认情况下会忽略空格中的更改,但前缀参数会在该命令的单次调用中关闭该更改。

With a numeric argument, compare-windows ignores changes in whitespace. If the variable compare-ignore-case is non-nil, the comparison ignores differences in case as well. If the variable compare-ignore-whitespace is non-nil, compare-windows by default ignores changes in whitespace, but a prefix argument turns that off for that single invocation of the command.

您可以使用M-x smerge-mode打开 Smerge 模式,这是一种用于编辑diff3程序输出的次要模式。这通常是由于文件更改冲突而导致 VC 外部版本控制系统更新合并失败的结果。 Smerge 模式提供了通过选择特定更改来解决冲突的命令。

You can use M-x smerge-mode to turn on Smerge mode, a minor mode for editing output from the diff3 program. This is typically the result of a failed merge from a version control system update outside VC, due to conflicting changes to a file. Smerge mode provides commands to resolve conflicts by selecting specific changes.

请参阅使用 Emerge 合并文件,了解 Emerge 工具,它提供了用于合并文件的强大界面。

See Merging Files with Emerge, for the Emerge facility, which provides a powerful interface for merging files.


19.10 差异模式

19.10 Diff Mode

Diff 模式是用于输出M-x diff和其他类似命令的主要模式。这种输出称为patch,因为它可以传递给patch命令以自动应用指定的更改。要手动选择 Diff 模式,请键入M-x diff-mode

Diff mode is a major mode used for the output of M-x diff and other similar commands. This kind of output is called a patch, because it can be passed to the patch command to automatically apply the specified changes. To select Diff mode manually, type M-x diff-mode.

补丁中指定的更改被分组为hunk,它们是包含一个或多个更改行的连续文本块。 Hunks 通常还包含未更改的行来为更改提供上下文。每个块前面都有一个块头,它指定块发生更改的旧行号和新行号。 Diff 模式突出显示每个块标头,以将其与块的实际内容区分开。

The changes specified in a patch are grouped into hunks, which are contiguous chunks of text that contain one or more changed lines. Hunks usually also include unchanged lines to provide context for the changes. Each hunk is preceded by a hunk header, which specifies the old and new line numbers where the hunk’s changes occur. Diff mode highlights each hunk header, to distinguish it from the actual contents of the hunk.

补丁中的第一个块前面是文件头,其中显示文件的新旧版本的名称及其时间戳。如果补丁显示多个文件的更改,则每个文件在该文件的第一个更改之前都有这样的标头。

The first hunk in a patch is preceded by a file header, which shows the names of the new and the old versions of the file, and their time stamps. If a patch shows changes for more than one file, each file has such a header before the first hunk of that file’s changes.

您可以像编辑任何其他缓冲区一样编辑 Diff 模式缓冲区。 (如果它是只读的,您需要首先将其设置为可写;请参阅其他缓冲区操作。)每当您编辑块时,Diff 模式都会尝试自动更正块标头中的行号,以确保补丁保持正确,并且仍然可以应用patch。要禁用自动行号更正,请将变量更改 diff-update-on-the-flynil

You can edit a Diff mode buffer like any other buffer. (If it is read-only, you need to make it writable first; see Miscellaneous Buffer Operations.) Whenever you edit a hunk, Diff mode attempts to automatically correct the line numbers in the hunk headers, to ensure that the patch remains correct, and could still be applied by patch. To disable automatic line number correction, change the variable diff-update-on-the-fly to nil.

Diff 模式安排块被处理M-g M-n错误消息的其他命令视为编译器错误消息(请参阅编译模式)。因此,您可以使用编译模式命令来访问相应的源位置。

Diff mode arranges for hunks to be treated as compiler error messages by M-g M-n and other commands that handle error messages (see Compilation Mode). Thus, you can use the compilation-mode commands to visit the corresponding source locations.

此外,Diff 模式提供以下命令来导航、操作和应用补丁的各个部分:

In addition, Diff mode provides the following commands to navigate, manipulate and apply parts of patches:

M-n
M-n

移至下一个块开始 ( diff-hunk-next)。使用前缀参数n,向前移动到下一个块。

默认情况下,Diff 模式会在 Emacs 显示块时对其进行细化,以更好的粒度突出显示它们的更改。或者,如果您设置diff-refine为符号navigation,则 Diff 模式仅细化您使用此命令或使用 移动到的块 diff-hunk-prev

Move to the next hunk-start (diff-hunk-next). With prefix argument n, move forward to the nth next hunk.

By default, Diff mode refines hunks as Emacs displays them, highlighting their changes with better granularity. Alternatively, if you set diff-refine to the symbol navigation, Diff mode only refines the hunk you move to with this command or with diff-hunk-prev.

M-p
M-p

移至上一个块开始 ( diff-hunk-prev)。使用前缀参数n,移回到前n 个块。例如 ,如果您设置为符号,M-n则此命令会优化您移动到的块 。 diff-refinenavigation

Move to the previous hunk-start (diff-hunk-prev). With prefix argument n, move back to the nth previous hunk. Like M-n, this command refines the hunk you move to if you set diff-refine to the symbol navigation.

M-}
M-}

移至多文件补丁 ( ) 中的下一个文件开头diff-file-next。使用前缀参数n,前进到下一个文件的开头

Move to the next file-start, in a multi-file patch (diff-file-next). With prefix argument n, move forward to the start of the nth next file.

M-{
M-{

移至多文件补丁 ( ) 中的上一个文件开头diff-file-prev。使用前缀参数n ,移回到前n个文件的开头。

Move to the previous file-start, in a multi-file patch (diff-file-prev). With prefix argument n, move back to the start of the nth previous file.

M-k
M-k

在( )点杀死大块头diff-hunk-kill

Kill the hunk at point (diff-hunk-kill).

M-K
M-K

在多文件补丁中,杀死当前文件部分。 ( diff-file-kill)。

In a multi-file patch, kill the current file part. (diff-file-kill).

C-c C-a
C-c C-a

将此块应用到其目标文件 ( diff-apply-hunk)。使用前缀参数C-u,恢复该块,即应用该块的相反内容,将“新”版本更改为“旧”版本。如果diff-jump-to-old-file不是nil,则将块应用到文件的“旧”版本。

Apply this hunk to its target file (diff-apply-hunk). With a prefix argument of C-u, revert this hunk, i.e. apply the reverse of the hunk, which changes the “new” version into the “old” version. If diff-jump-to-old-file is non-nil, apply the hunk to the “old” version of the file instead.

C-c C-b
C-c C-b

以更细的粒度突出显示该点的块的变化 ( diff-refine-hunk)。这使您可以准确查看每条更改行的哪些部分实际上已更改。

默认情况下,Diff 模式会在 Emacs 显示块时对其进行细化,因此如果您自定义diff-refine为非默认值,您可能会发现此命令很有用。

Highlight the changes of the hunk at point with a finer granularity (diff-refine-hunk). This allows you to see exactly which parts of each changed line were actually changed.

By default, Diff mode refines hunks as Emacs displays them, so you may find this command useful if you customize diff-refine to a non-default value.

C-c C-c
C-c C-c

转到与该块 ( diff-goto-source) 对应的源文件和行。默认情况下,这会跳转到文件的“新”版本,即文件头中第一个显示的版本。使用前缀参数,跳转到“旧”版本。如果 diff-jump-to-old-file为非nil,则该命令默认跳转到“旧”文件,并且前缀参数的含义相反。如果前缀参数是大于 8 的数字(例如,如果您键入C-u C-u C-c C-c),则此命令还会diff-jump-to-old-file为下一次调用进行设置。如果源文件受版本控制(请参阅版本控制),则默认情况下会跳转到工作文件。使用前缀参数,当点位于旧行时,跳转到文件的“旧”修订版(请参阅检查和比较旧修订版),否则跳转到“新”修订版。

Go to the source file and line corresponding to this hunk (diff-goto-source). By default, this jumps to the “new” version of the file, the one shown first on the file header. With a prefix argument, jump to the “old” version instead. If diff-jump-to-old-file is non-nil, this command by default jumps to the “old” file, and the meaning of the prefix argument is reversed. If the prefix argument is a number greater than 8 (e.g., if you type C-u C-u C-c C-c), then this command also sets diff-jump-to-old-file for the next invocation. If the source file is under version control (see Version Control), this jumps to the work file by default. With a prefix argument, jump to the “old” revision of the file (see Examining And Comparing Old Revisions), when point is on the old line, or otherwise jump to the “new” revision.

C-c C-e
C-c C-e

使用补丁 ( diff-ediff-patch) 启动 Ediff 会话。请参阅Ediff 手册中的Ediff

Start an Ediff session with the patch (diff-ediff-patch). See Ediff in The Ediff Manual.

C-c C-n
C-c C-n

将视图限制为当前块 ( diff-restrict-view)。请参阅缩小范围。使用前缀参数,将视图限制为多文件补丁的当前文件。要再次加宽,请使用C-x n w( widen)。

Restrict the view to the current hunk (diff-restrict-view). See Narrowing. With a prefix argument, restrict the view to the current file of a multiple-file patch. To widen again, use C-x n w (widen).

C-c C-r
C-c C-r

反转整个缓冲区的比较方向 ( diff-reverse-direction)。使用前缀参数,仅在当前区域内反转方向(请参阅标记和区域)。反转方向意味着更改块和文件开始标头以生成一个补丁,将“新”版本更改为“旧”版本。

Reverse the direction of comparison for the entire buffer (diff-reverse-direction). With a prefix argument, reverse the direction only inside the current region (see The Mark and the Region). Reversing the direction means changing the hunks and the file-start headers to produce a patch that would change the “new” version into the “old” one.

C-c C-s
C-c C-s

将点 ( ) 处的块分成diff-split-hunk两个单独的块。这会插入一个块头并修改当前块的头。该命令对于手动编辑补丁很有用,并且仅适用于 -u或者- 统一程序的选项diff 。如果您需要以上下文差异格式分割 由-C或者- 语境选项为 diff,首先使用 将缓冲区转换为统一的 diff 格式C-c C-u

Split the hunk at point (diff-split-hunk) into two separate hunks. This inserts a hunk header and modifies the header of the current hunk. This command is useful for manually editing patches, and only works with the unified diff format produced by the -u or --unified options to the diff program. If you need to split a hunk in the context diff format produced by the -c or --context options to diff, first convert the buffer to the unified diff format with C-c C-u.

C-c C-d
C-c C-d

将整个缓冲区转换为上下文差异格式 ( diff-unified->context)。使用前缀参数,仅转换该区域内的块。

Convert the entire buffer to the context diff format (diff-unified->context). With a prefix argument, convert only the hunks within the region.

C-c C-u
C-c C-u

将整个缓冲区转换为统一 diff 格式 ( diff-context->unified)。使用前缀参数,将统一格式转换为上下文格式。当标记处于活动状态时,仅转换该区域内的帅哥。

Convert the entire buffer to unified diff format (diff-context->unified). With a prefix argument, convert unified format to context format. When the mark is active, convert only the hunks within the region.

C-c C-l
C-c C-l

重新生成当前块 ( diff-refresh-hunk)。

Re-generate the current hunk (diff-refresh-hunk).

C-c C-w
C-c C-w

重新生成当前块,忽略空白 ( diff-ignore-whitespace-hunk) 的变化。

Re-generate the current hunk, disregarding changes in whitespace (diff-ignore-whitespace-hunk).

C-x 4 A
C-x 4 A

C-x 4 a像所做的那样(请参阅更改日志),为每个大块头生成一个更改日志条目( diff-add-change-log-entries-other-window)。这将创建更改日志的框架,您稍后可以用更改的实际描述来填充该框架。 C-x 4 aDiff 模式下的自身代表当前块的文件进行操作,但从补丁本身获取函数名称。这对于为补丁删除的函数创建日志条目非常有用。

Generate a ChangeLog entry, like C-x 4 a does (see Change Logs), for each one of the hunks (diff-add-change-log-entries-other-window). This creates a skeleton of the log of changes that you can later fill with the actual descriptions of the changes. C-x 4 a itself in Diff mode operates on behalf of the current hunk’s file, but gets the function name from the patch itself. This is useful for making log entries for functions that are deleted by the patch.

补丁有时会在修改的行上包含尾随空格,这是一种无意且不需要的更改。有两种方法可以解决这个问题。首先,如果您在 Diff 缓冲区中启用空白模式(请参阅无用空白),它会自动突出显示修改行中的尾随空白。其次,您可以使用命令M-x diff-delete-trailing-whitespace,该命令在修补程序修改的行中搜索尾随空格,并删除修补程序和修补后的源文件中的该空格。该命令不会保存所做的修改,因此您可以决定是否保存更改(修改的文件列表显示在回显区域中)。使用前缀参数,它尝试修改原始(“旧”)源文件而不是修补后的(“新”)源文件。

Patches sometimes include trailing whitespace on modified lines, as an unintentional and undesired change. There are two ways to deal with this problem. Firstly, if you enable Whitespace mode in a Diff buffer (see Useless Whitespace), it automatically highlights trailing whitespace in modified lines. Secondly, you can use the command M-x diff-delete-trailing-whitespace, which searches for trailing whitespace in the lines modified by the patch, and removes that whitespace in both the patch and the patched source file(s). This command does not save the modifications that it makes, so you can decide whether to save the changes (the list of modified files is displayed in the echo area). With a prefix argument, it tries to modify the original (“old”) source files rather than the patched (“new”) source files.

如果diff-font-lock-syntax为非nil,则 hunks 中的源代码片段将根据适当的主要模式突出显示。

If diff-font-lock-syntax is non-nil, fragments of source in hunks are highlighted according to the appropriate major mode.


19.11 复制、命名和重命名文件

19.11 Copying, Naming and Renaming Files

Emacs 有多个用于复制、命名和重命名文件的命令。它们都使用迷你缓冲区读取两个文件名,old(或target)和 new,然后相应地复制或调整文件名;他们不接受通配符文件名。

Emacs has several commands for copying, naming, and renaming files. All of them read two file names, old (or target) and new, using the minibuffer, and then copy or adjust a file’s name accordingly; they do not accept wildcard file names.

在所有这些命令中,如果参数new只是一个目录名称(请参阅Emacs Lisp 参考手册中的目录名称),则真正的新名称位于该目录中,具有与old相同的非目录组件。例如,该命令 重命名M-x rename-file RET ~/foo RET /tmp/ RET〜/富/tmp/foo。在 GNU 和其他类似 POSIX 的系统上,目录名称以 ' 结尾/'。

In all these commands, if the argument new is just a directory name (see Directory Names in the Emacs Lisp Reference Manual), the real new name is in that directory, with the same non-directory component as old. For example, the command M-x rename-file RET ~/foo RET /tmp/ RET renames ~/foo to /tmp/foo. On GNU and other POSIX-like systems, directory names end in ‘/’.

当新文件名已经存在时,所有这些命令都要求确认。

All these commands ask for confirmation when the new file name already exists.

M-x copy-file将文件old的内容复制到文件new

M-x copy-file copies the contents of the file old to the file new.

M-x copy-directory复制目录,类似于 cp -rshell 命令。如果new是目录名,它将创建目录的副本并将其放入new中。否则,它将old的所有内容复制到名为new 的新目录中。如果copy-directory-create-symlink是非nilold是符号链接,则此命令将复制符号链接。如果nil,此命令将跟随链接并复制内容。 (这是默认设置。)

M-x copy-directory copies directories, similar to the cp -r shell command. If new is a directory name, it creates a copy of the old directory and puts it in new. Otherwise it copies all the contents of old into a new directory named new. If copy-directory-create-symlink is non-nil and old is a symbolic link, this command will copy the symbolic link. If nil, this command will follow the link and copy the contents instead. (This is the default.)

M-x rename-file将文件old 重命名为new。如果文件名new已经存在,必须确认yes,否则重命名不完成;这是因为重命名会导致名称的旧含义丢失。如果旧文件新文件位于不同的文件系统上,则复制并删除 旧文件。

M-x rename-file renames file old as new. If the file name new already exists, you must confirm with yes or renaming is not done; this is because renaming causes the old meaning of the name new to be lost. If old and new are on different file systems, the file old is copied and deleted.

如果文件受版本控制(请参阅版本控制),则应 使用.请参阅删除和重命名版本控制文件M-x vc-rename-fileM-x rename-file

If a file is under version control (see Version Control), you should rename it using M-x vc-rename-file instead of M-x rename-file. See Deleting and Renaming Version-Controlled Files.

M-x add-name-to-file向现有文件添加附加名称而不删除旧名称。新名称被创建为现有文件的硬链接。新名称必须属于该文件所在的同一文件系统。在 MS-Windows 上,仅当文件驻留在 NTFS 文件系统中时此命令才有效。在 MS-DOS 和某些远程系统类型上,它通过复制文件来工作。

M-x add-name-to-file adds an additional name to an existing file without removing the old name. The new name is created as a hard link to the existing file. The new name must belong on the same file system that the file is on. On MS-Windows, this command works only if the file resides in an NTFS file system. On MS-DOS, and some remote system types, it works by copying the file.

M-x make-symbolic-link创建一个名为new 的符号链接 ,该链接指向target。其效果是,将来尝试打开文件时将引用 打开完成时名为target的任何文件,或者如果当时名称target不存在,则会出现错误。此命令不会扩展参数target,因此它允许您指定相对名称作为链接的目标。但是,此命令确实扩展了前导 '' 在目标中,以便您可以轻松指定主目录,并删除前导 '/:' 这样您就可以指定以文字 ' 开头的相对名称' 或者 '/:'。请参阅引用的文件名。在 MS-Windows 上,此命令仅适用于 MS Windows Vista 及更高版本。当new是远程时,它的工作原理取决于系统类型。

M-x make-symbolic-link creates a symbolic link named new, which points at target. The effect is that future attempts to open file new will refer to whatever file is named target at the time the opening is done, or will get an error if the name target is nonexistent at that time. This command does not expand the argument target, so that it allows you to specify a relative name as the target of the link. However, this command does expand leading ‘~’ in target so that you can easily specify home directories, and strips leading ‘/:’ so that you can specify relative names beginning with literal ‘~’ or ‘/:’. See Quoted File Names. On MS-Windows, this command works only on MS Windows Vista and later. When new is remote, it works depending on the system type.


19.12 杂项文件操作

19.12 Miscellaneous File Operations

Emacs 具有用于对文件执行许多其他操作的命令。全部操作在一个文件上;他们不接受通配符文件名。

Emacs has commands for performing many other operations on files. All operate on one file; they do not accept wildcard file names.

M-x delete-file提示输入文件并将其删除。如果要删除一个目录中的多个文件,使用 Dired 可能比delete-file.请参阅使用 Dired 删除文件

M-x delete-file prompts for a file and deletes it. If you are deleting many files in one directory, it may be more convenient to use Dired rather than delete-file. See Deleting Files with Dired.

M-x move-file-to-trash将文件移至系统 垃圾箱(或回收站)。大多数操作系统都可以使用此功能;如果您改变主意,移入废纸篓的文件可以稍后取回。 (恢复已删除文件的方式取决于系统。)

M-x move-file-to-trash moves a file into the system Trash (or Recycle Bin). This is a facility available on most operating systems; files that are moved into the Trash can be brought back later if you change your mind. (The way to restore trashed files is system-dependent.)

默认情况下,Emacs 删除命令不使用垃圾箱。要使用垃圾箱(如果可用)执行常见删除命令,请将变量更改delete-by-moving-to-trasht。这会影响命令M-x delete-fileM-x delete-directory(请参阅文件目录),以及 Dired 中的删除命令(请参阅使用 Dired 删除文件)。向M-x delete-file或提供前缀参数M-x delete-directory使它们彻底删除,而不是使用垃圾箱,无论 delete-by-moving-to-trash.

By default, Emacs deletion commands do not use the Trash. To use the Trash (when it is available) for common deletion commands, change the variable delete-by-moving-to-trash to t. This affects the commands M-x delete-file and M-x delete-directory (see File Directories), as well as the deletion commands in Dired (see Deleting Files with Dired). Supplying a prefix argument to M-x delete-file or M-x delete-directory makes them delete outright, instead of using the Trash, regardless of delete-by-moving-to-trash.

如果你已经delete-by-moving-to-trash设置了,并且你想在 Emacs 中手动从 Trash 目录中删除文件,那么使用D( dired-do-delete) 这样的命令在 Trash 目录中效果不佳(它只会给文件一个新名称,但不会删除任何事物)。如果您希望能够执行此操作,您应该.dir-locals.el在 Trash 目录中创建一个包含类似以下内容的文件:

If you have delete-by-moving-to-trash set, and you want to delete files manually in Emacs from the Trash directory, using commands like D (dired-do-delete) doesn’t work well in the Trash directory (it’ll just give the file a new name, but won’t delete anything). If you want to be able to do this, you should create a .dir-locals.el file containing something like the following in the Trash directory:

((dired-mode . ((通过移动到垃圾箱删除 . nil))))
((dired-mode . ((delete-by-moving-to-trash . nil))))

但请注意,如果您使用系统“清空垃圾箱”命令,它也可能会删除该.dir-locals.el文件,因此只有在手动从“垃圾箱”目录中删除文件时才应执行此操作。

Note, however, if you use the system “empty trash” command, it’s liable to also delete this .dir-locals.el file, so this should only be done if you delete files from the Trash directory manually.

如果文件受版本控制(请参阅版本控制),则应使用M-x vc-delete-file而不是 来删除它M-x delete-file。请参阅删除和重命名版本控制文件

If a file is under version control (see Version Control), you should delete it using M-x vc-delete-file instead of M-x delete-file. See Deleting and Renaming Version-Controlled Files.

M-x insert-file(也C-x i)将指定文件的内容的副本插入到当前缓冲区的 point 中,使内容之前的 point 保持不变。插入内容之后的位置将添加到标记环中,而不激活标记(请参阅标记环)。

M-x insert-file (also C-x i) inserts a copy of the contents of the specified file into the current buffer at point, leaving point unchanged before the contents. The position after the inserted contents is added to the mark ring, without activating the mark (see The Mark Ring).

M-x insert-file-literally类似于,只不过文件是按字面插入的:它被视为ASCIIM-x insert-file字符序列,没有特殊的编码或转换,类似于命令(请参阅访问文件)。 M-x find-file-literally

M-x insert-file-literally is like M-x insert-file, except the file is inserted literally: it is treated as a sequence of ASCII characters with no special encoding or conversion, similar to the M-x find-file-literally command (see Visiting Files).

M-x write-region是 的倒数M-x insert-file;它将区域的内容复制到指定的文件中。 M-x append-to-file将区域文本添加到指定文件的末尾。请参阅累积文本。该变量 write-region-inhibit-fsync适用于这些命令以及保存文件;请参阅自定义文件保存

M-x write-region is the inverse of M-x insert-file; it copies the contents of the region into the specified file. M-x append-to-file adds the text of the region to the end of the specified file. See Accumulating Text. The variable write-region-inhibit-fsync applies to these commands, as well as saving files; see Customizing Saving of Files.

M-x set-file-modes读取文件名后跟文件模式,并将该文件模式应用于指定的文件。文件模式(也称为文件权限)决定文件是否可以读取、写入或执行以及由谁读取、写入或执行。该命令使用该 chmod命令接受的相同符号或八进制格式读取文件模式;例如, 'u+x' 表示为拥有该文件的用户添加执行权限。它对不支持文件模式的操作系统没有影响。 chmod是此函数的方便别名。

M-x set-file-modes reads a file name followed by a file mode, and applies that file mode to the specified file. File modes, also called file permissions, determine whether a file can be read, written to, or executed, and by whom. This command reads file modes using the same symbolic or octal format accepted by the chmod command; for instance, ‘u+x’ means to add execution permission for the user who owns the file. It has no effect on operating systems that do not support file modes. chmod is a convenience alias for this function.


19.13 访问压缩文件

19.13 Accessing Compressed Files

当您访问压缩文件时,Emacs 会自动解压缩它们;如果您更改并保存它们,Emacs 也会自动重新压缩它们。 Emacs 通过文件名来识别压缩文件。文件名以 ' 结尾.gz' 表示使用 gzip.其他结尾表示其他压缩程序。

Emacs automatically uncompresses compressed files when you visit them, and automatically recompresses them if you alter them and save them. Emacs recognizes compressed files by their file names. File names ending in ‘.gz’ indicate a file compressed with gzip. Other endings indicate other compression programs.

自动解压缩和压缩适用于 Emacs 使用文件内容的所有操作。这包括访问它、保存它、将其内容插入缓冲区、加载它以及字节编译它。

Automatic uncompression and compression apply to all the operations in which Emacs uses the contents of a file. This includes visiting it, saving it, inserting its contents into a buffer, loading it, and byte compiling it.

要禁用此功能,请键入命令M-x auto-compression-mode。您可以通过自定义变量来永久禁用它auto-compression-mode

To disable this feature, type the command M-x auto-compression-mode. You can disable it permanently by customizing the variable auto-compression-mode.


19.14 文件档案

19.14 File Archives

名称以 ' 结尾的文件。柏油' 通常是程序 制作的存档tar。 Emacs 以一种称为 Tar 模式的特殊模式查看这些文件,该模式提供类似 Dired 的内容列表(请参阅Dired,目录编辑器)。您可以像在 Dired 中一样浏览列表,并访问存档中包含的子文件。但是,并非所有 Dired 命令都在 Tar 模式下可用。

A file whose name ends in ‘.tar’ is normally an archive made by the tar program. Emacs views these files in a special mode called Tar mode which provides a Dired-like list of the contents (see Dired, the Directory Editor). You can move around through the list just as you would in Dired, and visit the subfiles contained in the archive. However, not all Dired commands are available in Tar mode.

如果启用自动压缩模式(请参阅访问压缩文件),则 Tar 模式也用于压缩存档 - 扩展名为 ' 的文件.tgz',.tar.Z.tar.gz

If Auto Compression mode is enabled (see Accessing Compressed Files), then Tar mode is used also for compressed archives—files with extensions ‘.tgz’, .tar.Z and .tar.gz.

efRET全部将组件文件提取到自己的缓冲区中。您可以在那里编辑它,如果保存缓冲区,编辑后的版本将替换 Tar 缓冲区中的版本。用鼠标单击 Tar 缓冲区中的文件名也会产生同样的效果。 v在查看模式下将文件提取到缓冲区(请参阅查看模式)。 o提取文件并将其显示在另一个窗口中,以便您可以同时编辑文件和操作存档。

The keys e, f and RET all extract a component file into its own buffer. You can edit it there, and if you save the buffer, the edited version will replace the version in the Tar buffer. Clicking with the mouse on the file name in the Tar buffer does likewise. v extracts a file into a buffer in View mode (see View Mode). o extracts the file and displays it in another window, so you could edit the file and operate on the archive simultaneously.

I密钥将新的(常规)文件添加到存档中。该文件最初是空的,但可以使用上面的命令轻松编辑。该命令将新文件插入到当前文件之前,因此在 Tar 缓冲区的最上面一行使用它会使新文件成为归档中的第一个文件,在缓冲区末尾使用它会使其成为最后一个文件。

The I key adds a new (regular) file to the archive. The file is initially empty, but can readily be edited using the commands above. The command inserts the new file before the current one, so that using it on the topmost line of the Tar buffer makes the new file the first one in the archive, and using it at the end of the buffer makes it the last one.

d当您稍后使用 时,将文件标记为删除x,并 u取消标记文件,如 Dired 中。 C将文件从存档复制到磁盘并重R命名存档中的文件。 g从磁盘上的存档恢复缓冲区。键 MGO分别更改文件的权限位、组和所有者。

d marks a file for deletion when you later use x, and u unmarks a file, as in Dired. C copies a file from the archive to disk and R renames a file within the archive. g reverts the buffer from the archive on disk. The keys M, G, and O change the file’s permission bits, group, and owner, respectively.

保存 Tar 缓冲区会将新版本的存档以及您对组件所做的更改写入磁盘。

Saving the Tar buffer writes a new version of the archive to disk with the changes you made to the components.

您不需要tar程序来使用 Tar 模式 — Emacs 直接读取档案。但是,访问压缩档案需要适当的解压缩程序。

You don’t need the tar program to use Tar mode—Emacs reads the archives directly. However, accessing compressed archives requires the appropriate uncompression program.

单独但类似的存档模式用于arcjarlzhziprar7zzoo存档,以及exe自解压可执行文件。

A separate but similar Archive mode is used for arc, jar, lzh, zip, rar, 7z, and zoo archives, as well as exe files that are self-extracting executables.

Archive模式的按键绑定与Tar模式类似,多了一个按键m,用于标记文件以便后续操作,以及取消标记所有标记的文件。此外,该键还可以切换详细文件信息的显示,对于那些无法在一行中容纳的存档类型。仅某些存档格式支持重命名子文件或更改其模式或所有者等操作。 M-DELa

The key bindings of Archive mode are similar to those in Tar mode, with the addition of the m key which marks a file for subsequent operations, and M-DEL which unmarks all the marked files. Also, the a key toggles the display of detailed file information, for those archive types where it won’t fit in a single line. Operations such as renaming a subfile, or changing its mode or owner, are supported only for some of the archive formats.

与 Tar 模式不同,Archive 模式运行存档程序来解压和重新打包存档。但是,您不需要这些程序来查看存档目录,只需提取或操作存档中的子文件即可。程序名称及其选项的详细信息可以在“档案' 自定义组(请参阅自定义组)。

Unlike Tar mode, Archive mode runs the archiving programs to unpack and repack archives. However, you don’t need these programs to look at the archive table of contents, only to extract or manipulate the subfiles in the archive. Details of the program names and their options can be set in the ‘Archive’ Customize group (see Customization Groups).


19.15 远程文件

19.15 Remote Files

您可以使用特殊的文件名语法引用其他计算机上的文件:

You can refer to files on other machines using a special file name syntax:

/方法:主机:文件名
/方法:用户@主机:文件名
/方法:用户@主机#端口:文件名
/method:host:filename
/method:user@host:filename
/method:user@host#port:filename

为了执行此请求,Emacs 使用远程登录程序,例如 ssh.您必须始终在文件名中指定要使用的方法,例如,/ssh:用户@主机:文件名使用 ssh.当您指定伪方法 '-' 在文件名中,Emacs 选择方法如下:

To carry out this request, Emacs uses a remote-login program such as ssh. You must always specify in the file name which method to use—for example, /ssh:user@host:filename uses ssh. When you specify the pseudo method ‘-’ in the file name, Emacs chooses the method as follows:

  1. 如果主机名以 ' 开头ftp。'(带点),Emacs 使用 FTP。
  2. If the host name starts with ‘ftp.’ (with dot), Emacs uses FTP.
  3. 如果用户名是 '文件传输协议' 或者 '匿名的', Emacs 使用 FTP。
  4. If the user name is ‘ftp’ or ‘anonymous’, Emacs uses FTP.
  5. 如果变量tramp-default-method设置为 '文件传输协议', Emacs 使用 FTP。
  6. If the variable tramp-default-method is set to ‘ftp’, Emacs uses FTP.
  7. 如果ssh-agent正在运行,Emacs 使用scp.
  8. If ssh-agent is running, Emacs uses scp.
  9. 否则,Emacs 使用ssh.
  10. Otherwise, Emacs uses ssh.

您可以通过将变量设置tramp-mode为 来完全关闭远程文件名功能nil。在个别情况下,您可以通过用 ' 引用文件名来关闭该功能/:'(参见引用的文件名)。

You can entirely turn off the remote file name feature by setting the variable tramp-mode to nil. You can turn off the feature in individual cases by quoting the file name with ‘/:’ (see Quoted File Names).

通过 FTP 的远程文件访问由 Ange-FTP 包处理,如下所述。通过其他方法进行的远程文件访问由 Tramp 包处理,该包有自己的手册。请参阅《流浪汉手册》中的《流浪汉手册》 。

Remote file access through FTP is handled by the Ange-FTP package, which is documented in the following. Remote file access through the other methods is handled by the Tramp package, which has its own manual. See The Tramp Manual in The Tramp Manual.

当使用 Ange-FTP 包时,Emacs 使用名称user通过 FTP 登录(如果远程文件名中指定了该名称)。如果 未指定用户,Emacs 将使用您在本地系统上的用户名登录;但如果将变量设置ange-ftp-default-user 为字符串,则会使用该字符串。登录时,Emacs 也可能会要求输入密码。

When the Ange-FTP package is used, Emacs logs in through FTP using the name user, if that is specified in the remote file name. If user is unspecified, Emacs logs in using your user name on the local system; but if you set the variable ange-ftp-default-user to a string, that string is used instead. When logging in, Emacs may also ask for a password.

出于性能原因,Emacs 默认情况下不会为通过 FTP 访问的文件创建备份文件。为此,请将变量更改 ange-ftp-make-backup-files为非值nil

For performance reasons, Emacs does not make backup files for files accessed via FTP by default. To make it do so, change the variable ange-ftp-make-backup-files to a non-nil value.

默认情况下,远程文件的自动保存文件是在本地计算机上的临时文件目录中创建的,由变量 指定auto-save-file-name-transforms。请参阅自动保存文件

By default, auto-save files for remote files are made in the temporary file directory on the local machine, as specified by the variable auto-save-file-name-transforms. See Auto-Save Files.

要访问可通过匿名 FTP 访问的文件,您可以使用特殊的用户名 '匿名的' 或者 '文件传输协议'。这些用户名的密码经过特殊处理。该变量 ange-ftp-generate-anonymous-password控制发生的情况:如果该变量的值是字符串,则该字符串用作密码;如果非(默认),则使用nil的值 ;user-mail-address如果nil,则 Emacs 会照常提示您输入密码(请参阅输入密码)。

To visit files accessible by anonymous FTP, you use special user names ‘anonymous’ or ‘ftp’. Passwords for these user names are handled specially. The variable ange-ftp-generate-anonymous-password controls what happens: if the value of this variable is a string, then that string is used as the password; if non-nil (the default), then the value of user-mail-address is used; if nil, then Emacs prompts you for a password as usual (see Entering passwords).

有时,您可能无法访问远程计算机上的文件,因为中间的防火墙出于安全原因阻止了连接。如果您可以登录可访问目标文件的网关计算机并且其 FTP 服务器支持网关功能,您仍然可以使用远程文件名;您所要做的就是通过设置变量 来指定网关计算机的名称,并将其设置 为。否则,您也许可以使远程文件名起作用,但过程很复杂。您可以通过键入 来阅读说明。 ange-ftp-gateway-hostange-ftp-smart-gatewaytM-x finder-commentary RET ange-ftp RET

Sometimes you may be unable to access files on a remote machine because a firewall in between blocks the connection for security reasons. If you can log in on a gateway machine from which the target files are accessible, and whose FTP server supports gatewaying features, you can still use remote file names; all you have to do is specify the name of the gateway machine by setting the variable ange-ftp-gateway-host, and set ange-ftp-smart-gateway to t. Otherwise you may be able to make remote file names work, but the procedure is complex. You can read the instructions by typing M-x finder-commentary RET ange-ftp RET.


19.16 引用的文件名

19.16 Quoted File Names

您可以引用绝对文件名,以防止其中的特殊字符和语法产生特殊效果。执行此操作的方法是添加 '/:' 在开头。

You can quote an absolute file name to prevent special characters and syntax in it from having their special effects. The way to do this is to add ‘/:’ at the beginning.

例如,您可以引用看似远程的本地文件名,以防止将其视为远程文件名。因此,如果您有一个名为/foo:和一个名为酒吧在其中,您可以在 Emacs 中将该文件引用为 '/:/foo:/酒吧'。

For example, you can quote a local file name which appears remote, to prevent it from being treated as a remote file name. Thus, if you have a directory named /foo: and a file named bar in it, you can refer to that file in Emacs as ‘/:/foo:/bar’.

如果您只想引用远程文件名本地部分中的特殊字符,则可以仅引用本地部分。 '/ssh:baz:/:/foo:/bar' 指的是文件酒吧目录的 /foo:在主机上巴兹

If you want to quote only special characters in the local part of a remote file name, you can quote just the local part. ‘/ssh:baz:/:/foo:/bar’ refers to the file bar of directory /foo: on the host baz.

'/:'也可以预防'' 避免被视为用户主目录的特殊字符。例如,/:/tmp/~hack 引用一个文件,其名称为〜黑客在目录中/tmp

/:’ can also prevent ‘~’ from being treated as a special character for a user’s home directory. For example, /:/tmp/~hack refers to a file whose name is ~hack in directory /tmp.

用 ' 引用/:' 也是在迷你缓冲区中输入包含 ' 的文件名的一种方法$'。为了使其发挥作用,'/:' 必须位于迷你缓冲区内容的开头。 (您也可以将每个 ' 加倍$';请参阅带有 $ 的文件名。)

Quoting with ‘/:’ is also a way to enter in the minibuffer a file name that contains ‘$’. In order for this to work, the ‘/:’ must be at the beginning of the minibuffer contents. (You can also double each ‘$’; see File Names with $.)

您还可以使用 ' 引用通配符/:',来参观。例如,/:/tmp/foo*bar访问文件 /tmp/foo*酒吧

You can also quote wildcard characters with ‘/:’, for visiting. For example, /:/tmp/foo*bar visits the file /tmp/foo*bar.

获得相同结果的另一种方法是输入 /tmp/foo[*]栏,这是一个通配符规范,仅匹配/tmp/foo*酒吧。然而,在许多情况下,不需要引用通配符,因为即使不加引号,它们也会给出正确的结果。例如,如果唯一的文件名/tmp以 ' 开头' 并以 ' 结尾酒吧' 是富*酒吧,然后指定/tmp/foo*酒吧只会访问 /tmp/foo*酒吧

Another method of getting the same result is to enter /tmp/foo[*]bar, which is a wildcard specification that matches only /tmp/foo*bar. However, in many cases there is no need to quote the wildcard characters because even unquoted they give the right result. For example, if the only file name in /tmp that starts with ‘foo’ and ends with ‘bar’ is foo*bar, then specifying /tmp/foo*bar will visit only /tmp/foo*bar.


19.17 文件名缓存

19.17 File Name Cache

您可以使用文件名缓存来轻松地按名称定位文件,而无需准确记住它所在的位置。当在迷你缓冲区中输入文件名时, ( ) 使用文件名缓存完成输入。如果您重复,则会循环显示您最初键入的内容的可能补全。 (但是,请注意,无法在大多数文本终端上键入该字符。) C-TABfile-cache-minibuffer-completeC-TABC-TAB

You can use the file name cache to make it easy to locate a file by name, without having to remember exactly where it is located. When typing a file name in the minibuffer, C-TAB (file-cache-minibuffer-complete) completes it using the file name cache. If you repeat C-TAB, that cycles through the possible completions of what you had originally typed. (However, note that the C-TAB character cannot be typed on most text terminals.)

文件名缓存不会自动填满。相反,您可以使用以下命令将文件名加载到缓存中:

The file name cache does not fill up automatically. Instead, you load file names into the cache using these commands:

M-x file-cache-add-directory RET directory RET
M-x file-cache-add-directory RET directory RET

将目录中的每个文件名添加到文件名缓存中。

Add each file name in directory to the file name cache.

M-x file-cache-add-directory-using-find RET directory RET
M-x file-cache-add-directory-using-find RET directory RET

将目录及其所有嵌套子目录 中的每个文件名添加到文件名缓存中。

Add each file name in directory and all of its nested subdirectories to the file name cache.

M-x file-cache-add-directory-using-locate RET directory RET
M-x file-cache-add-directory-using-locate RET directory RET

将目录中的每个文件名及其所有嵌套子目录添加到文件名缓存中,使用locate来查找它们。

Add each file name in directory and all of its nested subdirectories to the file name cache, using locate to find them all.

M-x file-cache-add-directory-list RET variable RET
M-x file-cache-add-directory-list RET variable RET

将变量中列出的每个目录中的每个文件名添加到文件名缓存中。 变量应该是一个 Lisp 变量,其值是目录列表,例如load-path.

Add each file name in each directory listed in variable to the file name cache. variable should be a Lisp variable whose value is a list of directories, like load-path.

M-x file-cache-clear-cache RET
M-x file-cache-clear-cache RET

清除缓存;也就是说,从中删除所有文件名。

Clear the cache; that is, remove all file names from it.

文件名缓存不是持久性的:它仅在 Emacs 会话期间保留和维护。可以通过命令查看缓存的内容file-cache-display

The file name cache is not persistent: it is kept and maintained only for the duration of the Emacs session. You can view the contents of the cache with the file-cache-display command.


19.18 查找文件的便捷功能

19.18 Convenience Features for Finding Files

在本节中,我们将介绍一些方便的工具,用于查找最近打开的文件,从缓冲区读取文件名。

In this section, we introduce some convenient facilities for finding recently-opened files, reading file names from a buffer.

如果使用 启用Recentf 模式,M-x recentf-modeEmacs 会维护最近打开的文件的列表。要从此列表中打开文件,请使用以下M-x recentf-open命令。当启用此模式时,'文件' 菜单将包含一个子菜单,您可以使用它来访问这些文件之一。 M-x recentf-save-list将当前内容保存recentf-list到文件中并M-x recentf-edit-list 对其进行编辑。

If you enable Recentf mode, with M-x recentf-mode, Emacs maintains a list of recently opened files. To open a file from this list, use the M-x recentf-open command. When this mode is enabled, the ‘File’ menu will include a submenu that you can use to visit one of these files. M-x recentf-save-list saves the current recentf-list to a file, and M-x recentf-edit-list edits it.

M-x ffap命令概括find-file为更强大的启发式默认值(请参阅在点处查找文件和 URL),通常基于点处的文本。部分完成模式提供了其他扩展功能 find-file,可以与ffap.请参阅完成选项

The M-x ffap command generalizes find-file with more powerful heuristic defaults (see Finding Files and URLs at Point), often based on the text at point. Partial Completion mode offers other features extending find-file, which can be used with ffap. See Completion Options.


19.19 查看图像文件

19.19 Viewing Image Files

访问图像文件会自动选择图像模式。在此主要模式中,您可以键入C-c C-c( image-toggle-display) 在 Emacs 缓冲区中将文件显示为图像和显示其底层文本(或原始字节)表示形式之间进行切换。此外,您还可以键入C-c C-x( image-toggle-hex-display) 在 Emacs 缓冲区中将文件显示为图像和以十六进制表示形式显示之间进行切换。仅当 Emacs 编译为支持显示此类图像时,才能将文件显示为图像。

Visiting image files automatically selects Image mode. In this major mode, you can type C-c C-c (image-toggle-display) to toggle between displaying the file as an image in the Emacs buffer, and displaying its underlying text (or raw byte) representation. Additionally you can type C-c C-x (image-toggle-hex-display) to toggle between displaying the file as an image in the Emacs buffer, and displaying it in hex representation. Displaying the file as an image works only if Emacs is compiled with support for displaying such images.

如果显示的图像比显示它的窗口更宽或更高,则通常的点运动键(C-fC-p等)会导致显示图像的不同部分。但是,默认情况下,图像会自动调整大小以适合窗口,因此仅当您使用选项image-auto-resize和 自定义默认行为时才需要这样做image-auto-resize-on-window-resize

If the displayed image is wider or taller than the window in which it is displayed, the usual point motion keys (C-f, C-p, and so forth) cause different parts of the image to be displayed. However, by default images are resized automatically to fit the window, so this is only necessary if you customize the default behavior by using the options image-auto-resize and image-auto-resize-on-window-resize.

image-transform-fit-to-window要手动调整图像大小,您可以使用绑定的命令 s w使图像适合窗口高度和宽度。要将图像缩放到其原始大小的一定百分比,请使用 image-transform-set-percent绑定到 的命令s p。要缩放指定比例因子的图像,请使用 image-transform-set-scale绑定到 的命令s s。要将所有转换重置为初始状态,请使用 image-transform-reset-to-initial绑定到s 0image-transform-reset-to-original绑定到s o

To resize the image manually you can use the command image-transform-fit-to-window bound to s w that fits the image to both the window height and width. To scale the image to a percentage of its original size, use the command image-transform-set-percent bound to s p. To scale the image specifying a scale factor, use the command image-transform-set-scale bound to s s. To reset all transformations to the initial state, use image-transform-reset-to-initial bound to s 0, or image-transform-reset-to-original bound to s o.

您可以按n( image-next-file) 和p ( image-previous-file) 分别访问同一目录下的下一个图像文件和上一个图像文件。这些命令将查询“父”dired 缓冲区以确定下一个/上一个图像文件是什么。当从存档文件(如 zip 或 tar 文件)打开文件时,这些命令也有效,然后将查询存档模式缓冲区。如果找不到存档或 dired“父”缓冲区,则会打开 dired 缓冲区。

You can press n (image-next-file) and p (image-previous-file) to visit the next image file and the previous image file in the same directory, respectively. These commands will consult the “parent” dired buffer to determine what the next/previous image file is. These commands also work when opening a file from archive files (like zip or tar files), and will then instead consult the archive mode buffer. If neither an archive nor a dired “parent” buffer can be found, a dired buffer is opened.

查看图像时,有时能够方便地标记文件以供以后处理(例如,如果您想选择一组图像复制到其他位置)。m ( )命令image-mode-mark-file将在显示当前文件目录的任何 Dired 缓冲区中标记当前文件。如果没有打开这样的缓冲区,则在新缓冲区中打开该目录。要取消标记文件,请使用u( image-mode-mark-file) 命令。最后,如果您只想将当前缓冲区文件名复制到killring,则可以使用w ( image-mode-copy-file-name-as-kill)命令。

When looking through images, it’s sometimes convenient to be able to mark the files for later processing (for instance, if you want to select a group of images to copy somewhere else). The m (image-mode-mark-file) command will mark the current file in any Dired buffer(s) that display the current file’s directory. If no such buffer is open, the directory is opened in a new buffer. To unmark files, use the u (image-mode-mark-file) command. Finally, if you just want to copy the current buffers file name to the kill ring, you can use the w (image-mode-copy-file-name-as-kill) command.

如果图像可以动画化,则命令RET ( image-toggle-animation) 启动或停止动画。动画播放一次,除非选项image-animate-loop为非nil。使用f( image-next-frame) 和b ( image-previous-frame) 您可以单步执行各个帧。这两个命令都接受数字前缀来一次单步执行多个帧。您可以使用F ( )转到特定帧image-goto-frame。帧从 1 开始索引。键入a +( image-increase-speed) 会增加动画的速度, a -( image-decrease-speed) 会降低动画的速度,键入a r ( image-reverse-speed) 则会反转动画的速度。命令a 0 ( image-reset-speed) 将速度重置为原始值。

If the image can be animated, the command RET (image-toggle-animation) starts or stops the animation. Animation plays once, unless the option image-animate-loop is non-nil. With f (image-next-frame) and b (image-previous-frame) you can step through the individual frames. Both commands accept a numeric prefix to step through several frames at once. You can go to a specific frame with F (image-goto-frame). Frames are indexed from 1. Typing a + (image-increase-speed) increases the speed of the animation, a - (image-decrease-speed) decreases it, and a r (image-reverse-speed) reverses it. The command a 0 (image-reset-speed) resets the speed to the original value.

除了上述特定于图像模式的键绑定之外,当点位于图像处或图像内部时,任何 Emacs 缓冲区中显示的图像都具有特殊的键绑定:

In addition to the above key bindings, which are specific to Image mode, images shown in any Emacs buffer have special key bindings when point is at or inside the image:

i +
i +

将图像尺寸 ( image-increase-size) 增大 20%。前缀数字参数控制增量;n的值意味着将大小乘以因子,因此 意味着将大小增加 50%。 1 + n / 10C-u 5 i +

Increase the image size (image-increase-size) by 20%. Prefix numeric argument controls the increment; the value of n means to multiply the size by the factor of 1 + n / 10, so C-u 5 i + means to increase the size by 50%.

i -
i -

将图像尺寸 ( image-increase-size) 减小 20%。前缀数字参数控制减量;n的值意味着将大小乘以因子,因此 意味着将大小减小 30%。 - n / 10C-u 3 i -

Decrease the image size (image-increase-size) by 20%. Prefix numeric argument controls the decrement; the value of n means to multiply the size by the factor of - n / 10, so C-u 3 i - means to decrease the size by 30%.

i r
i r

将图像顺时针旋转 90 度 ( image-rotate)。使用前缀参数,改为逆时针旋转 90 度。请注意,此命令不适用于切片图像。

Rotate the image by 90 degrees clockwise (image-rotate). With the prefix argument, rotate by 90 degrees counter-clockwise instead. Note that this command is not available for sliced images.

i h
i h

水平翻转图像 ( image-flip-horizontally)。这呈现的图像就像在垂直镜子中反射一样。请注意,此命令不适用于切片图像。

Flip the image horizontally (image-flip-horizontally). This presents the image as if reflected in a vertical mirror. Note that this command is not available for sliced images.

i v
i v

垂直翻转图像 ( image-flip-vertically)。这呈现的图像就像在水平镜子中反射一样。请注意,此命令不适用于切片图像。

Flip the image vertically (image-flip-vertically). This presents the image as if reflected in a horizontal mirror. Note that this command is not available for sliced images.

i o
i o

将图像保存到文件 ( image-save)。此命令提示您输入用于保存图像的文件名。

Save the image to a file (image-save). This command prompts you for the name of the file to save the image.

i c
i c

裁剪图像 ( image-crop)。仅当您的系统安装了可用于裁剪和剪切图像的外部程序时,此命令才可用;用户选项 image-crop-crop-command决定使用什么程序,默认为 ImageMagick 的convert程序。该命令显示图像上叠加了一个矩形框,并允许您使用鼠标移动该框并调整该框的大小。键入m以使鼠标移动来移动框架而不是调整其大小;键入 s以移动方框。当您对裁剪框的位置和大小感到满意时,键入RET实际裁剪框下的部分;或键入q退出而不裁剪。然后您可以使用i o或保存裁剪后的图像。 M-x image-save

Crop the image (image-crop). This command is available only if your system has an external program installed that can be used for cropping and cutting of images; the user option image-crop-crop-command determines what program to use, and defaults to the ImageMagick’s convert program. The command displays the image with a rectangular frame superimposed on it, and lets you use the mouse to move and resize the frame. Type m to cause mouse movements to move the frame instead of resizing it; type s to move a square frame instead. When you are satisfied with the position and size of the cropping frame, type RET to actually crop the part under the frame; or type q to exit without cropping. You can then save the cropped image using i o or M-x image-save.

i x
i x

从图像中剪切一个矩形 ( image-cut)。其工作原理与image-crop(并且还需要由变量 定义的外部程序image-crop-cut-command来执行图像剪切),但它不是裁剪图像,而是删除框架内的部分并使用 指定的颜色填充该部分 image-cut-color。使用前缀参数,该命令会提示要使用的颜色。

Cut a rectangle from the image (image-cut). This works the same as image-crop (and also requires an external program, defined by the variable image-crop-cut-command, to perform the image cut), but instead of cropping the image, it removes the part inside the frame and fills that part with the color specified by image-cut-color. With prefix argument, the command prompts for the color to use.

大小和旋转命令是“重复”的,这意味着您可以在不使用前缀的情况下继续调整图像i

The size and rotation commands are “repeating”, which means that you can continue adjusting the image without using the i prefix.

如果 Emacs 是在支持 ImageMagick 库的情况下编译的,则它可以使用 ImageMagick 渲染各种图像。该变量 imagemagick-enabled-types列出了 Emacs 可以使用 ImageMagick 渲染的图像类型;列表中的每个元素应该是图像类型的内部 ImageMagick 名称,作为符号或等效字符串(例如BMP.bmp图片)。要为所有可能的图像类型启用 ImageMagick,请更改 imagemagick-enabled-typest。该变量 imagemagick-types-inhibit列出了永远不应该使用 ImageMagick 呈现的图像类型,无论 的值如何 imagemagick-enabled-types(默认列表包括 C和等类型HTML,ImageMagick 可以将其呈现为图像,但 Emacs 不应该)。要完全禁用 ImageMagick,请更改 imagemagick-types-inhibitt.

If Emacs was compiled with support for the ImageMagick library, it can use ImageMagick to render a wide variety of images. The variable imagemagick-enabled-types lists the image types that Emacs may render using ImageMagick; each element in the list should be an internal ImageMagick name for an image type, as a symbol or an equivalent string (e.g., BMP for .bmp images). To enable ImageMagick for all possible image types, change imagemagick-enabled-types to t. The variable imagemagick-types-inhibit lists the image types which should never be rendered using ImageMagick, regardless of the value of imagemagick-enabled-types (the default list includes types like C and HTML, which ImageMagick can render as an image but Emacs should not). To disable ImageMagick entirely, change imagemagick-types-inhibit to t.

如果 Emacs 没有对相关图像格式的本机支持,并且image-use-external-converter是非nil,则 Emacs 将尝试确定是否存在可用于在显示之前将相关图像转换为PNG 的外部实用程序。目前支持GraphicsMagick、ImageMagickffmpeg进行图像转换。

If Emacs doesn’t have native support for the image format in question, and image-use-external-converter is non-nil, Emacs will try to determine whether there are external utilities that can be used to transform the image in question to PNG before displaying. GraphicsMagick, ImageMagick and ffmpeg are currently supported for image conversions.

此外,您可能希望为某些图像格式添加特殊处理程序。这些可以通过函数添加 image-converter-add-handler。例如,要允许将 Krita 文件作为简单图像查看,您可以这样说:

In addition, you may wish to add special handlers for certain image formats. These can be added with the image-converter-add-handler function. For instance, to allow viewing Krita files as simple images, you could say something like:

(图像转换器添加处理程序
 “克拉”
 (lambda(文件数据-p)
   (如果数据-p
       (错误“无法解码非文件”)
     (调用进程“解压缩”nil t nil
                   “-qq”“-c”“-x”文件“mergedimage.png”))))
(image-converter-add-handler
 "kra"
 (lambda (file data-p)
   (if data-p
       (error "Can't decode non-files")
     (call-process "unzip" nil t nil
                   "-qq" "-c" "-x" file "mergedimage.png"))))

该函数有两个参数,第一个是文件名后缀,第二个是执行“转换”的函数。该函数有两个参数,其中第一个是文件名或带有数据的字符串,第二个表示第一个参数是否是数据,并且应该 image-convert-to-format在当前缓冲区中以格式输出图像。

The function takes two parameters, where the first is a file name suffix, and the second is a function to do the “conversion”. This function takes two parameters, where the first is the file name or a string with the data, and the second says whether the first parameter is data or not, and should output an image in image-convert-to-format format in the current buffer.

Image-Dired 包还可用于以缩略图形式查看图像。请参阅在 Dired 中查看图像缩略图

The Image-Dired package can also be used to view images as thumbnails. See Viewing Image Thumbnails in Dired.


19.20 文件集

19.20 Filesets

如果您定期编辑某一组文件,则可以将它们定义为文件集。这使您可以query-replace一次对所有文件执行某些操作,例如访问、和 shell 命令。要使用文件集,您必须首先将表达式添加 (filesets-init)到 init 文件中(请参阅Emacs 初始化文件)。这增加了一个'文件集' 菜单栏的子菜单 '文件' 菜单。

If you regularly edit a certain group of files, you can define them as a fileset. This lets you perform certain operations, such as visiting, query-replace, and shell commands on all the files at once. To make use of filesets, you must first add the expression (filesets-init) to your init file (see The Emacs Initialization File). This adds a ‘Filesets’ sub-menu to the menu bar’s ‘File’ menu.

定义文件集的最简单方法是一次向其中添加一个文件。要将文件添加到文件集名称,请访问该文件并键入 。如果没有文件集名称,则会创建一个新文件集,该文件集最初仅包含当前文件。该命令从文件集中删除当前文件。 M-x filesets-add-buffer RET name RETM-x filesets-remove-buffer

The simplest way to define a fileset is by adding files to it one at a time. To add a file to fileset name, visit the file and type M-x filesets-add-buffer RET name RET. If there is no fileset name, this creates a new one, which initially contains only the current file. The command M-x filesets-remove-buffer removes the current file from a fileset.

您还可以直接编辑文件集列表,使用M-x filesets-edit(或选择“编辑文件集' 来自 '文件集' 菜单)。编辑是在自定义缓冲区中执行的(请参阅轻松自定义界面)。通常,文件集是简单的文件列表,但您也可以将文件集定义为匹配文件名的正则表达式。自定义缓冲区中显示了这些更复杂的文件集的一些示例。记得选择'保存以备将来使用' 如果您想在将来的 Emacs 会话中使用相同的文件集。

You can also edit the list of filesets directly, with M-x filesets-edit (or by choosing ‘Edit Filesets’ from the ‘Filesets’ menu). The editing is performed in a Customize buffer (see Easy Customization Interface). Normally, a fileset is a simple list of files, but you can also define a fileset as a regular expression matching file names. Some examples of these more complicated filesets are shown in the Customize buffer. Remember to select ‘Save for future sessions’ if you want to use the same filesets in future Emacs sessions.

您可以使用该命令M-x filesets-open访问文件集中的所有文件并M-x filesets-close关闭它们。用于 M-x filesets-run-cmd对文件集中的所有文件运行 shell 命令。这些命令也可以从 '文件集' 菜单,其中每个现有文件集都由一个子菜单表示。

You can use the command M-x filesets-open to visit all the files in a fileset, and M-x filesets-close to close them. Use M-x filesets-run-cmd to run a shell command on all the files in a fileset. These commands are also available from the ‘Filesets’ menu, where each existing fileset is represented by a submenu.

请参阅版本控制,了解文件集的不同概念:捆绑在一起进行版本控制操作的文件组。该类型的文件集是未命名的,并且不会在 Emacs 会话中持续存在。

See Version Control, for a different concept of filesets: groups of files bundled together for version control operations. Filesets of that type are unnamed, and do not persist across Emacs sessions.


20 使用多个缓冲区

20 Using Multiple Buffers

您在 Emacs 中编辑的文本驻留在称为 缓冲区的对象中。每次访问文件时,都会使用缓冲区来保存文件的文本。每次调用 Dired 时,都会使用一个缓冲区来保存目录列表。如果您使用 发送消息C-x m,则将使用缓冲区来保存消息的文本。当您请求命令的文档时,该文档会出现在名为的缓冲区中*帮助*

The text you are editing in Emacs resides in an object called a buffer. Each time you visit a file, a buffer is used to hold the file’s text. Each time you invoke Dired, a buffer is used to hold the directory listing. If you send a message with C-x m, a buffer is used to hold the text of the message. When you ask for a command’s documentation, that appears in a buffer named *Help*.

缓冲区只要在使用中就存在,并且在不再需要时被您(请参阅杀死缓冲区)或 Emacs(例如,当您退出 Emacs 时,请参阅退出 Emacs)删除(“杀死”)。

Buffers exist as long as they are in use, and are deleted (“killed”) when no longer needed, either by you (see Killing Buffers) or by Emacs (e.g., when you exit Emacs, see Exiting Emacs).

每个缓冲区都有一个唯一的名称,该名称可以是任意长度。当缓冲区显示在窗口中时,其名称显示在模式行中(请参阅模式行)。缓冲区名称中大小写的区别很重要。大多数缓冲区是通过访问文件创建的,并且它们的名称源自文件的名称;但是,您也可以使用任何您想要的名称创建一个空缓冲区。新启动的 Emacs 有多个缓冲区,其中一个名为*划痕*,它可用于计算 Lisp 表达式,并且不与任何文件关联(请参阅Lisp Interaction Buffers)。

Each buffer has a unique name, which can be of any length. When a buffer is displayed in a window, its name is shown in the mode line (see The Mode Line). The distinction between upper and lower case matters in buffer names. Most buffers are made by visiting files, and their names are derived from the files’ names; however, you can also create an empty buffer with any name you want. A newly started Emacs has several buffers, including one named *scratch*, which can be used for evaluating Lisp expressions and is not associated with any file (see Lisp Interaction Buffers).

任一时刻,只能选择一个缓冲区;我们称之为当前缓冲区。我们有时会说命令在“缓冲区”上运行;这实际上意味着它在当前缓冲区上运行。当只有一个 Emacs 窗口时,该窗口中显示的缓冲区是当前的。当有多个窗口时,所选窗口中显示的缓冲区为当前缓冲区。请参阅多个窗口

At any time, one and only one buffer is selected; we call it the current buffer. We sometimes say that a command operates on “the buffer”; this really means that it operates on the current buffer. When there is only one Emacs window, the buffer displayed in that window is current. When there are multiple windows, the buffer displayed in the selected window is current. See Multiple Windows.

缓冲区的内容由一系列字符组成,每个字符都可以选择携带一组文本属性(请参阅文本属性),这些属性可以指定有关该字符的更多信息。

A buffer’s contents consist of a series of characters, each of which optionally carries a set of text properties (see Text properties) that can specify more information about that character.

除了文本内容之外,每个缓冲区还记录几条信息,例如它正在访问什么文件(如果有)、是否被修改以及有效的主要模式和次要模式(请参阅主要和次要模式)。它们存储在缓冲区局部变量中——每个缓冲区中可以有不同值的变量。请参阅局部变量

Aside from its textual contents, each buffer records several pieces of information, such as what file it is visiting (if any), whether it is modified, and what major mode and minor modes are in effect (see Major and Minor Modes). These are stored in buffer-local variables—variables that can have a different value in each buffer. See Local Variables.

缓冲区的大小不能大于某个最大值,该最大值由Emacs 整数表示的最大缓冲区位置定义。这是因为 Emacs 使用该数据类型跟踪缓冲区位置。对于典型的 64 位计算机,此最大缓冲区大小为2^{61} - 2 字节,或大约 2 EiB。对于典型的 32 位计算机,最大值通常为2^{29} - 2字节,或大约 512 MiB。缓冲区大小还受到系统内存量的限制。

A buffer’s size cannot be larger than some maximum, which is defined by the largest buffer position representable by Emacs integers. This is because Emacs tracks buffer positions using that data type. For typical 64-bit machines, this maximum buffer size is 2^{61} - 2 bytes, or about 2 EiB. For typical 32-bit machines, the maximum is usually 2^{29} - 2 bytes, or about 512 MiB. Buffer sizes are also limited by the amount of memory in the system.


20.1 创建和选择缓冲区

20.1 Creating and Selecting Buffers

C-x b buffer RET
C-x b buffer RET

选择或创建一个名为buffer ( switch-to-buffer) 的缓冲区。

Select or create a buffer named buffer (switch-to-buffer).

C-x 4 b buffer RET
C-x 4 b buffer RET

类似,但在另一个窗口中选择缓冲区switch-to-buffer-other-window( )。

Similar, but select buffer in another window (switch-to-buffer-other-window).

C-x 5 b buffer RET
C-x 5 b buffer RET

类似,但在单独的帧中选择缓冲区switch-to-buffer-other-frame( )。

Similar, but select buffer in a separate frame (switch-to-buffer-other-frame).

C-x LEFT
C-x LEFT

选择缓冲区列表中的前一个缓冲区 ( previous-buffer)。

Select the previous buffer in the buffer list (previous-buffer).

C-x RIGHT
C-x RIGHT

选择缓冲区列表中的下一个缓冲区 ( next-buffer)。

Select the next buffer in the buffer list (next-buffer).

C-u M-g M-g
C-u M-g M-g
C-u M-g g
C-u M-g g

读取数字n并移动到另一个窗口中除当前缓冲区之外的最近选择的缓冲区中的 第n行。

Read a number n and move to line n in the most recently selected buffer other than the current buffer, in another window.

C-x b( )命令switch-to-buffer使用迷你缓冲区读取缓冲区名称。然后它使该缓冲区成为当前缓冲区,并将其显示在当前选定的窗口中。空输入指定当前未在任何窗口中显示的缓冲区中最近的缓冲区。

The C-x b (switch-to-buffer) command reads a buffer name using the minibuffer. Then it makes that buffer current, and displays it in the currently-selected window. An empty input specifies the buffer that was current most recently among those not now displayed in any window.

输入缓冲区名称时,您可以使用常用的完成和历史命令(请参阅迷你缓冲区)。请注意C-x b,以及相关命令,请使用允许完成并确认RET迷你缓冲区完成:如果您在迷你缓冲区文本命名一个不存在的缓冲区时 键入,Emacs 会打印 '[确认]' 并且您必须输入第二个字符RET才能提交该缓冲区名称。有关详细信息,请参阅完成退出。有关其他完成选项和功能,请参阅完成选项

While entering the buffer name, you can use the usual completion and history commands (see The Minibuffer). Note that C-x b, and related commands, use permissive completion with confirmation for minibuffer completion: if you type RET when the minibuffer text names a nonexistent buffer, Emacs prints ‘[Confirm]’ and you must type a second RET to submit that buffer name. See Completion Exit, for details. For other completion options and features, see Completion Options.

如果指定的缓冲区不存在,则C-x b创建一个不访问任何文件的新的空缓冲区,并选择它进行编辑。变量的默认值major-mode 决定了新缓冲区的主要模式;默认值为基本模式。请参阅主要模式。创建新缓冲区的原因之一是用它来制作临时笔记。如果您尝试保存它,Emacs 会询问要使用的文件名,并且会考虑该文件名来重新建立缓冲区的主要模式(请参阅选择文件模式)。

If you specify a buffer that does not exist, C-x b creates a new, empty buffer that is not visiting any file, and selects it for editing. The default value of the variable major-mode determines the new buffer’s major mode; the default value is Fundamental mode. See Major Modes. One reason to create a new buffer is to use it for making temporary notes. If you try to save it, Emacs asks for the file name to use, and the buffer’s major mode is re-established taking that file name into account (see Choosing File Modes).

为了方便地在几个缓冲区之间切换,请使用命令 和。 ( ) 选择前一个缓冲区(按照当前帧中最近选择的顺序),而( ) 以相反方向在缓冲区中移动。这两个命令都支持用作重复计数的数字前缀参数。 C-x LEFTC-x RIGHTC-x LEFTprevious-bufferC-x RIGHTnext-buffer

For conveniently switching between a few buffers, use the commands C-x LEFT and C-x RIGHT. C-x LEFT (previous-buffer) selects the previous buffer (following the order of most recent selection in the current frame), while C-x RIGHT (next-buffer) moves through buffers in the reverse direction. Both commands support a numeric prefix argument that serves as a repeat count.

要在当前窗口以外的窗口中选择缓冲区(请参阅多个窗口),请键入C-x 4 b ( switch-to-buffer-other-window)。这会提示使用迷你缓冲区输入缓冲区名称,在另一个窗口中显示该缓冲区,然后选择该窗口。

To select a buffer in a window other than the current one (see Multiple Windows), type C-x 4 b (switch-to-buffer-other-window). This prompts for a buffer name using the minibuffer, displays that buffer in another window, and selects that window.

类似地,C-x 5 b( switch-to-buffer-other-frame) 提示输入缓冲区名称,在另一个帧中显示该缓冲区(请参阅帧和图形显示),然后选择该帧。如果缓冲区已显示在另一个框架上的窗口中,则 Emacs 会选择该窗口和框架,而不是创建新框架。

Similarly, C-x 5 b (switch-to-buffer-other-frame) prompts for a buffer name, displays that buffer in another frame (see Frames and Graphical Displays), and selects that frame. If the buffer is already being shown in a window on another frame, Emacs selects that window and frame instead of creating a new frame.

请参阅在窗口中显示缓冲区,了解C-x 4 bC-x 5 b命令如何获取要显示的窗口和/或框架。

See Displaying a Buffer in a Window, for how the C-x 4 b and C-x 5 b commands get the window and/or frame to display in.

此外,C-x C-f和任何其他用于访问文件的命令也可用于切换到现有的文件访问缓冲区。请参阅访问文件

In addition, C-x C-f, and any other command for visiting a file, can also be used to switch to an existing file-visiting buffer. See Visiting Files.

C-u M-g M-g,即goto-line使用普通前缀参数,使用迷你缓冲区读取数字n ,选择另一个窗口中除当前缓冲区之外的最近选择的缓冲区,然后将指针移动到 该缓冲区中第n行的开头。这在引用另一个缓冲区中的行号的缓冲区中主要有用:如果 point 位于数字上或紧随数字之后, 则使用该数字作为ngoto-line的默认值。请注意,前缀参数的行为不只是不同。 转到当前缓冲区中的第 4 行,而不从迷你缓冲区中读取数字。 (请记住,如果没有前缀参数,则读取数字n ,然后移动到当前缓冲区中的行号n 。请参阅更改 Point 的位置。) C-uC-u 4 M-g M-gM-g M-g

C-u M-g M-g, that is goto-line with a plain prefix argument, reads a number n using the minibuffer, selects the most recently selected buffer other than the current buffer in another window, and then moves point to the beginning of line number n in that buffer. This is mainly useful in a buffer that refers to line numbers in another buffer: if point is on or just after a number, goto-line uses that number as the default for n. Note that prefix arguments other than just C-u behave differently. C-u 4 M-g M-g goes to line 4 in the current buffer, without reading a number from the minibuffer. (Remember that M-g M-g without prefix argument reads a number n and then moves to line number n in the current buffer. See Changing the Location of Point.)

Emacs 使用以空格开头的缓冲区名称用于内部目的。它以较小的方式特殊对待这些缓冲区 - 例如,默认情况下它们不记录撤消信息。最好避免自己使用此类缓冲区名称。

Emacs uses buffer names that start with a space for internal purposes. It treats these buffers specially in minor ways—for example, by default they do not record undo information. It is best to avoid using such buffer names yourself.


20.2 列出现有缓冲区

20.2 Listing Existing Buffers

C-x C-b
C-x C-b

列出现有缓冲区 ( list-buffers)。

List the existing buffers (list-buffers).

要显示现有缓冲区的列表,请键入C-x C-b。这会在名为的缓冲区中弹出一个缓冲区菜单*缓冲区列表*。列表中的每一行显示一个缓冲区的名称、大小、主要模式和访问的文件。缓冲区按照当前的顺序列出;最近的缓冲区排在第一位。本节描述缓冲区列表如何显示以及如何解释列表中的各种指示;有关特殊模式的说明,请参阅对多个缓冲区进行操作*缓冲区列表*缓冲区和那里可用的命令。

To display a list of existing buffers, type C-x C-b. This pops up a buffer menu in a buffer named *Buffer List*. Each line in the list shows one buffer’s name, size, major mode and visited file. The buffers are listed in the order that they were current; the buffers that were current most recently come first. This section describes how the list of buffers is displayed and how to interpret the various indications in the list; see Operating on Several Buffers, for description of the special mode in the *Buffer List* buffer and the commands available there.

'行的第一个字段中的 ' 表示缓冲区是当前的。 '%' 表示只读缓冲区。 '*' 表示缓冲区已修改。如果修改了多个缓冲区,则可能需要保存一些缓冲区C-x s(请参阅保存文件的命令)。这是缓冲区列表的示例:

.’ in the first field of a line indicates that the buffer is current. ‘%’ indicates a read-only buffer. ‘*’ indicates that the buffer is modified. If several buffers are modified, it may be time to save some with C-x s (see Commands for Saving Files). Here is an example of a buffer list:

CRM 缓冲区大小模式文件
。 * .emacs 3294 Emacs-Lisp ~/.emacs
 % *帮助* 101 帮助
    搜索.c 86055 C ~/cvs/emacs/src/search.c
 % src 20959 按名称定向 ~/cvs/emacs/src/
  * *邮件* 42 邮件
 % HELLO 1607 基础 ~/cvs/emacs/etc/HELLO
 % NEWS 481184 大纲 ~/cvs/emacs/etc/NEWS
    *scratch* 191 Lisp 交互
  * *消息* 1554 条消息
CRM Buffer                Size  Mode              File
. * .emacs                3294  Emacs-Lisp        ~/.emacs
 %  *Help*                 101  Help
    search.c             86055  C                 ~/cvs/emacs/src/search.c
 %  src                  20959  Dired by name     ~/cvs/emacs/src/
  * *mail*                  42  Mail
 %  HELLO                 1607  Fundamental       ~/cvs/emacs/etc/HELLO
 %  NEWS                481184  Outline           ~/cvs/emacs/etc/NEWS
    *scratch*              191  Lisp Interaction
  * *Messages*            1554  Messages

缓冲器*帮助*由帮助请求提出(请参阅帮助);它没有访问任何文件。缓冲区src是由 Dired 在目录上创建的〜/ cvs / emacs / src /。您可以通过为命令提供前缀参数来仅列出正在访问文件的缓冲区,如 中所示 C-u C-x C-b

The buffer *Help* was made by a help request (see Help); it is not visiting any file. The buffer src was made by Dired on the directory ~/cvs/emacs/src/. You can list only buffers that are visiting files by giving the command a prefix argument, as in C-u C-x C-b.

list-buffers省略名称以空格开头的缓冲区,除非它们访问文件:此类缓冲区由 Emacs 内部使用。

list-buffers omits buffers whose names begin with a space, unless they visit files: such buffers are used internally by Emacs.


20.3 其他缓冲区操作

20.3 Miscellaneous Buffer Operations

C-x C-q
C-x C-q

切换缓冲区的只读状态 ( read-only-mode)。

Toggle read-only status of buffer (read-only-mode).

C-x x r RET buffer RET
C-x x r RET buffer RET

更改当前缓冲区的名称。

Change the name of the current buffer.

C-x x u
C-x x u

通过添加 ' 重命名当前缓冲区<数字>' 到最后。

Rename the current buffer by adding ‘<number>’ to the end.

M-x view-buffer RET buffer RET
M-x view-buffer RET buffer RET

滚动浏览缓冲区buffer。请参阅查看模式

Scroll through buffer buffer. See View Mode.

缓冲区可以是只读的,这意味着不允许插入或删除其文本的命令。 (但是,其他命令,例如 ,仍然可以将其标记为已修改,请参阅指定文件文本的编码系统)。模式行用 ' 指示只读缓冲区C-x RET f%%' 或者 '%*' 靠近左边距。请参阅模式行。只读缓冲区通常由 Dired 和 Rmail 等子系统创建,这些子系统具有对文本进行操作的特殊命令。访问访问控制表明您无法写入的文件也会使缓冲区变为只读。

A buffer can be read-only, which means that commands to insert or delete its text are not allowed. (However, other commands, like C-x RET f, can still mark it as modified, see Specifying a Coding System for File Text). The mode line indicates read-only buffers with ‘%%’ or ‘%*’ near the left margin. See The Mode Line. Read-only buffers are usually made by subsystems such as Dired and Rmail that have special commands to operate on the text. Visiting a file whose access control says you cannot write it also makes the buffer read-only.

命令C-x C-q( read-only-mode) 使只读缓冲区可写,并使可写缓冲区变为只读。这是通过设置变量 来实现的buffer-read-only,该变量在每个缓冲区中都有一个本地值,如果其值为非值,则该缓冲区将变为只读nil。如果将该选项更改view-read-only为非值nil,则将缓冲区设置为只读,同时C-x C-q 也会在缓冲区中启用“查看模式”(请参阅​​“查看模式”)。

The command C-x C-q (read-only-mode) makes a read-only buffer writable, and makes a writable buffer read-only. This works by setting the variable buffer-read-only, which has a local value in each buffer and makes the buffer read-only if its value is non-nil. If you change the option view-read-only to a non-nil value, making the buffer read-only with C-x C-q also enables View mode in the buffer (see View Mode).

C-x x r(rename-buffer更改当前缓冲区的名称。您将新名称指定为迷你缓冲区参数;没有默认值。如果您指定的名称已用于其他缓冲区,则会发生错误并且不会进行重命名。

C-x x r (rename-buffer changes the name of the current buffer. You specify the new name as a minibuffer argument; there is no default. If you specify a name that is in use for some other buffer, an error happens and no renaming is done.

C-x x u( rename-uniquely) 将当前缓冲区重命名为类似的名称,并添加数字后缀以使其既不同又唯一。该命令不需要参数。它对于创建多个 shell 缓冲区很有用:如果您重命名*壳* buffer,然后再做M-x shell一次,它会创建一个名为的新 shell 缓冲区*壳*;同时,旧的 shell 缓冲区继续以新名称存在。此方法也适用于邮件缓冲区、编译缓冲区和大多数使用特定名称创建特殊缓冲区的 Emacs 功能。 (对于其中一些功能,例如 M-x compile, M-x grep,您需要在再次使用该命令之前切换到其他缓冲区,否则尽管名称更改,它仍将重用当前缓冲区。)

C-x x u (rename-uniquely) renames the current buffer to a similar name with a numeric suffix added to make it both different and unique. This command does not need an argument. It is useful for creating multiple shell buffers: if you rename the *shell* buffer, then do M-x shell again, it makes a new shell buffer named *shell*; meanwhile, the old shell buffer continues to exist under its new name. This method is also good for mail buffers, compilation buffers, and most Emacs features that create special buffers with particular names. (With some of these features, such as M-x compile, M-x grep, you need to switch to some other buffer before using the command again, otherwise it will reuse the current buffer despite the name change.)

命令M-x append-to-bufferC-x x i ( insert-buffer) 还可用于将文本从一个缓冲区复制到另一个缓冲区。请参阅累积文本

The commands M-x append-to-buffer and C-x x i (insert-buffer) can also be used to copy text from one buffer to another. See Accumulating Text.


20.4 终止缓冲区

20.4 Killing Buffers

如果您继续 Emacs 会话一段时间,可能会积累大量缓冲区。然后您可能会发现杀死 不再需要的缓冲区很方便。 (其他一些编辑器将此操作称为close,并谈论“关闭缓冲区”或“关闭缓冲区中访问的文件”。)在大多数操作系统上,终止缓冲区会将用于缓冲区的内存 Emacs 释放回操作系统以便其他程序可以使用它。以下是一些用于终止缓冲区的命令:

If you continue an Emacs session for a while, you may accumulate a large number of buffers. You may then find it convenient to kill the buffers you no longer need. (Some other editors call this operation close, and talk about “closing the buffer” or “closing the file” visited in the buffer.) On most operating systems, killing a buffer releases the memory Emacs used for the buffer back to the operating system so that other programs can use it. Here are some commands for killing buffers:

C-x k buffer RET
C-x k buffer RET

杀死缓冲区缓冲区( kill-buffer)。

Kill buffer buffer (kill-buffer).

M-x kill-some-buffers
M-x kill-some-buffers

提议一个一个地杀死每个缓冲区。

Offer to kill each buffer, one by one.

M-x kill-matching-buffers
M-x kill-matching-buffers

提议杀死与正则表达式匹配的所有缓冲区。

Offer to kill all buffers matching a regular expression.

C-x k( kill-buffer) 终止一个缓冲区,其名称是您在迷你缓冲区中指定的。如果您仅在迷你缓冲区中键入,则使用默认值 RET来终止当前缓冲区。如果您终止当前缓冲区,则另一个缓冲区将成为当前缓冲区:最近一段时间是当前缓冲区,但现在不再显示在任何窗口中。如果您要求终止已修改的文件访问缓冲区,则必须在yes终止缓冲区之前进行确认。

C-x k (kill-buffer) kills one buffer, whose name you specify in the minibuffer. The default, used if you type just RET in the minibuffer, is to kill the current buffer. If you kill the current buffer, another buffer becomes current: one that was current in the recent past but is not displayed in any window now. If you ask to kill a file-visiting buffer that is modified, then you must confirm with yes before the buffer is killed.

该命令M-x kill-some-buffers逐一询问每个缓冲区。的答案yes意味着杀死缓冲区,就像 kill-buffer.此命令忽略名称以空格开头的缓冲区,这些缓冲区由 Emacs 内部使用。

The command M-x kill-some-buffers asks about each buffer, one by one. An answer of yes means to kill the buffer, just like kill-buffer. This command ignores buffers whose names begin with a space, which are used internally by Emacs.

该命令M-x kill-matching-buffers提示输入正则表达式并杀死名称与该表达式匹配的所有缓冲区。请参阅正则表达式的语法。就像kill-some-buffers,它在每次击杀之前都会要求确认。该命令通常会忽略名称以空格开头的缓冲区,这些缓冲区由 Emacs 内部使用。要同时终止内部缓冲区,请kill-matching-buffers 使用前缀参数进行调用。

The command M-x kill-matching-buffers prompts for a regular expression and kills all buffers whose names match that expression. See Syntax of Regular Expressions. Like kill-some-buffers, it asks for confirmation before each kill. This command normally ignores buffers whose names begin with a space, which are used internally by Emacs. To kill internal buffers as well, call kill-matching-buffers with a prefix argument.

缓冲区菜单功能也可以方便地杀死各种缓冲区。请参阅对多个缓冲区进行操作

The Buffer Menu feature is also convenient for killing various buffers. See Operating on Several Buffers.

如果您想在每次杀死缓冲区时执行一些特殊操作,您可以向钩子添加钩子函数kill-buffer-hook(请参阅Hooks)。

If you want to do something special every time a buffer is killed, you can add hook functions to the hook kill-buffer-hook (see Hooks).

如果您像许多人一样运行一个 Emacs 会话一段时间,它可能会填满您几天前使用过的缓冲区。该命令 M-x clean-buffer-list是清除它们的便捷方法;它会杀死您很长时间没有使用的所有未修改的缓冲区。一个普通的缓冲区如果三天没有显示就会被杀死;但是,您可以指定某些缓冲区永远不应该被自动终止,而其他缓冲区如果仅一个小时未使用就应该被终止。这些默认值以及此命令行为的其他方面可以通过自定义clean-buffer-list.

If you run one Emacs session for a period of days, as many people do, it can fill up with buffers that you used several days ago. The command M-x clean-buffer-list is a convenient way to purge them; it kills all the unmodified buffers that you have not used for a long time. An ordinary buffer is killed if it has not been displayed for three days; however, you can specify certain buffers that should never be killed automatically, and others that should be killed if they have been unused for a mere hour. These defaults, and other aspects of this command’s behavior, can be controlled by customizing several options described in the doc string of clean-buffer-list.

您还可以通过启用午夜模式,每天一次为您完成缓冲区清除。午夜模式每天午夜运行;那时,它会运行clean-buffer-list,或者您放置在普通钩子中的任何函数 midnight-hook(请参阅Hooks)。要启用午夜模式,请使用自定义缓冲区将变量设置midnight-modet。请参阅简易定制界面

You can also have this buffer purging done for you, once a day, by enabling Midnight mode. Midnight mode operates each day at midnight; at that time, it runs clean-buffer-list, or whichever functions you have placed in the normal hook midnight-hook (see Hooks). To enable Midnight mode, use the Customization buffer to set the variable midnight-mode to t. See Easy Customization Interface.


20.5 对多个缓冲区进行操作

20.5 Operating on Several Buffers

M-x buffer-menu
M-x buffer-menu

开始编辑列出所有 Emacs 缓冲区的缓冲区。

Begin editing a buffer listing all Emacs buffers.

M-x buffer-menu-other-window
M-x buffer-menu-other-window

类似,但在另一个窗口中执行。

Similar, but do it in another window.

通过(参见列出现有缓冲区)打开的缓冲区菜单不仅仅列出缓冲区。它还允许您通过类似于 Dired 的界面对缓冲区执行各种操作(请参阅Dired,目录编辑器)。您可以保存缓冲区、杀死它们(这里称为 删除它们,以与 Dired 保持一致)或显示它们。 C-x C-b

The Buffer Menu opened by C-x C-b (see Listing Existing Buffers) does not merely list buffers. It also allows you to perform various operations on buffers, through an interface similar to Dired (see Dired, the Directory Editor). You can save buffers, kill them (here called deleting them, for consistency with Dired), or display them.

要使用缓冲区菜单,请键入C-x C-b并切换到显示缓冲区菜单的窗口*缓冲区列表*缓冲。您还可以键入 M-x buffer-menu以在所选窗口中打开缓冲区菜单。或者,该命令M-x buffer-menu-other-window在另一个窗口中打开缓冲区菜单,并选择该窗口。

To use the Buffer Menu, type C-x C-b and switch to the window displaying the *Buffer List* buffer. You can also type M-x buffer-menu to open the Buffer Menu in the selected window. Alternatively, the command M-x buffer-menu-other-window opens the Buffer Menu in another window, and selects that window.

缓冲区菜单是只读缓冲区,只能通过本节中描述的特殊命令进行更改。可以在此缓冲区中使用常用的光标移动命令。以下命令适用于当前行描述的缓冲区:

The Buffer Menu is a read-only buffer, and can be changed only through the special commands described in this section. The usual cursor motion commands can be used in this buffer. The following commands apply to the buffer described on the current line:

d
d

将缓冲区标记为删除(终止),然后将指针移动到下一行 ( Buffer-menu-delete)。删除标志由字符'表示D' 位于该行缓冲区名称之前。仅当您键入命令时才会发生删除x(见下文)。

Flag the buffer for deletion (killing), then move point to the next line (Buffer-menu-delete). The deletion flag is indicated by the character ‘D’ on the line, before the buffer name. The deletion occurs only when you type the x command (see below).

C-d
C-d

与 类似d,但将点向上移动而不是向下移动 ( Buffer-menu-delete-backwards)。

Like d, but move point up instead of down (Buffer-menu-delete-backwards).

s
s

将缓冲区标记为保存 ( Buffer-menu-save)。保存标志由字符 ' 表示S' 位于该行缓冲区名称之前。仅当您键入 时才会进行保存x。您可以请求对同一缓冲区进行保存和删除。

Flag the buffer for saving (Buffer-menu-save). The save flag is indicated by the character ‘S’ on the line, before the buffer name. The saving occurs only when you type x. You may request both saving and deletion for the same buffer.

x
x

执行所有标记的删除并保存 ( Buffer-menu-execute)。

Perform all flagged deletions and saves (Buffer-menu-execute).

u
u

删除当前行中的所有标志,然后向下移动 ( Buffer-menu-unmark)。使用前缀参数,在删除标志后向上移动。

Remove all flags from the current line, and move down (Buffer-menu-unmark). With a prefix argument, moves up after removing the flags.

DEL
DEL

移至上一行并删除该行上的所有标志 ( Buffer-menu-backup-unmark)。

Move to the previous line and remove all flags on that line (Buffer-menu-backup-unmark).

M-DEL
M-DEL

从所有行中删除特定标志 ( Buffer-menu-unmark-all-buffers)。这要求单个字符,并取消标记用该字符标记的缓冲区;打字 RET会删除所有标记。

Remove a particular flag from all lines (Buffer-menu-unmark-all-buffers). This asks for a single character, and unmarks buffers marked with that character; typing RET removes all marks.

U
U

删除所有行 ( Buffer-menu-unmark-all) 中的所有标志。

Remove all flags from all the lines (Buffer-menu-unmark-all).

用于删除标志的命令dC-d接受数字参数作为重复计数。

The commands for removing flags, d and C-d, accept a numeric argument as a repeat count.

以下命令立即对当前行列出的缓冲区进行操作。它们还接受数字参数作为重复计数。

The following commands operate immediately on the buffer listed on the current line. They also accept a numeric argument as a repeat count.

~
~

将缓冲区标记为未修改 ( Buffer-menu-not-modified)。请参阅保存文件的命令

Mark the buffer as unmodified (Buffer-menu-not-modified). See Commands for Saving Files.

%
%

切换缓冲区的只读状态 ( Buffer-menu-toggle-read-only)。请参阅其他缓冲区操作

Toggle the buffer’s read-only status (Buffer-menu-toggle-read-only). See Miscellaneous Buffer Operations.

t
t

将缓冲区作为标签表进行访问 ( Buffer-menu-visit-tags-table)。请参阅选择标签表

Visit the buffer as a tags table (Buffer-menu-visit-tags-table). See Selecting a Tags Table.

以下命令用于选择另一个或多个缓冲区:

The following commands are used to select another buffer or buffers:

q
q

退出缓冲区菜单 ( quit-window)。最近的以前可见的缓冲区将显示在其位置。

Quit the Buffer Menu (quit-window). The most recent formerly visible buffer is displayed in its place.

RET
RET
f
f

选择该行的缓冲区,替换*缓冲区列表*缓冲区位于其窗口 ( Buffer-menu-this-window) 中。

Select this line’s buffer, replacing the *Buffer List* buffer in its window (Buffer-menu-this-window).

o
o

在另一个窗口中选择该行的缓冲区,就像通过C-x 4 b,离开*缓冲区列表*可见的 (Buffer-menu-other-window)。

Select this line’s buffer in another window, as if by C-x 4 b, leaving *Buffer List* visible (Buffer-menu-other-window).

C-o
C-o

在另一个窗口中显示该行的缓冲区,而不选择它 ( Buffer-menu-switch-other-window)。

Display this line’s buffer in another window, without selecting it (Buffer-menu-switch-other-window).

1
1

在全帧窗口 ( Buffer-menu-1-window) 中选择该行的缓冲区。

Select this line’s buffer in a full-frame window (Buffer-menu-1-window).

2
2

在当前帧上设置两个窗口,其中选择该行的缓冲区,以及先前的当前缓冲区(除了 *缓冲区列表*)在另一个(Buffer-menu-2-window)中。

Set up two windows on the current frame, with this line’s buffer selected in one, and a previously current buffer (aside from *Buffer List*) in the other (Buffer-menu-2-window).

b
b

埋葬该行的缓冲区 ( Buffer-menu-bury)(即,将其移动到缓冲区列表的末尾)。

Bury this line’s buffer (Buffer-menu-bury) (i.e., move it to the end of the buffer list).

m
m

v如果使用命令 ( )退出,则将此行的缓冲区标记为显示在另一个窗口中Buffer-menu-mark。显示标志由字符 ' 表示>' 在该行的开头。 (单个缓冲区可能无法同时具有删除和显示标志。)

Mark this line’s buffer to be displayed in another window if you exit with the v command (Buffer-menu-mark). The display flag is indicated by the character ‘>’ at the beginning of the line. (A single buffer may not have both deletion and display flags.)

v
v

选择该行的缓冲区,并在其他窗口中显示用命令m( Buffer-menu-select) 标记的任何缓冲区。如果您没有标记任何缓冲区,则此命令相当于 1.

Select this line’s buffer, and also display in other windows any buffers flagged with the m command (Buffer-menu-select). If you have not flagged any buffers, this command is equivalent to 1.

以下命令影响整个缓冲区列表:

The following commands affect the entire buffer list:

S
S

根据当前列中的值对缓冲区菜单条目进行排序。使用数字前缀参数n,根据第n列 ( tabulated-list-sort) 进行排序。

Sort the Buffer Menu entries according to their values in the column at point. With a numeric prefix argument n, sort according to the n-th column (tabulated-list-sort).

}
}

将当前列宽加宽n(前缀数字参数)个字符。

Widen the current column width by n (the prefix numeric argument) characters.

{
{

将当前列宽缩小n(前缀数字参数)个字符。

Narrow the current column width by n (the prefix numeric argument) characters.

T
T

删除或重新插入非文件缓冲区的行 ( Buffer-menu-toggle-files-only)。此命令切换缓冲区列表中此类缓冲区的包含情况。

Delete, or reinsert, lines for non-file buffers (Buffer-menu-toggle-files-only). This command toggles the inclusion of such buffers in the buffer list.

通常情况下,缓冲区*缓冲区列表*创建和终止缓冲区时不会自动更新;它的内容只是文本。如果您创建、删除或重命名了缓冲区,更新的方式*缓冲区列表*要显示您已完成的操作,请键入 g( revert-buffer)。auto-revert-interval如果您在此缓冲区中启用自动恢复模式,只要它没有标记为已修改,您就可以每秒定期发生一次。全局自动恢复模式适用于*缓冲区列表*global-auto-revert-non-file-buffers仅当非 时才缓冲 nil。有关详细信息, 请参阅global-auto-revert-non-file-buffers 。

Normally, the buffer *Buffer List* is not updated automatically when buffers are created and killed; its contents are just text. If you have created, deleted or renamed buffers, the way to update *Buffer List* to show what you have done is to type g (revert-buffer). You can make this happen regularly every auto-revert-interval seconds if you enable Auto Revert mode in this buffer, as long as it is not marked modified. Global Auto Revert mode applies to the *Buffer List* buffer only if global-auto-revert-non-file-buffers is non-nil. See global-auto-revert-non-file-buffers, for details.


20.6 间接缓冲区

20.6 Indirect Buffers

间接缓冲区共享其他缓冲区的文本,这些缓冲区称为间接缓冲区的基本缓冲区。在某些方面,它是文件之间符号链接的缓冲区类似物。

An indirect buffer shares the text of some other buffer, which is called the base buffer of the indirect buffer. In some ways it is a buffer analogue of a symbolic link between files.

M-x make-indirect-buffer RET base-buffer RET indirect-name RET
M-x make-indirect-buffer RET base-buffer RET indirect-name RET

使用基本缓冲区 base-buffer创建名为invalid-name 的间接缓冲区。

Create an indirect buffer named indirect-name with base buffer base-buffer.

M-x clone-indirect-buffer RET
M-x clone-indirect-buffer RET

创建一个间接缓冲区,它是当前缓冲区的孪生副本。

Create an indirect buffer that is a twin copy of the current buffer.

C-x 4 c
C-x 4 c

创建一个间接缓冲区,它是当前缓冲区的孪生副本,并在另一个窗口 ( clone-indirect-buffer-other-window) 中选择它。

Create an indirect buffer that is a twin copy of the current buffer, and select it in another window (clone-indirect-buffer-other-window).

间接缓冲区的文本始终与其基本缓冲区的文本相同;通过编辑其中之一所做的更改会立即在另一个中可见。这里的“文本”包括字符及其文本属性。但在所有其他方面,间接缓冲区与其基础缓冲区是完全分开的。它们可以有不同的名称、不同的点值、不同的缩小范围、不同的标记、不同的覆盖、不同的主要模式和不同的局部变量。

The text of the indirect buffer is always identical to the text of its base buffer; changes made by editing either one are visible immediately in the other. “Text” here includes both the characters and their text properties. But in all other respects, the indirect buffer and its base buffer are completely separate. They can have different names, different values of point, different narrowing, different markers, different overlays, different major modes, and different local variables.

间接缓冲区无法访问文件,但其基本缓冲区可以。如果您尝试保存间接缓冲区,实际上是通过保存基本缓冲区来实现的。杀死基本缓冲区会有效地杀死间接缓冲区,但杀死间接缓冲区对其基本缓冲区没有影响。

An indirect buffer cannot visit a file, but its base buffer can. If you try to save the indirect buffer, that actually works by saving the base buffer. Killing the base buffer effectively kills the indirect buffer, but killing an indirect buffer has no effect on its base buffer.

使用间接缓冲区的一种方法是显示轮廓的多个视图。请参阅在多个视图中查看一个大纲

One way to use indirect buffers is to display multiple views of an outline. See Viewing One Outline in Multiple Views.

创建间接缓冲区的一种快速且方便的方法是使用命令 C-x 4 c( clone-indirect-buffer-other-window)。它创建并选择一个间接缓冲区,其基本缓冲区是当前缓冲区。使用数字参数时,它会提示输入间接缓冲区的名称;否则它使用当前缓冲区的名称,并带有 '<n>' 添加后缀。

A quick and handy way to make an indirect buffer is with the command C-x 4 c (clone-indirect-buffer-other-window). It creates and selects an indirect buffer whose base buffer is the current buffer. With a numeric argument, it prompts for the name of the indirect buffer; otherwise it uses the name of the current buffer, with a ‘<n>’ suffix added.

创建间接缓冲区的更通用方法是使用命令 M-x make-indirect-buffer。它从缓冲区base-buffer创建一个名为invalid-name的间接缓冲区,提示两者都使用迷你缓冲区。

The more general way to make an indirect buffer is with the command M-x make-indirect-buffer. It creates an indirect buffer named indirect-name from a buffer base-buffer, prompting for both using the minibuffer.

创建间接缓冲区的函数 clone-indirect-buffer-hook在创建间接缓冲区后运行挂钩。当这个钩子运行时,新创建的间接缓冲区是当前缓冲区。

The functions that create indirect buffers run the hook clone-indirect-buffer-hook after creating the indirect buffer. When this hook runs, the newly created indirect buffer is the current buffer.

注意:当对缓冲区的文本进行修改时,修改挂钩仅在基本缓冲区中运行,因为这些挂钩上的大多数函数尚未准备好在间接缓冲区中正常工作。因此,如果需要在间接缓冲区中修改钩子函数,则需要手动将该函数添加到 基础缓冲区中的钩子中,然后使该函数在所需的间接缓冲区中运行。

Note: When a modification is made to the text of a buffer, the modification hooks are run only in the base buffer, because most of the functions on those hooks are not prepared to work correctly in indirect buffers. So if you need a modification hook function in an indirect buffer, you need to manually add that function to the hook in the base buffer and then make the function operate in the desired indirect buffer.


20.7 缓冲区处理的便利特性和定制

20.7 Convenience Features and Customization of Buffer Handling

本节介绍了几种可以更方便地在缓冲区之间切换的模式和功能。

This section describes several modes and features that make it more convenient to switch between buffers.


20.7.1 使缓冲区名称唯一

20.7.1 Making Buffer Names Unique

当多个缓冲区访问同名文件时,Emacs 必须为缓冲区指定不同的名称。默认方法根据包含文件的目录名称添加后缀。例如,如果您访问文件/foo/bar/mumble/名称/baz/quux/mumble/名字同时,它们的缓冲区将被命名为'姓名<栏/咕哝>' 和 '姓名<quux/mumble>', 分别。 Emacs 添加所需数量的目录部分以形成唯一的名称。

When several buffers visit identically-named files, Emacs must give the buffers distinct names. The default method adds a suffix based on the names of the directories that contain the files. For example, if you visit files /foo/bar/mumble/name and /baz/quux/mumble/name at the same time, their buffers will be named ‘name<bar/mumble>’ and ‘name<quux/mumble>’, respectively. Emacs adds as many directory parts as are needed to make a unique name.

您可以通过自定义选项从几种不同的样式中进行选择来构造唯一的缓冲区名称uniquify-buffer-name-style

You can choose from several different styles for constructing unique buffer names, by customizing the option uniquify-buffer-name-style.

命名方法forward在缓冲区名称的开头包含文件目录名的一部分;使用此方法,缓冲访问文件/u/rms/tmp/Makefile/usr/projects/zaphod/Makefile将被命名为'临时文件/生成文件' 和 'zaphod/Makefile'。

The forward naming method includes part of the file’s directory name at the beginning of the buffer name; using this method, buffers visiting the files /u/rms/tmp/Makefile and /usr/projects/zaphod/Makefile would be named ‘tmp/Makefile’ and ‘zaphod/Makefile’.

相反,post-forward命名方法将调用缓冲区'生成文件|tmp' 和 'Makefile|zaphod'。默认方法post-forward-angle-brackets类似于post-forward,只不过它将唯一路径括在尖括号中。命名 reverse方法将调用它们'生成文件\tmp' 和 'Makefile\zaphod'。当只有一个目录名不足以区分两个文件时,post-forward和之间就会出现显着的差异 ;reverse然后reverse按相反的顺序放置目录名称,以便/顶部/中间/文件 变成'文件\中\顶部', whilepost-forward将它们按正向顺序放在文件名后面,如 '文件|顶部/中间'。如果 uniquify-buffer-name-style设置为nil,则缓冲区名称只需获取 '<2>','<3>'等附加。

In contrast, the post-forward naming method would call the buffers ‘Makefile|tmp’ and ‘Makefile|zaphod’. The default method post-forward-angle-brackets is like post-forward, except that it encloses the unique path in angle brackets. The reverse naming method would call them ‘Makefile\tmp’ and ‘Makefile\zaphod’. The nontrivial difference between post-forward and reverse occurs when just one directory name is not enough to distinguish two files; then reverse puts the directory names in reverse order, so that /top/middle/file becomes ‘file\middle\top’, while post-forward puts them in forward order after the file name, as in ‘file|top/middle’. If uniquify-buffer-name-style is set to nil, the buffer names simply get ‘<2>’, ‘<3>’, etc. appended.

的值uniquify-buffer-name-style可以设置为具有两个参数baseextra-strings的自定义函数,其中base是字符串, extra-strings是字符串列表。例如,当前的实现post-forward-angle-brackets可能是:

The value of uniquify-buffer-name-style can be set to a customized function with two arguments base and extra-strings where base is a string and extra-strings is a list of strings. For example the current implementation for post-forward-angle-brackets could be:

(defun my-post-forward-angle-brackets (基本额外字符串)
  (concat base \"<\" (mapconcat #'identity extra-string \"/\") \">\"))
(defun my-post-forward-angle-brackets (base extra-string)
  (concat base \"<\" (mapconcat #'identity extra-string \"/\") \">\"))

如果您要在键入缓冲区名称之前查看缓冲区名称,那么遵循哪条规则将目录名称放入缓冲区名称中并不是很重要。但作为一个有经验的用户,如果你知道规则,你就不必看。然后您可能会发现一条或另一条规则更容易让您记住并快速应用。

Which rule to follow for putting the directory names in the buffer name is not very important if you are going to look at the buffer names before you type one. But as an experienced user, if you know the rule, you won’t have to look. And then you may find that one rule or another is easier for you to remember and apply quickly.


20.7.2 快速迷你缓冲区选择

20.7.2 Fast minibuffer selection

Icomplete 全局次要模式提供了一种便捷的方法,可以在小型缓冲区中的可能补全中快速选择元素。启用后,在迷你缓冲区中键入内容会连续显示与您键入的字符串匹配的可能完成列表。

Icomplete global minor mode provides a convenient way to quickly select an element among the possible completions in a minibuffer. When enabled, typing in the minibuffer continuously displays a list of possible completions that match the string you have typed.

您可以随时键入C-j以选择列表中的第一个完成项。因此,选择特定完成的方法是将其置于列表中的第一个。有两种方法可以做到这一点。您可以输入更多的补全名称,从而缩小列表范围,排除所需补全之上不需要的补全。或者,您可以使用C-.C-,旋转列表,直到所需的缓冲区位于第一个。

At any time, you can type C-j to select the first completion in the list. So the way to select a particular completion is to make it the first in the list. There are two ways to do this. You can type more of the completion name and thus narrow down the list, excluding unwanted completions above the desired one. Alternatively, you can use C-. and C-, to rotate the list until the desired buffer is first.

M-TAB将选择列表中的第一个完成,就像 C-j但不退出迷你缓冲区,以便您可以进一步编辑它。这通常在输入文件名时使用, 可以使用几次来降低目录层次结构。 M-TAB

M-TAB will select the first completion in the list, like C-j but without exiting the minibuffer, so you can edit it further. This is typically used when entering a file name, where M-TAB can be used a few times to descend in the hierarchy of directories.

要启用 Icomplete 模式,请键入M-x icomplete-mode或将变量自定义icomplete-modet(请参阅轻松自定义界面)。

To enable Icomplete mode, type M-x icomplete-mode, or customize the variable icomplete-mode to t (see Easy Customization Interface).

Icomplete 模式的替代方案是 Fido 模式。这与 Icomplete 模式非常相似,但保留了名为 Ido 模式的流行扩展的一些功能(实际上该名称源自“Fake Ido”)。除其他外,在 Fido 模式下,C-sC-r用于旋转完成列表,C-k可用于删除文件和杀死列表中的缓冲区。另一个值得注意的方面是flex用作默认完成样式(请参阅如何选择完成替代方案)。要更改此设置,请将以下内容添加到初始化文件中(请参阅Emacs 初始化文件):

An alternative to Icomplete mode is Fido mode. This is very similar to Icomplete mode, but retains some functionality from a popular extension called Ido mode (in fact the name is derived from “Fake Ido”). Among other things, in Fido mode, C-s and C-r are also used to rotate the completions list, C-k can be used to delete files and kill buffers in-list. Another noteworthy aspect is that flex is used as the default completion style (see How Completion Alternatives Are Chosen). To change this, add the following to your initialization file (see The Emacs Initialization File):

(defun my-icomplete-styles ()
  (setq-本地完成样式'(首字母缩写flex)))
(添加钩子'icomplete-minibuffer-setup-hook'my-icomplete-styles)
(defun my-icomplete-styles ()
  (setq-local completion-styles '(initials flex)))
(add-hook 'icomplete-minibuffer-setup-hook 'my-icomplete-styles)

要启用 Fido 模式,请键入M-x fido-mode或自定义变量fido-modet(请参阅轻松自定义界面)。

To enable Fido mode, type M-x fido-mode, or customize the variable fido-mode to t (see Easy Customization Interface).

默认情况下,Icomplete 模式和 Fido 模式将可能的补全显示在与提示相同的行上。要在提示下垂直显示完成候选,请键入M-x icomplete-vertical-mode,或将变量自定义icomplete-vertical-modet (请参阅轻松自定义界面)。

Icomplete mode and Fido mode display the possible completions on the same line as the prompt by default. To display the completion candidates vertically under the prompt, type M-x icomplete-vertical-mode, or customize the variable icomplete-vertical-mode to t (see Easy Customization Interface).


20.7.3 自定义缓冲区菜单

20.7.3 Customizing Buffer Menus

M-x bs-show
M-x bs-show

制作一个缓冲区列表,类似于M-x list-buffers制作一个类似于但可定制的

Make a list of buffers similarly to M-x list-buffers but customizable.

M-x ibuffer
M-x ibuffer

制作一个缓冲区列表并以类似于 Dired 的方式对其进行操作。

Make a list of buffers and operate on them in Dired-like fashion.

M-x bs-show弹出一个缓冲区列表,与通常显示的缓冲区列表类似C-x C-b,但您可以以更灵活的方式自定义其显示。例如,您可以指定要显示的缓冲区属性列表、缓冲区名称列的最小和最大宽度、永远不会显示和始终显示的缓冲区名称的正则表达式等。如果您更喜欢这样做通常的缓冲区列表,您可以将此命令绑定到C-x C-b.要自定义此缓冲区列表,请使用bs自定义组(请参阅轻松自定义界面),或调用bs-customize.

M-x bs-show pops up a buffer list similar to the one normally displayed by C-x C-b, but whose display you can customize in a more flexible fashion. For example, you can specify the list of buffer attributes to show, the minimum and maximum width of buffer name column, a regexp for names of buffers that will never be shown and those which will always be shown, etc. If you prefer this to the usual buffer list, you can bind this command to C-x C-b. To customize this buffer list, use the bs Custom group (see Easy Customization Interface), or invoke bs-customize.

MSB 全局次要模式(“MSB”代表“鼠标选择缓冲区”)提供了您可能喜欢的不同且可自定义的鼠标缓冲区菜单。它取代了mouse-buffer-menu通常绑定到的命令C-Down-mouse-1和的命令,并且还修改了菜单栏缓冲区菜单。您可以在自定义组中自定义菜单。 C-F10msb

MSB global minor mode (“MSB” stands for “mouse select buffer”) provides a different and customizable mouse buffer menu which you may prefer. It replaces the mouse-buffer-menu commands, normally bound to C-Down-mouse-1 and C-F10, with its own commands, and also modifies the menu-bar buffer menu. You can customize the menu in the msb Custom group.

IBuffer 是一种主要模式,用于查看缓冲区列表并以类似于 Dired 的方式对其进行操作(请参阅Dired,目录编辑器),包括以各种方式进行过滤、标记、排序以及对缓冲区进行操作。

IBuffer is a major mode for viewing a list of buffers and operating on them in a way analogous to that of Dired (see Dired, the Directory Editor), including filtering, marking, sorting in various ways, and acting on buffers.


21 多个窗口

21 Multiple Windows

Emacs 可以将一个框架分割成两个或多个窗口。多个窗口可以显示不同缓冲区的一部分,或一个缓冲区的不同部分。多个框架总是意味着多个窗口,因为每个框架都有自己的一组窗口。每个窗口属于一个且仅一个框架。

Emacs can split a frame into two or many windows. Multiple windows can display parts of different buffers, or different parts of one buffer. Multiple frames always imply multiple windows, because each frame has its own set of windows. Each window belongs to one and only one frame.


21.1 Emacs Windows 的概念

21.1 Concepts of Emacs Windows

每个 Emacs 窗口随时显示一个 Emacs 缓冲区。单个缓冲区可能出现在多个窗口中;如果是这样,其文本的任何更改都会显示在它出现的所有窗口中。但这些窗口可以显示缓冲区的不同部分,因为每个窗口都有自己的点值。

Each Emacs window displays one Emacs buffer at any time. A single buffer may appear in more than one window; if it does, any changes in its text are displayed in all the windows where it appears. But these windows can show different parts of the buffer, because each window has its own value of point.

任何时候,一个 Emacs 窗口都是被选择的窗口;该窗口显示的缓冲区是当前缓冲区。在图形显示上,该点在选定窗口中由实心闪烁光标指示,在未选定窗口中由空心框指示。在文本终端上,光标仅绘制在选定的窗口中。请参阅显示光标

At any time, one Emacs window is the selected window; the buffer this window is displaying is the current buffer. On graphical displays, the point is indicated by a solid blinking cursor in the selected window, and by a hollow box in non-selected windows. On text terminals, the cursor is drawn only in the selected window. See Displaying the Cursor.

移动点的命令仅影响所选 Emacs 窗口的点值。它们不会更改其他 Emacs 窗口中的 point 值,即使是那些显示相同缓冲区的窗口。对于诸如C-x b;之类的缓冲区切换命令也是如此。它们根本不影响其他窗口。然而,还有其他命令,例如 C-x 4 b选择不同的窗口并在其中切换缓冲区。此外,所有在窗口中显示信息的命令,包括(例如)C-h f( describe-function) 和C-x C-b ( list-buffers),通常通过在非选定窗口中显示缓冲区来工作,而不影响选定窗口。

Commands to move point affect the value of point for the selected Emacs window only. They do not change the value of point in other Emacs windows, even those showing the same buffer. The same is true for buffer-switching commands such as C-x b; they do not affect other windows at all. However, there are other commands such as C-x 4 b that select a different window and switch buffers in it. Also, all commands that display information in a window, including (for example) C-h f (describe-function) and C-x C-b (list-buffers), usually work by displaying buffers in a nonselected window without affecting the selected window.

当多个窗口显示相同的缓冲区时,它们可以具有不同的区域,因为它们可以具有不同的点值。然而,它们都具有相同的标记值,因为每个缓冲区只有一个标记位置。

When multiple windows show the same buffer, they can have different regions, because they can have different values of point. However, they all have the same value for the mark, because each buffer has only one mark position.

每个窗口都有自己的模式行,显示窗口中显示的缓冲区名称、修改状态以及主要和次要模式。所选窗口的模式线以不同的颜色显示。有关详细信息,请参阅模式行

Each window has its own mode line, which displays the buffer name, modification status and major and minor modes of the buffer that is displayed in the window. The selected window’s mode line appears in a different color. See The Mode Line, for details.


21.2 分割窗口

21.2 Splitting Windows

C-x 2
C-x 2

将选定的窗口拆分为两个窗口,一个位于另一个之上 ( split-window-below)。

Split the selected window into two windows, one above the other (split-window-below).

C-x 3
C-x 3

将选定的窗口拆分为两个并排放置的窗口 ( split-window-right)。

Split the selected window into two windows, positioned side by side (split-window-right).

C-mouse-2
C-mouse-2

在窗口的模式行中,分割该窗口。

In the mode line of a window, split that window.

C-x 2( split-window-below) 将选定的窗口分成两个窗口,一个在另一个窗口之上。分割后,上方是选中的窗口,下方是新分割的窗口。两个窗口都具有与以前相同的 point 值,并显示缓冲区的相同部分(或尽可能接近)。如有必要,窗口会滚动以保持屏幕上的点。默认情况下,两个窗口的高度均为原始窗口的一半。正数值参数指定向顶部窗口提供多少行;负数值参数指定向底部窗口提供多少行。

C-x 2 (split-window-below) splits the selected window into two windows, one above the other. After splitting, the selected window is the upper one, and the newly split-off window is below. Both windows have the same value of point as before, and display the same portion of the buffer (or as close to it as possible). If necessary, the windows are scrolled to keep point on-screen. By default, the two windows each get half the height of the original window. A positive numeric argument specifies how many lines to give to the top window; a negative numeric argument specifies how many lines to give to the bottom window.

如果将变量更改split-window-keep-pointnilC-x 2则改为调整两个窗口显示的缓冲区部分以及每个窗口中的 point 值,以使屏幕上的文本尽可能接近之前的内容;此外,如果点位于原始窗口的下半部分,则选择底部窗口而不是上部窗口。

If you change the variable split-window-keep-point to nil, C-x 2 instead adjusts the portion of the buffer displayed by the two windows, as well as the value of point in each window, in order to keep the text on the screen as close as possible to what it was before; furthermore, if point was in the lower half of the original window, the bottom window is selected instead of the upper one.

C-x 3( split-window-right) 将选定的窗口拆分为两个并排的窗口。左侧窗口为选中窗口;右侧窗口显示同一缓冲区的同一部分,并具有相同的点值。正数值参数指定左窗口有多少列;负数值参数指定为右侧窗口提供多少列。

C-x 3 (split-window-right) splits the selected window into two side-by-side windows. The left window is the selected one; the right window displays the same portion of the same buffer, and has the same value of point. A positive numeric argument specifies how many columns to give the left window; a negative numeric argument specifies how many columns to give the right window.

当您使用 分割窗口时C-x 3,每个生成的窗口所占的空间都小于框架的整个宽度。如果它变得太窄,并且正在使用连续行(请参阅连续行),则缓冲区可能难以读取。因此,如果窗口宽度小于 50 列,Emacs 会自动切换到行截断。无论变量的值如何,都会发生这种截断truncate-lines(请参阅行截断);它是由变量控制的 truncate-partial-width-windows。如果该变量的值为正整数(默认为50),则指定发生自动行截断之前部分宽度窗口的最小总宽度;如果值为nil,则禁用自动行截断;对于任何其他非nil值,Emacs 会截断每个部分宽度窗口中的行,无论其宽度如何。窗口的总宽度以列为单位 window-total-width(请参阅Emacs Lisp 参考手册中的窗口大小)),它包括边缘、延续和截断字形、边距和滚动条。

When you split a window with C-x 3, each resulting window occupies less than the full width of the frame. If it becomes too narrow, the buffer may be difficult to read if continuation lines are in use (see Continuation Lines). Therefore, Emacs automatically switches to line truncation if the window width becomes narrower than 50 columns. This truncation occurs regardless of the value of the variable truncate-lines (see Line Truncation); it is instead controlled by the variable truncate-partial-width-windows. If the value of this variable is a positive integer (the default is 50), that specifies the minimum total width for a partial-width window before automatic line truncation occurs; if the value is nil, automatic line truncation is disabled; and for any other non-nil value, Emacs truncates lines in every partial-width window regardless of its width. The total width of a window is in column units as reported by window-total-width (see Window Sizes in The Emacs Lisp Reference Manual), it includes the fringes, the continuation and truncation glyphs, the margins, and the scroll bar.

在文本终端上,并排窗口由使用vertical-border面部绘制的垂直分隔线分隔。

On text terminals, side-by-side windows are separated by a vertical divider which is drawn using the vertical-border face.

如果您单击C-mouse-2窗口的模式线,则会分割窗口,并在您单击的位置放置一个垂直分隔线。根据 Emacs 的编译方式,您还可以通过单击C-mouse-2滚动条来分割窗口,这会在您单击的位置放置一个水平分隔线(当 Emacs 使用 GTK+ 滚动条时,此功能不起作用)。

If you click C-mouse-2 in the mode line of a window, that splits the window, putting a vertical divider where you click. Depending on how Emacs is compiled, you can also split a window by clicking C-mouse-2 in the scroll bar, which puts a horizontal divider where you click (this feature does not work when Emacs uses GTK+ scroll bars).

默认情况下,当您拆分窗口时,Emacs 会给出每个结果窗口的尺寸,该尺寸是框架默认字体大小的整数倍。这可能会在生成的窗口之间不均匀地细分屏幕空间。如果将该变量设置window-resize-pixelwise为非值nil,Emacs 将为每个窗口提供相同数量的像素(如果初始尺寸为奇数个像素,则给出或取一个像素)。请注意,当一帧的像素大小不是该帧的字符大小的倍数时,即使此选项为 ,至少一个窗口也可能会按像素调整大小nil

By default, when you split a window, Emacs gives each of the resulting windows dimensions that are an integral multiple of the default font size of the frame. That might subdivide the screen estate unevenly between the resulting windows. If you set the variable window-resize-pixelwise to a non-nil value, Emacs will give each window the same number of pixels (give or take one pixel if the initial dimension was an odd number of pixels). Note that when a frame’s pixel size is not a multiple of the frame’s character size, at least one window may get resized pixelwise even if this option is nil.


21.3 使用其他窗口

21.3 Using Other Windows

C-x o
C-x o

选择另一个窗口 ( other-window)。

Select another window (other-window).

C-M-v
C-M-v

向上滚动下一个窗口 ( scroll-other-window)。

Scroll the next window upward (scroll-other-window).

C-M-S-v
C-M-S-v

向下滚动下一个窗口 ( scroll-other-window-down)。

Scroll the next window downward (scroll-other-window-down).

C-M-S-l
C-M-S-l

将下一个窗口居中 ( recenter-other-window)。

Recenter the next window (recenter-other-window).

mouse-1
mouse-1

mouse-1,在窗口的文本区域中,选择窗口并将点移动到单击的位置。单击模式线即可选择窗口而不移动其中的点。

mouse-1, in the text area of a window, selects the window and moves point to the position clicked. Clicking in the mode line selects the window without moving point in it.

使用键盘,您可以通过键入C-x o ( other-window) 来切换窗口。这是一个o, 代表“其他”,而不是零。当有两个以上窗口时,该命令以循环顺序移动所有窗口,通常是从上到下、从左到右。在最右边和最底部的窗口之后,它返回到左上角的窗口。数字参数意味着按照窗口的循环顺序移动几个步骤。否定论证以相反的顺序围绕循环移动。当迷你缓冲区处于活动状态时,迷你缓冲区窗口是循环中的最后一个窗口;您可以从迷你缓冲区窗口切换到其他窗口之一,然后再切换回来并完成提供所请求的迷你缓冲区参数。请参阅在迷你缓冲区中进行编辑

With the keyboard, you can switch windows by typing C-x o (other-window). That is an o, for “other”, not a zero. When there are more than two windows, this command moves through all the windows in a cyclic order, generally top to bottom and left to right. After the rightmost and bottommost window, it goes back to the one at the upper left corner. A numeric argument means to move several steps in the cyclic order of windows. A negative argument moves around the cycle in the opposite order. When the minibuffer is active, the minibuffer window is the last window in the cycle; you can switch from the minibuffer window to one of the other windows, and later switch back and finish supplying the minibuffer argument that is requested. See Editing in the Minibuffer.

other-window命令通常只会切换到当前帧中的下一个窗口(除非另有配置)。如果您在多帧环境中工作并且希望所有帧中的窗口都成为循环的一部分,则可以重新绑定C-x o到该 next-window-any-frame命令。 (有关如何重新绑定命令, 请参阅交互更改键绑定。)

The other-window command will normally only switch to the next window in the current frame (unless otherwise configured). If you work in a multi-frame environment and you want windows in all frames to be part of the cycle, you can rebind C-x o to the next-window-any-frame command. (See Changing Key Bindings Interactively, for how to rebind a command.)

常用的滚动命令(请参阅控制显示)仅适用于选定的窗口,但也有滚动下一个窗口的命令。 C-M-v( scroll-other-window) 滚动要选择的窗口 C-x o。在其他方面,该命令的行为类似于 C-v;两者都将缓冲区文本相对于窗口向上移动,并采用正参数和负参数。 (在迷你缓冲区中,C-M-v 滚动与迷你缓冲区关联的帮助窗口(如果有),而不是标准循环顺序中的下一个窗口;请参阅在迷你缓冲区中编辑。) C-M-S-v( scroll-other-window-down) 以类似方式向下滚动下一个窗口。同样,C-M-S-l ( )在下一个窗口中的 recenter-other-window行为与C-l ( ) 类似。recenter-top-bottom

The usual scrolling commands (see Controlling the Display) apply to the selected window only, but there are also commands to scroll the next window. C-M-v (scroll-other-window) scrolls the window that C-x o would select. In other respects, the command behaves like C-v; both move the buffer text upward relative to the window, and take positive and negative arguments. (In the minibuffer, C-M-v scrolls the help window associated with the minibuffer, if any, rather than the next window in the standard cyclic order; see Editing in the Minibuffer.) C-M-S-v (scroll-other-window-down) scrolls the next window downward in a similar way. Likewise, C-M-S-l (recenter-other-window) behaves like C-l (recenter-top-bottom) in the next window.

如果设置mouse-autoselect-window为非值nil,则将鼠标移到不同的窗口上会选择该窗口。该功能默认关闭。

If you set mouse-autoselect-window to a non-nil value, moving the mouse over a different window selects that window. This feature is off by default.


21.4 在另一个窗口中显示

21.4 Displaying in Another Window

C-x 4是切换到不同窗口(另一个现有窗口,或通过拆分所选窗口创建的新窗口)中的缓冲区的各种命令的前缀键。请参阅工作原理display-buffer,了解 Emacs 如何选择或创建要使用的窗口。

C-x 4 is a prefix key for a variety of commands that switch to a buffer in a different window—either another existing window, or a new window created by splitting the selected window. See How display-buffer works, for how Emacs picks or creates the window to use.

C-x 4 b bufname RET
C-x 4 b bufname RET

在另一个窗口 ( )中选择缓冲区bufnameswitch-to-buffer-other-window 。请参阅创建和选择缓冲区

Select buffer bufname in another window (switch-to-buffer-other-window). See Creating and Selecting Buffers.

C-x 4 C-o bufname RET
C-x 4 C-o bufname RET

在某个窗口中显示缓冲区bufname,而不尝试选择它 ( display-buffer)。有关如何选择窗口的详细信息, 请参阅在窗口中显示缓冲区。

Display buffer bufname in some window, without trying to select it (display-buffer). See Displaying a Buffer in a Window, for details about how the window is chosen.

C-x 4 f filename RET
C-x 4 f filename RET

访问文件filename并在另一个窗口 ( find-file-other-window) 中选择其缓冲区。请参阅访问文件

Visit file filename and select its buffer in another window (find-file-other-window). See Visiting Files.

C-x 4 d directory RET
C-x 4 d directory RET

在另一个窗口 ( )中为目录目录选择 Dired 缓冲区。dired-other-window请参阅Dired,目录编辑器

Select a Dired buffer for directory directory in another window (dired-other-window). See Dired, the Directory Editor.

C-x 4 m
C-x 4 m

开始撰写邮件消息,类似于C-x m(请参阅发送邮件),但在另一个窗口中 ( compose-mail-other-window)。

Start composing a mail message, similar to C-x m (see Sending Mail), but in another window (compose-mail-other-window).

C-x 4 .
C-x 4 .

查找标识符的定义,类似于M-. (请参阅查找标识符引用),但在另一个窗口中 ( xref-find-definitions-other-window)。

Find the definition of an identifier, similar to M-. (see Find Identifier References), but in another window (xref-find-definitions-other-window).

C-x 4 r filename RET
C-x 4 r filename RET

以只读方式访问文件filenamefind-file-read-only-other-window ,并在另一个窗口 ( ) 中选择其缓冲区。请参阅访问文件

Visit file filename read-only, and select its buffer in another window (find-file-read-only-other-window). See Visiting Files.

C-x 4 4
C-x 4 4

更通用的前缀命令会影响在此前缀命令之后立即调用的下一个命令显示的缓冲区。它请求将下一个命令的缓冲区显示在另一个窗口中。

A more general prefix command affects the buffer displayed by the next command invoked immediately after this prefix command. It requests the buffer of the next command to be displayed in another window.

C-x 4 1
C-x 4 1

该通用前缀命令请求下一个命令的缓冲区显示在同一窗口中。

This general prefix command requests the buffer of the next command to be displayed in the same window.


21.5 删除窗口和调整窗口大小

21.5 Deleting and Resizing Windows

C-x 0
C-x 0

删除选定的窗口 ( delete-window)。

Delete the selected window (delete-window).

C-x 1
C-x 1

删除所选帧中除所选窗口 ( delete-other-windows) 之外的所有窗口。

Delete all windows in the selected frame except the selected window (delete-other-windows).

C-x 4 0
C-x 4 0

删除所选窗口并终止其中显示的缓冲区 ( kill-buffer-and-window)。该按键序列中的最后一个字符是零。

Delete the selected window and kill the buffer that was showing in it (kill-buffer-and-window). The last character in this key sequence is a zero.

C-x w 0 RET buffer RET
C-x w 0 RET buffer RET

删除显示指定缓冲区的窗口。

Delete windows showing the specified buffer.

C-x ^
C-x ^

使选定的窗口更高 ( enlarge-window)。

Make selected window taller (enlarge-window).

C-x }
C-x }

使选定的窗口变宽 ( enlarge-window-horizontally)。

Make selected window wider (enlarge-window-horizontally).

C-x {
C-x {

使选定的窗口变窄 ( shrink-window-horizontally)。

Make selected window narrower (shrink-window-horizontally).

C-x -
C-x -

如果其缓冲区不需要这么多行,则缩小此窗口 ( shrink-window-if-larger-than-buffer)。

Shrink this window if its buffer doesn’t need so many lines (shrink-window-if-larger-than-buffer).

C-x +
C-x +

使所有窗户的高度相同 ( balance-windows)。

Make all windows the same height (balance-windows).

要删除选定的窗口,请键入C-x 0 ( delete-window)。 (这是一个零。)一旦删除了一个窗口,它所占用的空间就会分配给相邻的窗口(但不会分配给迷你缓冲区窗口,即使它当时处于活动状态)。删除窗口对其用于显示的缓冲区没有影响;缓冲区继续存在,您仍然可以使用 切换到它C-x b。该选项delete-window-choose-selected控制选择哪个窗口作为新选定的窗口(请参阅Emacs Lisp 参考手册中的删除窗口)。

To delete the selected window, type C-x 0 (delete-window). (That is a zero.) Once a window is deleted, the space that it occupied is given to an adjacent window (but not the minibuffer window, even if that is active at the time). Deleting the window has no effect on the buffer it used to display; the buffer continues to exist, and you can still switch to it with C-x b. The option delete-window-choose-selected controls which window is chosen as the new selected window instead (see Deleting Windows in The Emacs Lisp Reference Manual).

C-x 4 0( kill-buffer-and-window) 的命令比C-x 0;更强。它会杀死当前缓冲区,然后删除选定的窗口。

C-x 4 0 (kill-buffer-and-window) is a stronger command than C-x 0; it kills the current buffer and then deletes the selected window.

C-x 1( ) 删除所选窗口之外的delete-other-windows所有窗口 ;选定的窗口将扩展以使用整个框架。 (当迷你缓冲区窗口处于活动状态时,无法使用此命令;尝试这样做会发出错误信号。)

C-x 1 (delete-other-windows) deletes all the windows, except the selected one; the selected window expands to use the whole frame. (This command cannot be used while the minibuffer window is active; attempting to do so signals an error.)

M-x delete-windows-on删除显示特定缓冲区的窗口。它提示输入缓冲区,默认为当前缓冲区。如果前缀参数为零,C-u 0则此命令仅删除当前显示器帧上的窗口。

M-x delete-windows-on deletes windows that show a specific buffer. It prompts for the buffer, defaulting to the current buffer. With prefix argument of zero, C-u 0, this command deletes windows only on the current display’s frames.

命令C-x ^( enlarge-window) 使选定的窗口高一行,占用垂直相邻窗口的空间,而不改变框架的高度。使用正数值参数,此命令将窗口高度增加那么多行;如果参数为负,则高度会减少那么多行。如果没有垂直相邻的窗口(即窗口处于全帧高度),则表示错误。如果您尝试将任何窗口的高度降低到低于由变量指定的某个最小行数 window-min-height(默认值为 4), 该命令也会发出错误信号。

The command C-x ^ (enlarge-window) makes the selected window one line taller, taking space from a vertically adjacent window without changing the height of the frame. With a positive numeric argument, this command increases the window height by that many lines; with a negative argument, it reduces the height by that many lines. If there are no vertically adjacent windows (i.e., the window is at the full frame height), that signals an error. The command also signals an error if you attempt to reduce the height of any window below a certain minimum number of lines, specified by the variable window-min-height (the default is 4).

同样,C-x }( enlarge-window-horizontally) 使所选窗口变宽,C-x { ( shrink-window-horizontally) 使所选窗口变窄。如果您尝试将任何窗口的宽度减小到低于由变量指定的某个最小列数 window-min-width(默认值为 10), 这些命令会发出错误信号。

Similarly, C-x } (enlarge-window-horizontally) makes the selected window wider, and C-x { (shrink-window-horizontally) makes it narrower. These commands signal an error if you attempt to reduce the width of any window below a certain minimum number of columns, specified by the variable window-min-width (the default is 10).

鼠标单击模式线(请参阅模式线鼠标命令)或窗口分隔线(请参阅窗口分隔线)提供了另一种更改窗口高度以及分割或删除窗口的方法。

Mouse clicks on the mode line (see Mode Line Mouse Commands) or on window dividers (see Window Dividers) provide another way to change window heights and to split or delete windows.

C-x -shrink-window-if-larger-than-buffer如果所选窗口的高度高于显示正在显示的缓冲区的整个文本所需的高度,则( ) 会减小所选窗口的高度。它为框架中的其他窗口提供了额外的线条。

C-x - (shrink-window-if-larger-than-buffer) reduces the height of the selected window, if it is taller than necessary to show the whole text of the buffer it is displaying. It gives the extra lines to other windows in the frame.

您还可以使用C-x +( balance-windows) 来平衡所选框架中所有窗口的高度。

You can also use C-x + (balance-windows) to even out the heights of all the windows in the selected frame.


21.6 在窗口中显示缓冲区

21.6 Displaying a Buffer in a Window

显示或弹出某些缓冲区以响应用户命令是常见的 Emacs 操作。命令有多种不同的方式来执行此操作。

It is a common Emacs operation to display or pop up some buffer in response to a user command. There are several different ways in which commands do this.

许多命令(如C-x C-f( find-file))默认情况下通过“接管”所选窗口来显示缓冲区,期望将用户的注意力转移到该缓冲区。

Many commands, like C-x C-f (find-file), by default display the buffer by “taking over” the selected window, expecting that the user’s attention will be diverted to that buffer.

一些命令尝试智能地显示,尝试不接管所选窗口,例如,通过分割新窗口并在那里显示所需的缓冲区。此类命令包括各种帮助命令(请参阅帮助),通过 display-buffer内部调用来工作。有关详细信息,请参阅工作原理display-buffer

Some commands try to display intelligently, trying not to take over the selected window, e.g., by splitting off a new window and displaying the desired buffer there. Such commands, which include the various help commands (see Help), work by calling display-buffer internally. See How display-buffer works, for details.

其他命令的作用与 相同display-buffer,并另外选择显示窗口,以便您可以开始编辑其缓冲区。命令M-g M-n( next-error) 就是一个示例(请参阅编译模式)。此类命令通过内部调用函数来工作pop-to-buffer。请参阅《Emacs Lisp 参考手册》中的切换到窗口中的缓冲区

Other commands do the same as display-buffer, and additionally select the displaying window so that you can begin editing its buffer. The command M-g M-n (next-error) is one example (see Compilation Mode). Such commands work by calling the function pop-to-buffer internally. See Switching to a Buffer in a Window in The Emacs Lisp Reference Manual.

名称以 结尾的命令的-other-window行为类似于 display-buffer,但它们从不显示在选定的窗口中。其中几个命令绑定在C-x 4前缀键中(请参阅在另一个窗口中显示)。

Commands with names ending in -other-window behave like display-buffer, except that they never display in the selected window. Several of these commands are bound in the C-x 4 prefix key (see Displaying in Another Window).

名称以 结尾的命令的-other-frame行为类似于 display-buffer,只不过它们 (i) 从不显示在所选窗口中,并且 (ii) 更喜欢创建新帧或使用其他帧上的窗口来显示所需的缓冲区。其中几个命令绑定在C-x 5前缀键中。

Commands with names ending in -other-frame behave like display-buffer, except that they (i) never display in the selected window and (ii) prefer to either create a new frame or use a window on some other frame to display the desired buffer. Several of these commands are bound in the C-x 5 prefix key.


21.6.1display-buffer工作原理

21.6.1 How display-buffer works

display-buffer命令(以及内部调用它的命令)按照下面给出的步骤选择要显示的窗口。有关如何更改此步骤顺序的详细信息, 请参阅Emacs Lisp 参考手册的选择用于显示缓冲区的窗口。

The display-buffer command (as well as commands that call it internally) chooses a window to display by following the steps given below. See Choosing a Window for Displaying a Buffer in The Emacs Lisp Reference Manual, for details about how to alter this sequence of steps.

  • 如果无论其他考虑因素如何,缓冲区都应显示在所选窗口中,请重用所选窗口。默认情况下,会跳过此步骤,但您可以通过将与缓冲区名称匹配的正则表达式以及对display-buffer-same-window操作函数的引用(请参阅Emacs Lisp 参考手册中的缓冲区显示操作函数)添加到选项 (请参阅《Emacs Lisp 参考手册》中的选择用于显示缓冲区的窗口display-buffer-alist)。例如,显示缓冲区*划痕*最好在选定的窗口中写入:
    (设置选项
     显示缓冲区列表
     '((“\\*scratch\\*”(显示缓冲区同一窗口))))
    

    默认情况下,display-buffer-alistnil.

  • If the buffer should be displayed in the selected window regardless of other considerations, reuse the selected window. By default, this step is skipped, but you can tell Emacs not to skip it by adding a regular expression matching the buffer’s name together with a reference to the display-buffer-same-window action function (see Action Functions for Buffer Display in The Emacs Lisp Reference Manual) to the option display-buffer-alist (see Choosing a Window for Displaying a Buffer in The Emacs Lisp Reference Manual). For example, to display the buffer *scratch* preferably in the selected window write:
    (setopt
     display-buffer-alist
     '(("\\*scratch\\*" (display-buffer-same-window))))
    

    By default, display-buffer-alist is nil.

  • 否则,如果缓冲区已显示在现有窗口中,请重用该窗口。通常,仅考虑选定帧上的窗口,但如果使用相应的reusable-frames动作列表条目,其他帧上的窗口也可以重用(请参阅《Emacs Lisp 参考手册》中的“缓冲区显示的动作列表”)。有关如何执行此操作的示例,请参阅下一步。
  • Otherwise, if the buffer is already displayed in an existing window, reuse that window. Normally, only windows on the selected frame are considered, but windows on other frames are also reusable if you use the corresponding reusable-frames action alist entry (see Action Alists for Buffer Display in The Emacs Lisp Reference Manual). See the next step for an example of how to do that.
  • 否则,可以选择创建一个新帧并在其中显示缓冲区。默认情况下,会跳过此步骤。要启用它,请更改该选项的值display-buffer-base-action(请参阅《Emacs Lisp 参考手册》中的选择用于显示缓冲区的窗口),如下所示:
    (设置选项
     显示缓冲区基本操作
     '((显示缓冲区重用窗口显示缓冲区弹出框架)
       (可重复使用的框架。0)))
    

    此自定义还将尝试使前面的步骤在所有可见或图标化框架上搜索可重用窗口。

  • Otherwise, optionally create a new frame and display the buffer there. By default, this step is skipped. To enable it, change the value of the option display-buffer-base-action (see Choosing a Window for Displaying a Buffer in The Emacs Lisp Reference Manual) as follows:
    (setopt
     display-buffer-base-action
     '((display-buffer-reuse-window display-buffer-pop-up-frame)
       (reusable-frames . 0)))
    

    This customization will also try to make the preceding step search for a reusable window on all visible or iconified frames.

  • 否则,尝试通过在所选帧上拆分窗口来创建新窗口,并在该新窗口中显示缓冲区。

    分割可以是垂直的,也可以是水平的,具体取决于变量split-height-thresholdsplit-width-threshold。这些变量应该具有整数值。如果split-height-threshold小于所选窗口的高度,则分割会将新窗口放在下面。否则,如果 split-width-threshold小于窗口的宽度,则分割会将新窗口放在右侧。如果这两个条件都不成立,Emacs 会尝试分割以使新窗口位于下方,但前提是该窗口之前未分割过(以避免过度分割)。

  • Otherwise, try to create a new window by splitting a window on the selected frame, and display the buffer in that new window.

    The split can be either vertical or horizontal, depending on the variables split-height-threshold and split-width-threshold. These variables should have integer values. If split-height-threshold is smaller than the chosen window’s height, the split puts the new window below. Otherwise, if split-width-threshold is smaller than the window’s width, the split puts the new window on the right. If neither condition holds, Emacs tries to split so that the new window is below—but only if the window was not split before (to avoid excessive splitting).

  • 否则,在先前显示该缓冲区的窗口中显示该缓冲区。通常,仅考虑所选帧上的窗口,但使用合适的reusable-frames动作列表条目(见上文),窗口也可能位于另一个帧上。
  • Otherwise, display the buffer in a window previously showing it. Normally, only windows on the selected frame are considered, but with a suitable reusable-frames action alist entry (see above) the window may be also on another frame.
  • 否则,在所选帧的现有窗口中显示缓冲区。
  • Otherwise, display the buffer in an existing window on the selected frame.
  • 如果上述所有方法由于某种原因失败,请创建一个新帧并在其中显示缓冲区。
  • If all the above methods fail for whatever reason, create a new frame and display the buffer there.

21.6.2 显示不可编辑的缓冲区。

21.6.2 Displaying non-editable buffers.

一些缓冲区显示在窗口中是为了细读而不是为了编辑。帮助命令(参见Help)通常使用一个名为*帮助* 为此,迷你缓冲区完成(参见Completion)使用一个名为*完工*等。此类缓冲区通常仅显示很短的时间。

Some buffers are shown in windows for perusal rather than for editing. Help commands (see Help) typically use a buffer called *Help* for that purpose, minibuffer completion (see Completion) uses a buffer called *Completions*, etc. Such buffers are usually displayed only for a short period of time.

通常,Emacs 通过 来选择用于此类临时显示的窗口 display-buffer,如上一小节所述。这 *完工*另一方面,缓冲区通常显示在所选帧底部的窗口中,无论该帧上已显示的窗口数量如何。

Normally, Emacs chooses the window for such temporary displays via display-buffer, as described in the previous subsection. The *Completions* buffer, on the other hand, is normally displayed in a window at the bottom of the selected frame, regardless of the number of windows already shown on that frame.

如果您希望 Emacs 以不同的方式显示临时缓冲区,请适当地自定义该变量display-buffer-alist (请参阅《Emacs Lisp 参考手册》中的选择用于显示缓冲区的窗口)。例如,要显示*完工*始终位于所选窗口下方,在初始化文件中使用以下形式(请参阅Emacs 初始化文件):

If you prefer Emacs to display a temporary buffer in a different fashion, customize the variable display-buffer-alist (see Choosing a Window for Displaying a Buffer in The Emacs Lisp Reference Manual) appropriately. For example, to display *Completions* always below the selected window, use the following form in your initialization file (see The Emacs Initialization File):

(设置选项
 显示缓冲区列表
 '((“\\*Completions\\*”显示缓冲区下方所选)))
(setopt
 display-buffer-alist
 '(("\\*Completions\\*" display-buffer-below-selected)))

*完工*buffer 也很特殊,因为 Emacs 通常会尝试使其窗口尽可能大以显示其所有内容。要调整显示其他临时显示的窗口大小,例如*帮助*buffer,打开次要模式(请参阅次要模式temp-buffer-resize-mode (请参阅《Emacs Lisp 参考手册》中的临时显示)。

The *Completions* buffer is also special in the sense that Emacs usually tries to make its window just as large as necessary to display all of its contents. To resize windows showing other temporary displays, like, for example, the *Help* buffer, turn on the minor mode (see Minor Modes) temp-buffer-resize-mode (see Temporary Displays in The Emacs Lisp Reference Manual).

调整大小的窗口的最大尺寸temp-buffer-resize-mode 可以通过自定义选项 temp-buffer-max-height和来控制temp-buffer-max-width (请参阅《Emacs Lisp 参考手册》中的临时显示),并且不能超过包含框架的尺寸。

The maximum size of windows resized by temp-buffer-resize-mode can be controlled by customizing the options temp-buffer-max-height and temp-buffer-max-width (see Temporary Displays in The Emacs Lisp Reference Manual), and cannot exceed the size of the containing frame.


21.7 窗口处理的便利功能

21.7 Convenience Features for Window Handling

获胜者模式是一种全局次要模式,它记录窗口配置的更改(即,框架如何划分为窗口),以便您可以撤消它们。您可以使用M-x winner-mode或通过自定义变量来 切换获胜者模式winner-mode。启用该模式后,C-c left ( winner-undo) 将撤消上次窗口配置更改。如果您在撤消操作时改变了主意,可以使用C-c right( )重做已撤消的更改M-x winner-redo。为了防止获胜者模式绑定C-c leftC-c right,您可以将变量自定义winner-dont-bind-my-keys为非值nil。默认情况下,Winner 模式每帧最多存储 200 个窗口配置,但您可以通过修改变量 来更改它winner-ring-size。如果您不希望在获胜者模式下恢复某些缓冲区的窗口,请将它们的名称添加到 list 变量winner-boring-buffers或 regexp 中 winner-boring-buffers-regexp

Winner mode is a global minor mode that records the changes in the window configuration (i.e., how the frames are partitioned into windows), so that you can undo them. You can toggle Winner mode with M-x winner-mode, or by customizing the variable winner-mode. When the mode is enabled, C-c left (winner-undo) undoes the last window configuration change. If you change your mind while undoing, you can redo the changes you had undone using C-c right (M-x winner-redo). To prevent Winner mode from binding C-c left and C-c right, you can customize the variable winner-dont-bind-my-keys to a non-nil value. By default, Winner mode stores a maximum of 200 window configurations per frame, but you can change that by modifying the variable winner-ring-size. If there are some buffers whose windows you wouldn’t want Winner mode to restore, add their names to the list variable winner-boring-buffers or to the regexp winner-boring-buffers-regexp.

跟随模式 ( M-x follow-mode) 同步同一缓冲区上的多个窗口,以便它们始终显示该缓冲区的相邻部分。请参阅跟随模式

Follow mode (M-x follow-mode) synchronizes several windows on the same buffer so that they always display adjacent sections of that buffer. See Follow Mode.

Windmove 包定义了在框架中的相邻窗口之间定向移动的命令。 M-x windmove-right 选择紧邻当前所选窗口右侧的窗口,左侧、上侧和下侧的窗口也类似。 windmove-default-keybindings将这些命令绑定到 S-right等;这样做会禁用这些键的 Shift 选择(请参阅Shift Selection)。与可以为定向选择窗口的命令定义键绑定的方式相同,您可以使用 windmove-display-default-keybindings为指定在哪个方向显示下一个命令将要显示的缓冲区的窗口的命令定义键绑定。此外,还可 windmove-delete-default-keybindings以为定向删除窗口的命令定义键绑定,以及 windmove-swap-states-default-keybindings为将选定窗口的窗口内容与指定方向的窗口交换的命令定义键绑定。

The Windmove package defines commands for moving directionally between neighboring windows in a frame. M-x windmove-right selects the window immediately to the right of the currently selected one, and similarly for the left, up, and down counterparts. windmove-default-keybindings binds these commands to S-right etc.; doing so disables shift selection for those keys (see Shift Selection). In the same way as key bindings can be defined for commands that select windows directionally, you can use windmove-display-default-keybindings to define keybindings for commands that specify in what direction to display the window for the buffer that the next command is going to display. Also there is windmove-delete-default-keybindings to define keybindings for commands that delete windows directionally, and windmove-swap-states-default-keybindings that defines key bindings for commands that swap the window contents of the selected window with the window in the specified direction.

该命令M-x compare-windows允许您比较不同窗口中显示的文本。请参阅比较文件

The command M-x compare-windows lets you compare the text shown in different windows. See Comparing Files.

全部滚动模式 ( M-x scroll-all-mode) 是一种全局次要模式,它使滚动命令和点运动命令应用于每个窗口。

Scroll All mode (M-x scroll-all-mode) is a global minor mode that causes scrolling commands and point motion commands to apply to every single window.


21.8 窗口制表线

21.8 Window Tab Line

该命令切换每个窗口顶部屏幕行上选项卡行global-tab-line-mode的显示。选项卡行显示窗口中显示的每个缓冲区的特殊按钮(“选项卡”),并允许通过单击相应的按钮切换到任何这些缓冲区。单击该图标会将新缓冲区添加到缓冲区的窗口本地选项卡行中,单击 选项卡的图标会将其删除。选项卡行上的鼠标滚轮可水平滚动选项卡。 +x

The command global-tab-line-mode toggles the display of a tab line on the top screen line of each window. The Tab Line shows special buttons (“tabs”) for each buffer that was displayed in a window, and allows switching to any of these buffers by clicking the corresponding button. Clicking on the + icon adds a new buffer to the window-local tab line of buffers, and clicking on the x icon of a tab deletes it. The mouse wheel on the tab line scrolls the tabs horizontally.

选择上一个窗口本地选项卡与键入( )相同,选择下一个选项卡与( )相同。这两个命令都支持数字前缀参数作为重复计数。 C-x LEFTprevious-bufferC-x RIGHTnext-buffer

Selecting the previous window-local tab is the same as typing C-x LEFT (previous-buffer), selecting the next tab is the same as C-x RIGHT (next-buffer). Both commands support a numeric prefix argument as a repeat count.

您可以自定义变量tab-line-tabs-function来定义选项卡行的首选内容。默认情况下,它显示窗口中先前访问过的所有缓冲区,如上所述。但您也可以将其设置为显示与当前缓冲区具有相同主要模式的缓冲区列表,或者显示按主要模式分组的缓冲区,其中单击第一个选项卡中的模式名称会显示所有主要模式的列表,其中您可以选择另一组缓冲区。

You can customize the variable tab-line-tabs-function to define the preferred contents of the tab line. By default, it displays all buffers previously visited in the window, as described above. But you can also set it to display a list of buffers with the same major mode as the current buffer, or to display buffers grouped by their major mode, where clicking on the mode name in the first tab displays a list of all major modes where you can select another group of buffers.

请注意,选项卡行与选项卡栏不同(请参阅选项卡栏)。每个框架顶部的选项卡栏上的选项卡用于在包含多个带有缓冲区的窗口的窗口配置之间切换,而每个窗口顶部的选项卡行上的选项卡用于在窗口中的缓冲区之间切换。

Note that the Tab Line is different from the Tab Bar (see Tab Bars). Whereas tabs on the Tab Bar at the top of each frame are used to switch between window configurations containing several windows with buffers, tabs on the Tab Line at the top of each window are used to switch between buffers in the window.


22 帧和图形显示

22 Frames and Graphical Displays

当 Emacs 在图形显示上启动时,例如在 X Window 系统上,它会占用图形系统级显示区域。在本手册中,我们将其称为框架并为框架中用于显示缓冲区的部分保留“窗口”一词。一个框架最初包含一个窗口,但它可以细分为多个窗口(请参阅多个窗口)。框架通常还包含菜单栏、工具栏和回显区域。

When Emacs is started on a graphical display, e.g., on the X Window System, it occupies a graphical system-level display region. In this manual, we call this a frame, reserving the word “window” for the part of the frame used for displaying a buffer. A frame initially contains one window, but it can be subdivided into multiple windows (see Multiple Windows). A frame normally also contains a menu bar, tool bar, and echo area.

您还可以创建其他框架(请参阅创建框架)。在同一 Emacs 会话中创建的所有框架都可以访问相同的底层缓冲区和其他数据。例如,如果一个缓冲区在多个帧中显示,则在一帧中对其所做的任何更改也会立即显示在其他帧中。

You can also create additional frames (see Creating Frames). All frames created in the same Emacs session have access to the same underlying buffers and other data. For instance, if a buffer is being shown in more than one frame, any changes made to it in one frame show up immediately in the other frames too.

键入C-x C-c会关闭当前显示器上的所有框架,如果在任何其他显示器上都没有打开的框架,则结束 Emacs 会话(请参阅退出 Emacs)。要仅关闭选定的框架,请键入 C-x 5 0(即零,而不是o)。

Typing C-x C-c closes all the frames on the current display, and ends the Emacs session if it has no frames open on any other displays (see Exiting Emacs). To close just the selected frame, type C-x 5 0 (that is zero, not o).

本章介绍特定于图形显示的 Emacs 功能(特别是鼠标命令)以及管理多个框架的功能。在文本终端上,其中许多功能不可用。但是,仍然可以在文本终端上创建多个框架;此类帧一次显示一个,填满整个终端屏幕(请参阅文本终端)。还可以在某些文本终端上使用鼠标(有关在 GNU 和 Unix 系统上执行此操作的信息,请参阅在文本终端中使用鼠标;有关在 MS-DOS 上执行此操作的信息,请参阅 MS-DOS 上的鼠标使用)。所有文本终端都支持菜单。

This chapter describes Emacs features specific to graphical displays (particularly mouse commands), and features for managing multiple frames. On text terminals, many of these features are unavailable. However, it is still possible to create multiple frames on text terminals; such frames are displayed one at a time, filling the entire terminal screen (see Text Terminals). It is also possible to use the mouse on some text terminals (see Using a Mouse in Text Terminals, for doing so on GNU and Unix systems; and see Mouse Usage on MS-DOS, for doing so on MS-DOS). Menus are supported on all text terminals.


22.1 用于编辑的鼠标命令

22.1 Mouse Commands for Editing

mouse-1
mouse-1

将点移动到单击 ( mouse-set-point) 的位置。

Move point to where you click (mouse-set-point).

Drag-mouse-1
Drag-mouse-1

通过拖动激活所选文本周围的区域,并将文本放入主选择 ( mouse-set-region) 中。

Activate the region around the text selected by dragging, and put the text in the primary selection (mouse-set-region).

mouse-2
mouse-2

将点移动到单击的位置,然后在此处插入主要选择的内容 ( mouse-yank-primary)。

Move point to where you click, and insert the contents of the primary selection there (mouse-yank-primary).

mouse-3
mouse-3

如果该区域处于活动状态,则将该区域的近端移动到单击位置;否则,将mark设置为point的当前值,并将point设置为单击位置。将生成的区域保存在 Kill Ring 中;第二次单击时,将其杀死 ( mouse-save-then-kill)。

If the region is active, move the nearer end of the region to the click position; otherwise, set mark at the current value of point and point at the click position. Save the resulting region in the kill ring; on a second click, kill it (mouse-save-then-kill).

C-M-mouse-1
C-M-mouse-1

通过拖动激活选定文本周围的矩形区域。请参阅矩形

Activate a rectangular region around the text selected by dragging. See Rectangles.

最基本的鼠标命令是,通过在窗口的文本区域中mouse-set-point单击鼠标左键 来调用该命令。mouse-1这会将点移动到您单击的位置。如果该窗口不是选定的窗口,它将成为选定的窗口。您还可以通过双击激活区域 mouse-1(请参阅单词和行的鼠标命令)。

The most basic mouse command is mouse-set-point, which is invoked by clicking with the left mouse button, mouse-1, in the text area of a window. This moves point to the position where you clicked. If that window was not the selected window, it becomes the selected window. You can also activate a region by double-clicking mouse-1 (see Mouse Commands for Words and Lines).

通常,如果您单击的帧不是选定的帧,除了选择窗口和设置光标之外,还会将其设为选定的帧。在 X Window 系统上,您可以通过将变量设置x-mouse-click-focus-ignore-position为 来 更改此设置t。在这种情况下,首次单击未选择的框架只会选择该框架,而不执行任何其他操作;再次单击将选择窗口并设置光标位置。

Normally, if the frame you clicked in was not the selected frame, it is made the selected frame, in addition to selecting the window and setting the cursor. On the X Window System, you can change this by setting the variable x-mouse-click-focus-ignore-position to t. In that case, the initial click on an unselected frame just selects the frame, without doing anything else; clicking again selects the window and sets the cursor position.

mouse-1在一段文本上按住并拖动鼠标会激活该文本周围的区域 ( mouse-set-region),将标记放置在您开始按住鼠标按钮的位置,然后指向您释放它的位置(请参阅标记和区域)。此外,该区域中的文本将成为主要选择(请参阅使用其他窗口应用程序进行剪切和粘贴)。

Holding down mouse-1 and dragging the mouse over a stretch of text activates the region around that text (mouse-set-region), placing the mark where you started holding down the mouse button, and point where you release it (see The Mark and the Region). In addition, the text in the region becomes the primary selection (see Cut and Paste with Other Window Applications).

如果将变量更改mouse-drag-copy-region为非值nil,则将鼠标拖动到一段文本上也会将该文本添加到终止环。默认为nil.

If you change the variable mouse-drag-copy-region to a non-nil value, dragging the mouse over a stretch of text also adds the text to the kill ring. The default is nil.

如果此变量为non-empty,则仅在该区域非空时才复制到终止环。例如,如果您用鼠标拖动小于半个字符的区域,通常会在杀死环中得到空字符串,但是使用non-empty,这种短距离的鼠标拖动不会影响杀死环。

If this variable is non-empty, only copy to the kill ring if the region is non-empty. For instance, if you mouse drag an area that is less than a half a character, you’d normally get the empty string in your kill ring, but with non-empty, this short mouse drag won’t affect the kill ring.

如果您在拖动时将鼠标移离窗口的顶部或底部,窗口会以稳定的速度滚动,直到您将鼠标移回到窗口中。这样,您就可以选择不完全适合屏幕的区域。每一步滚动的行数取决于鼠标离开窗口边缘的距离;该变量 mouse-scroll-min-lines指定最小步长。

If you move the mouse off the top or bottom of the window while dragging, the window scrolls at a steady rate until you move the mouse back into the window. This way, you can select regions that don’t fit entirely on the screen. The number of lines scrolled per step depends on how far away from the window edge the mouse has gone; the variable mouse-scroll-min-lines specifies a minimum step size.

如果启用该选项mouse-drag-mode-line-buffer并且窗口系统支持拖动文件,则在模式行的缓冲区名称部分上拖动鼠标会将该缓冲区的文件拖动到另一个程序或框架。

If you enable the option mouse-drag-mode-line-buffer and dragging files is supported by the window system, then dragging the mouse on the buffer name portion of the mode line will drag that buffer’s file to another program or frame.

单击鼠标中键 ,mouse-2将点移动到单击的位置并插入主选择内容 ( mouse-yank-primary)。请参阅使用其他窗口应用程序进行剪切和粘贴。此行为与其他 X 应用程序一致。或者,您可以重新绑定mouse-2mouse-yank-at-click,这会在您单击的位置执行拉动。

Clicking with the middle mouse button, mouse-2, moves point to the position where you clicked and inserts the contents of the primary selection (mouse-yank-primary). See Cut and Paste with Other Window Applications. This behavior is consistent with other X applications. Alternatively, you can rebind mouse-2 to mouse-yank-at-click, which performs a yank at the position you click.

如果将变量更改mouse-yank-at-point为非值nilmouse-2则不移动点;它会在该点插入文本,无论您单击何处,甚至单击框架的哪个窗口。该变量影响 mouse-yank-primarymouse-yank-at-click

If you change the variable mouse-yank-at-point to a non-nil value, mouse-2 does not move point; it inserts the text at point, regardless of where you clicked or even which of the frame’s windows you clicked on. This variable affects both mouse-yank-primary and mouse-yank-at-click.

单击鼠标右键 ,mouse-3运行命令mouse-save-then-kill。这将根据您单击的位置和区域的状态执行多项操作:

Clicking with the right mouse button, mouse-3, runs the command mouse-save-then-kill. This performs several actions depending on where you click and the status of the region:

  • 如果没有活动区域,则单击mouse-3会激活该区域,将标记放置在点所在位置,并将点指向单击的位置。
  • If no region is active, clicking mouse-3 activates the region, placing the mark where point was and point at the clicked position.
  • 如果某个区域处于活动状态,则单击可mouse-3通过将其移动到单击的位置来调整该区域的近端。调整后的区域文本被复制到killring;如果原始区域中的文本已经在杀戮环上,它将在那里替换它。
  • If a region is active, clicking mouse-3 adjusts the nearer end of the region by moving it to the clicked position. The adjusted region’s text is copied to the kill ring; if the text in the original region was already on the kill ring, it replaces it there.
  • 如果您最初使用 double 或 Triple 指定区域 mouse-1,以便将区域定义为由整个单词或行组成(请参阅单词和行的鼠标命令),则调整区域时也会mouse-3按整个单词或行进行。
  • If you originally specified the region using a double or triple mouse-1, so that the region is defined to consist of entire words or lines (see Mouse Commands for Words and Lines), then adjusting the region with mouse-3 also proceeds by entire words or lines.
  • 如果在同一位置连续使用mouse-3第二次,则会杀死已选择的区域。因此,用鼠标删除文本的最简单方法是单击mouse-1一端,然后mouse-3在另一端单击两次。要将文本复制到 Kill Ring 中而不将其从缓冲区中删除,mouse-3 只需按一次,或者只需使用 拖过文本mouse-1。然后你可以通过拉动它来将其复制到其他地方。
  • If you use mouse-3 a second time consecutively, at the same place, that kills the region already selected. Thus, the simplest way to kill text with the mouse is to click mouse-1 at one end, then click mouse-3 twice at the other end. To copy the text into the kill ring without deleting it from the buffer, press mouse-3 just once—or just drag across the text with mouse-1. Then you can copy it elsewhere by yanking it.

mouse-save-then-kill命令还遵循变量 mouse-drag-copy-region(如上所述)。如果该值为 non- nil,则每当该命令设置或调整活动区域时,该区域中的文本也会添加到终止环中。如果以相同方式添加了最新的终止环条目,则该条目将被替换,而不是创建新条目。

The mouse-save-then-kill command also obeys the variable mouse-drag-copy-region (described above). If the value is non-nil, then whenever the command sets or adjusts the active region, the text in the region is also added to the kill ring. If the latest kill ring entry had been added the same way, that entry is replaced rather than making a new entry.

每当您使用上述任何鼠标命令设置区域时,除了停用标记的常用方法之外,任何后续未移动的光标运动命令都会停用该标记。请参阅班次选择

Whenever you set the region using any of the mouse commands described above, the mark will be deactivated by any subsequent unshifted cursor motion command, in addition to the usual ways of deactivating the mark. See Shift Selection.

有些鼠标有一个“轮子”,可以用来滚动。默认情况下,在大多数图形显示器上,Emacs 支持使用鼠标滚轮滚动窗口。要切换此功能,请使用M-x mouse-wheel-mode。变量mouse-wheel-follow-mouse确定 mouse-wheel-scroll-amount缓冲区滚动的位置和滚动量。该变量 mouse-wheel-progressive-speed确定滚动速度是否与移动滚轮的速度相关。此模式还支持增加或减小字体大小,默认情况下绑定到使用Ctrl修饰符滚动。启用此模式后,鼠标滚轮会产生特殊事件,例如wheel-upwheel-down。 (一些较旧的系统将它们报告为mouse-4mouse-5。)如果鼠标有水平滚轮,它也会 生成wheel-left和事件。wheel-right

Some mice have a “wheel” which can be used for scrolling. Emacs supports scrolling windows with the mouse wheel, by default, on most graphical displays. To toggle this feature, use M-x mouse-wheel-mode. The variables mouse-wheel-follow-mouse and mouse-wheel-scroll-amount determine where and by how much buffers are scrolled. The variable mouse-wheel-progressive-speed determines whether the scroll speed is linked to how fast you move the wheel. This mode also supports increasing or decreasing the font size, by default bound to scrolling with the Ctrl modifier. When this mode is enabled, mouse wheel produces special events like wheel-up and wheel-down. (Some older systems report them as mouse-4 and mouse-5.) If the mouse has a horizontal scroll wheel, it produces wheel-left and wheel-right events as well.

Emacs 还支持使用Shift 修饰符进行水平滚动。在开始水平滚动之前键入数字前缀 arg(例如,M-5)会更改由用户选项定义的步长值mouse-wheel-scroll-amount-horizontal

Emacs also supports horizontal scrolling with the Shift modifier. Typing a numeric prefix arg (e.g., M-5) before starting horizontal scrolling changes its step value defined by the user option mouse-wheel-scroll-amount-horizontal.

如果您的鼠标滚轮可以倾斜,或者您的触摸板支持它,那么您还可以通过将变量自定义mouse-wheel-tilt-scroll为非值来启用水平滚动nil。默认情况下,倾斜鼠标滚轮会沿倾斜方向水平滚动窗口视图:例如,向右倾斜会将窗口向右滚动,从而使窗口中显示的文本水平向左移动。如果您想反转水平滚动的方向,请将变量自定义 mouse-wheel-flip-direction为非值nil

If your mouse’s wheel can be tilted, or if your touchpad supports it, then you can also enable horizontal scrolling by customizing the variable mouse-wheel-tilt-scroll to a non-nil value. By default, tilting the mouse wheel scrolls the window’s view horizontally in the direction of the tilt: e.g., tilting to the right scrolls the window to the right, so that the text displayed in the window moves horizontally to the left. If you’d like to reverse the direction of horizontal scrolling, customize the variable mouse-wheel-flip-direction to a non-nil value.

当鼠标指针位于图像模式下的图像上时,请参阅查看图像文件,使用修改器滚动鼠标滚轮Ctrl可缩放鼠标指针下的图像,使用 Shift修改器滚动鼠标滚轮可水平滚动图像。

When the mouse pointer is over an image in Image mode, see Viewing Image Files, scrolling the mouse wheel with the Ctrl modifier scales the image under the mouse pointer, and scrolling the mouse wheel with the Shift modifier scrolls the image horizontally.


22.2 单词和行的鼠标命令

22.2 Mouse Commands for Words and Lines

这些变体mouse-1一次选择整个单词或行。 Emacs 激活所选文本周围的区域,该区域也被复制到终止环。

These variants of mouse-1 select entire words or lines at a time. Emacs activates the region around the selected text, which is also copied to the kill ring.

Double-mouse-1
Double-mouse-1

选择您单击的单词或字符周围的文本。

双击具有符号语法(例如 C 模式下的下划线)的字符可以选择该字符周围的符号。双击具有左括号或右括号语法的字符可以选择该字符开始或结束的括号分组。双击带有字符串分隔符语法的字符(例如 C 中的单引号或双引号)可以选择字符串常量(Emacs 使用启发式方法来确定该字符是它的开头还是结尾)。

双击括号分组的开头或开头字符串分隔符会将 point 移动到区域的末尾,如果需要,则向前滚动缓冲区显示以显示 point 的新位置。默认情况下,双击括号分组的末尾或结束字符串分隔符会将点保留在区域的末尾,因此如果区域的开头位于窗口顶部上方,则该区域的开头将不可见;将用户选项设置 mouse-select-region-move-to-beginning为“不”nil会更改此操作以将点移动到区域的开头,并在必要时向后滚动显示。

Select the text around the word or character which you click on.

Double-clicking on a character with symbol syntax (such as underscore, in C mode) selects the symbol surrounding that character. Double-clicking on a character with open- or close-parenthesis syntax selects the parenthetical grouping which that character starts or ends. Double-clicking on a character with string-delimiter syntax (such as a single-quote or double-quote in C) selects the string constant (Emacs uses heuristics to figure out whether that character is the beginning or the end of it).

Double-clicking on the beginning of a parenthetical grouping or beginning string-delimiter moves point to the end of the region, scrolling the buffer display forward if necessary to show the new location of point. Double-clicking on the end of a parenthetical grouping or end string-delimiter keeps point at the end of the region by default, so the beginning of the region will not be visible if it is above the top of the window; setting the user option mouse-select-region-move-to-beginning to non-nil changes this to move point to the beginning of the region, scrolling the display backward if necessary.

Double-Drag-mouse-1
Double-Drag-mouse-1

选择您拖过的文本(以整个单词为单位)。

Select the text you drag across, in units of whole words.

Triple-mouse-1
Triple-mouse-1

选择您单击的行。

Select the line you click on.

Triple-Drag-mouse-1
Triple-Drag-mouse-1

选择您拖动的文本(以整行为单位)。

Select the text you drag across, in units of whole lines.


22.3 使用鼠标跟随参考

22.3 Following References with the Mouse

一些 Emacs 缓冲区包括按钮超链接:激活时(例如,通过单击它们)执行某些操作(例如,遵循引用)的文本片段。通常,按钮的文本在视觉上突出显示:带有下划线,或者在其周围绘制一个框。如果将鼠标移到按钮上,鼠标光标的形状会发生变化并且按钮会亮起。如果将该变量更改 mouse-highlightnil,Emacs 将禁用此突出显示。

Some Emacs buffers include buttons, or hyperlinks: pieces of text that perform some action (e.g., following a reference) when activated (e.g., by clicking on them). Usually, a button’s text is visually highlighted: it is underlined, or a box is drawn around it. If you move the mouse over a button, the shape of the mouse cursor changes and the button lights up. If you change the variable mouse-highlight to nil, Emacs disables this highlighting.

RET您可以通过将指针移至按钮并键入,或者单击按钮上的mouse-1或来激活按钮 。mouse-2例如,在 Dired 缓冲区中,每个文件名都是一个按钮;激活它会导致 Emacs 访问该文件(请参阅Dired,目录编辑器)。在一个 *汇编*缓冲区中,每个错误消息都是一个按钮,激活它会访问该错误的源代码(请参阅Emacs 下的运行编译)。

You can activate a button by moving point to it and typing RET, or by clicking either mouse-1 or mouse-2 on the button. For example, in a Dired buffer, each file name is a button; activating it causes Emacs to visit that file (see Dired, the Directory Editor). In a *Compilation* buffer, each error message is a button, and activating it visits the source code for that error (see Running Compilations under Emacs).

尽管单击mouse-1按钮通常会激活该按钮,但如果您在释放鼠标按钮之前按住鼠标按钮一段时间(具体来说,超过 450 毫秒),则 Emacs 会将点移动到您单击的位置,而不激活该按钮。通过这种方式,您可以使用鼠标将点移动到按钮上,而无需激活它。将鼠标拖动到按钮上或按钮上具有设置区域的通常行为,并且不会激活按钮。

Although clicking mouse-1 on a button usually activates the button, if you hold the mouse button down for a period of time before releasing it (specifically, for more than 450 milliseconds), then Emacs moves point where you clicked, without activating the button. In this way, you can use the mouse to move point over a button without activating it. Dragging the mouse over or onto a button has its usual behavior of setting the region, and does not activate the button.

您可以mouse-1通过自定义变量来更改应用于按钮的方式mouse-1-click-follows-link。如果该值为正整数,则确定需要按住鼠标按钮多长时间(以毫秒为单位)才能取消按钮激活;默认值为 450,如上一段所述。如果值为nilmouse-1则仅设置单击的位置,而不激活按钮。如果值为double,则双击激活按钮,但单击仅设置点。

You can change how mouse-1 applies to buttons by customizing the variable mouse-1-click-follows-link. If the value is a positive integer, that determines how long you need to hold the mouse button down for, in milliseconds, to cancel button activation; the default is 450, as described in the previous paragraph. If the value is nil, mouse-1 just sets point where you clicked, and does not activate buttons. If the value is double, double clicks activate buttons but single clicks just set point.

通常,mouse-1即使按钮位于未选定的窗口中,按按钮也会激活该按钮。如果将变量更改 mouse-1-click-in-non-selected-windowsnil,则 mouse-1在未选择的窗口中的按钮上,会将点移动到单击的位置并选择该窗口,而不激活该按钮。

Normally, mouse-1 on a button activates the button even if it is in a non-selected window. If you change the variable mouse-1-click-in-non-selected-windows to nil, mouse-1 on a button in an unselected window moves point to the clicked position and selects that window, without activating the button.


22.5 模式行鼠标命令

22.5 Mode Line Mouse Commands

您可以使用鼠标单击窗口模式线来选择和操作窗口。

You can use mouse clicks on window mode lines to select and manipulate windows.

模式行的某些区域(例如缓冲区名称以及主要和次要模式名称)有自己特殊的鼠标绑定。当您将鼠标悬停在这些区域上时,这些区域会突出显示,并且将显示有关特殊绑定的信息(请参阅工具提示)。本节的命令不适用于这些区域。

Some areas of the mode line, such as the buffer name, and major and minor mode names, have their own special mouse bindings. These areas are highlighted when you hold the mouse over them, and information about the special bindings will be displayed (see Tooltips). This section’s commands do not apply in those areas.

mouse-1
mouse-1

mouse-1在模式行上选择它所属的窗口。通过拖动mouse-1模式线,您可以移动它,从而更改上方和下方窗口的高度。以这种方式用鼠标更改高度永远不会删除窗口,它只是拒绝使任何窗口小于最小高度。

mouse-1 on a mode line selects the window it belongs to. By dragging mouse-1 on the mode line, you can move it, thus changing the height of the windows above and below. Changing heights with the mouse in this way never deletes windows, it just refuses to make any window smaller than the minimum height.

mouse-2
mouse-2

mouse-2在模式行上扩展该窗口以填充其框架。

mouse-2 on a mode line expands that window to fill its frame.

mouse-3
mouse-3

mouse-3在模式行上删除它所属的窗口。如果框架只有一个窗口,则它不会执行任何操作。

mouse-3 on a mode line deletes the window it belongs to. If the frame has only one window, it does nothing.

C-mouse-2
C-mouse-2

C-mouse-2在模式线上分割该窗口,生成两个并排的窗口,其边界穿过单击位置(请参阅分割窗口)。

C-mouse-2 on a mode line splits that window, producing two side-by-side windows with the boundary running through the click position (see Splitting Windows).

此外,通过单击并拖动mouse-1两条并排模式线之间的分隔线,您可以将垂直边界向左或向右移动。

Furthermore, by clicking and dragging mouse-1 on the divider between two side-by-side mode lines, you can move the vertical boundary to the left or right.

请注意,调整窗口大小受 值的影响 window-resize-pixelwise,请参阅拆分窗口

Note that resizing windows is affected by the value of window-resize-pixelwise, see Splitting Windows.


22.6 创建框架

22.6 Creating Frames

前缀键C-x 5类似于C-x 4。尽管每个C-x 4命令都会在所选帧的不同窗口中弹出缓冲区(请参阅在另一个窗口中显示),但这些C-x 5命令使用不同的帧。如果现有的可见或图标化(也称为“最小化”,请参阅Emacs Lisp 参考手册中的框架可见性)框架已显示请求的缓冲区,则该框架将被提升并去图标化(“非最小化”);否则,在当前显示终端上创建一个新的帧。

The prefix key C-x 5 is analogous to C-x 4. Whereas each C-x 4 command pops up a buffer in a different window in the selected frame (see Displaying in Another Window), the C-x 5 commands use a different frame. If an existing visible or iconified (a.k.a. “minimized”, see Visibility of Frames in The Emacs Lisp Reference Manual) frame already displays the requested buffer, that frame is raised and deiconified (“un-minimized”); otherwise, a new frame is created on the current display terminal.

各种C-x 5命令的不同之处在于它们如何查找或创建要选择的缓冲区:

The various C-x 5 commands differ in how they find or create the buffer to select:

C-x 5 2
C-x 5 2

使用默认框架参数创建新框架 ( make-frame-command)。

Create a new frame using the default frame parameters (make-frame-command).

C-x 5 c
C-x 5 c

使用当前帧的窗口配置和帧参数创建一个新帧 ( clone-frame)。

Create a new frame using the window configuration and frame parameters of the current frame (clone-frame).

C-x 5 b bufname RET
C-x 5 b bufname RET

在另一个帧中选择缓冲区bufname 。这运行 switch-to-buffer-other-frame.

Select buffer bufname in another frame. This runs switch-to-buffer-other-frame.

C-x 5 f filename RET
C-x 5 f filename RET

访问文件filename并在另一帧中选择其缓冲区。这运行find-file-other-frame.请参阅访问文件

Visit file filename and select its buffer in another frame. This runs find-file-other-frame. See Visiting Files.

C-x 5 d directory RET
C-x 5 d directory RET

为另一帧中的目录目录选择 Dired 缓冲区。这运行dired-other-frame.请参阅Dired,目录编辑器

Select a Dired buffer for directory directory in another frame. This runs dired-other-frame. See Dired, the Directory Editor.

C-x 5 m
C-x 5 m

开始在另一个框架中撰写邮件消息。这运行 compose-mail-other-frame.它是 的其他框架变体 C-x m。请参阅发送邮件

Start composing a mail message in another frame. This runs compose-mail-other-frame. It is the other-frame variant of C-x m. See Sending Mail.

C-x 5 .
C-x 5 .

在另一个框架中查找标识符的定义。这运行的是 xref-find-definitions-other-frame的多帧变体M-.。请参阅查找标识符参考

Find the definition of an identifier in another frame. This runs xref-find-definitions-other-frame, the multiple-frame variant of M-.. See Find Identifier References.

C-x 5 r filename RET
C-x 5 r filename RET

只读访问文件filename,并在另一帧中选择其缓冲区。这运行find-file-read-only-other-frame.请参阅访问文件

Visit file filename read-only, and select its buffer in another frame. This runs find-file-read-only-other-frame. See Visiting Files.

C-x 5 5
C-x 5 5

更通用的前缀命令,影响在此前缀命令 ( ) 之后立即调用的下一个命令显示的缓冲区other-frame-prefix。它请求在另一帧中显示下一个命令的缓冲区。

A more general prefix command that affects the buffer displayed by the next command invoked immediately after this prefix command (other-frame-prefix). It requests the buffer of the next command to be displayed in another frame.

您可以通过指定框架参数来控制新创建的框架的外观和行为。请参阅帧参数

You can control the appearance and behavior of the newly-created frames by specifying frame parameters. See Frame Parameters.


22.7 帧命令

22.7 Frame Commands

以下命令用于删除和操作帧:

The following commands are used to delete and operate on frames:

C-x 5 0
C-x 5 0

删除选定的帧 ( delete-frame)。如果只有一帧,则会发出错误信号。

Delete the selected frame (delete-frame). This signals an error if there is only one frame.

C-x 5 u
C-x 5 u

启用后undelete-frame-mode,取消删除最近删除的 16 个帧之一。如果没有前缀参数,则取消删除最近删除的帧。使用 1 到 16 之间的数字前缀参数(其中 1 是最近删除的帧),取消删除相应的已删除帧。

When undelete-frame-mode is enabled, undelete one of the 16 most recently deleted frames. Without a prefix argument, undelete the most recently deleted frame. With a numerical prefix argument between 1 and 16, where 1 is the most recently deleted frame, undelete the corresponding deleted frame.

C-z
C-z

最小化(或图标化)选定的 Emacs 框架 ( suspend-frame)。请参阅退出 Emacs

Minimize (or iconify) the selected Emacs frame (suspend-frame). See Exiting Emacs.

C-x 5 o
C-x 5 o

选择另一个框架并将其抬起。如果重复此命令,它将循环显示终端上的所有帧。

Select another frame, and raise it. If you repeat this command, it cycles through all the frames on your terminal.

C-x 5 1
C-x 5 1

删除当前终端上除所选帧之外的所有帧。

Delete all frames on the current terminal, except the selected one.

M-F10
M-F10

切换当前帧的最大化状态。当框架最大化时,它会填满屏幕。

Toggle the maximization state of the current frame. When a frame is maximized, it fills the screen.

F11
F11

切换当前帧的全屏模式。 (全屏和最大化之间的区别通常是前者隐藏了窗口管理器装饰,为 Emacs 本身提供了更多的屏幕空间。)

Toggle full-screen mode for the current frame. (The difference between full-screen and maximized is normally that the former hides window manager decorations, giving slightly more screen space to Emacs itself.)

请注意,对于某些窗口管理器,您可能必须将变量自定义frame-resize-pixelwise为非值nil才能使框架真正最大化或全屏。当该变量设置为非值时nil,通常允许以像素分辨率而不是行和列的整数倍来调整帧大小。

Note that with some window managers you may have to customize the variable frame-resize-pixelwise to a non-nil value in order to make a frame truly maximized or full-screen. This variable, when set to a non-nil value, in general allows resizing frames at pixel resolution, rather than in integral multiples of lines and columns.

C-x 5 0( )命令delete-frame删除选定的帧。但是,它会拒绝删除 Emacs 会话中的最后一帧,以防止您失去与 Emacs 会话交互的能力。请注意,当 Emacs 作为守护程序运行时(请参阅使用 Emacs 作为服务器),在删除所有普通的交互式框架后,始终会保留一个虚拟框架。这种情况下,C-x 5 0可以删除最后一个交互帧;您可以使用 emacsclient它重新连接到 Emacs 会话。

The C-x 5 0 (delete-frame) command deletes the selected frame. However, it will refuse to delete the last frame in an Emacs session, to prevent you from losing the ability to interact with the Emacs session. Note that when Emacs is run as a daemon (see Using Emacs as a Server), there is always a virtual frame that remains after all the ordinary, interactive frames are deleted. In this case, C-x 5 0 can delete the last interactive frame; you can use emacsclient to reconnect to the Emacs session.

C-x 5 1( )命令delete-other-frames删除当前终端上的所有其他框架(此终端指的是图形显示或文本终端;请参阅文本终端)。如果 Emacs 会话在其他图形显示器或文本终端上打开了框架,则不会删除这些框架。

The C-x 5 1 (delete-other-frames) command deletes all other frames on the current terminal (this terminal refers to either a graphical display, or a text terminal; see Text Terminals). If the Emacs session has frames open on other graphical displays or text terminals, those are not deleted.

C-x 5 o( )命令other-frame选择当前终端上的下一帧。如果您在 X Window 系统上使用带有窗口管理器的 Emacs,该窗口管理器选择(或将焦点置于)鼠标光标所在的任何帧,则必须将该变量更改focus-follows-mouse为 ,t以便该命令正常工作。然后调用C-x 5 o还会将鼠标光标扭曲到所选帧。

The C-x 5 o (other-frame) command selects the next frame on the current terminal. If you are using Emacs on the X Window System with a window manager that selects (or gives focus to) whatever frame the mouse cursor is over, you have to change the variable focus-follows-mouse to t in order for this command to work properly. Then invoking C-x 5 o will also warp the mouse cursor to the chosen frame.


22.8 字体

22.8 Fonts

默认情况下,Emacs 使用 10 点等宽字体在图形显示器上显示文本,并且可以交互更改字体大小(请参阅文本比例)。

By default, Emacs displays text on graphical displays using a 10-point monospace font, and the font size can be changed interactively (see Text Scale).

有几种不同的方法可以指定不同的字体:

There are several different ways to specify a different font:

  • 点击 '设置默认字体' 在里面 '选项' 菜单。这使得所选字体成为所有现有图形框架上的默认字体。要保存此内容以供将来的会话使用,请单击“保存选项' 在里面 '选项' 菜单。
  • Click on ‘Set Default Font’ in the ‘Options’ menu. This makes the selected font the default on all existing graphical frames. To save this for future sessions, click on ‘Save Options’ in the ‘Options’ menu.
  • 在初始化文件中添加一行,修改变量 default-frame-alist以指定font参数(请参阅帧参数),如下所示:
    (添加到列表“默认框架列表
                 '(字体。“DejaVu Sans Mono-10”))
    

    这使得该字体成为使用该 init 文件重新启动 Emacs 后创建的所有图形框架上的默认字体。

  • Add a line to your init file, modifying the variable default-frame-alist to specify the font parameter (see Frame Parameters), like this:
    (add-to-list 'default-frame-alist
                 '(font . "DejaVu Sans Mono-10"))
    

    This makes the font the default on all graphical frames created after restarting Emacs with that init file.

  • 添加一个 'emacs.字体' X 资源设置到您的 X 资源文件,如下所示:
    emacs.font: DejaVu Sans Mono-12
    

    必须重新启动X,或者使用该xrdb命令,X资源文件才能生效。请参阅X 资源。不要在 X 资源文件中引用字体名称。

  • Add an ‘emacs.font’ X resource setting to your X resource file, like this:
    emacs.font: DejaVu Sans Mono-12
    

    You must restart X, or use the xrdb command, for the X resources file to take effect. See X Resources. Do not quote font names in X resource files.

  • font-use-system-font如果您在 GNOME 桌面或 Haiku 上运行 Emacs,则可以通过将变量设置为t(默认值为nil)来告诉 Emacs 调整框架的默认字体以及对默认系统字体的更改 。为此,Emacs 必须在编译时支持 Gsettings(或旧版 Gconf)。 (具体来说,使用的 Gsettings 配置名称是 'org.gnome.desktop.interface 等宽字体名称' 和 'org.gnome.desktop.interface 字体名称'。)
  • If you are running Emacs on the GNOME desktop or Haiku, you can tell Emacs to adjust the frame’s default font along with changes to the default system font by setting the variable font-use-system-font to t (the default is nil). For this to work, Emacs must have been compiled with support for Gsettings (or the older Gconf). (To be specific, the Gsettings configuration names used are ‘org.gnome.desktop.interface monospace-font-name’ and ‘org.gnome.desktop.interface font-name’.)
  • 使用命令行选项'-fn' (或者 '--字体')。请参阅字体规范选项
  • Use the command line option ‘-fn’ (or ‘--font’). See Font Specification Options.

要检查您当前使用的字体,该C-u C-x = 命令可能会有所帮助。它描述了该点的字符,并命名了它所呈现的字体。

To check what font you’re currently using, the C-u C-x = command can be helpful. It describes the character at point, and names the font that it’s rendered in.

有四种不同的方式来表达字体名称。第一种是使用Fontconfig 模式。 Fontconfig 模式具有以下形式:

There are four different ways to express a font name. The first is to use a Fontconfig pattern. Fontconfig patterns have the following form:

字体名称[-字体大小][:名称 1 =值 1 ][:名称 2 =值 2 ]...
fontname[-fontsize][:name1=values1][:name2=values2]...

在此格式中,括号中的任何元素都可以省略。这里,fontname是字体的家族名称,例如'等宽字体' 或者 'DejaVu Sans Mono'; fontsize是 字体的磅值(一台打印机的磅值约为 1/72 英寸);和'名称=' 条目指定字体的倾斜度和粗细等设置。每个 可以是单个值,也可以是用逗号分隔的值列表。此外,某些属性值仅对一种属性名称有效,在这种情况下 '姓名=' 部分可以省略。

Within this format, any of the elements in brackets may be omitted. Here, fontname is the family name of the font, such as ‘Monospace’ or ‘DejaVu Sans Mono’; fontsize is the point size of the font (one printer’s point is about 1/72 of an inch); and the ‘name=values’ entries specify settings such as the slant and weight of the font. Each values may be a single value, or a list of values separated by commas. In addition, some property values are valid with only one kind of property name, in which case the ‘name=’ part may be omitted.

以下是常见字体属性的列表:

Here is a list of common font properties:

'倾斜'
slant

其中之一'斜体','', 或者 '罗马'。

One of ‘italic’, ‘oblique’, or ‘roman’.

'重量'
weight

其中之一'','中等的','德米博尔德','大胆的' 或者 '黑色的'。

One of ‘light’, ‘medium’, ‘demibold’, ‘bold’ or ‘black’.

'风格'
style

某些字体定义了特殊样式,它们是倾斜和粗细的组合。例如, 'Dejavu Sans' 定义了 '' 样式,它会覆盖倾斜和粗细属性。

Some fonts define special styles which are a combination of slant and weight. For instance, ‘Dejavu Sans’ defines the ‘book’ style, which overrides the slant and weight properties.

'宽度'
width

其中之一'浓缩的','普通的', 或者 '扩大'。

One of ‘condensed’, ‘normal’, or ‘expanded’.

'间距'
spacing

其中之一'等宽字体','成比例的','双宽度', 或者 '查塞尔'。

One of ‘monospace’, ‘proportional’, ‘dual-width’, or ‘charcell’.

以下是 Fontconfig 模式的一些示例:

Here are some examples of Fontconfig patterns:

等宽字体
等宽字体-12
Monospace-12:粗体
DejaVu Sans Mono:粗体:斜体
Monospace-12:粗细=粗体:倾斜=斜体
Monospace
Monospace-12
Monospace-12:bold
DejaVu Sans Mono:bold:italic
Monospace-12:weight=bold:slant=italic

有关 Fontconfig 模式的更详细描述,请参阅 Fontconfig 手册,该手册随 Fontconfig 一起分发,并可在https://fontconfig.org/fontconfig-user.html在线获取。

For a more detailed description of Fontconfig patterns, see the Fontconfig manual, which is distributed with Fontconfig and available online at https://fontconfig.org/fontconfig-user.html.

在 MS-Windows 上,所有字体仅支持fontname [- fontsize ]形式的子集 ;完整的 Fontconfig 模式可能不适用于所有这些。

On MS-Windows, only the subset of the form fontname[-fontsize] is supported for all fonts; the full Fontconfig pattern might not work for all of them.

指定字体的第二种方法是使用GTK 字体模式。这些有语法

The second way to specify a font is to use a GTK font pattern. These have the syntax

字体名称[属性] [字体大小]
fontname [properties] [fontsize]

其中fontname是家族名称,properties是由空格分隔的属性值列表,fontsize是磅值。您可以为 GTK 字体模式指定的属性如下:

where fontname is the family name, properties is a list of property values separated by spaces, and fontsize is the point size. The properties that you may specify for GTK font patterns are as follows:

  • 倾斜属性:'斜体' 或者 ''。如果省略,则暗示默认(罗马)倾斜。
  • Slant properties: ‘Italic’ or ‘Oblique’. If omitted, the default (roman) slant is implied.
  • 重量属性:'大胆的','','','中等的','半粗体', 或者 '超轻'。如果省略,'中等的' 隐含重量。
  • Weight properties: ‘Bold’, ‘Book’, ‘Light’, ‘Medium’, ‘Semi-bold’, or ‘Ultra-light’. If omitted, ‘Medium’ weight is implied.
  • 宽度属性:'半凝结' 或者 '浓缩'。如果省略,则使用默认宽度。
  • Width properties: ‘Semi-Condensed’ or ‘Condensed’. If omitted, a default width is used.

以下是 GTK 字体模式的一些示例:

Here are some examples of GTK font patterns:

等宽字体 12
等宽粗斜体 12
Monospace 12
Monospace Bold Italic 12

在 MS-Windows 上,仅支持 子集字体名。

On MS-Windows, only the subset fontname is supported.

指定字体的第三种方法是使用XLFDX 逻辑字体描述)。这是 X 下指定字体的传统方法,MS-Windows 也支持。每个 XLFD 由 14 个单词或数字组成,用破折号分隔,如下所示:

The third way to specify a font is to use an XLFD (X Logical Font Description). This is the traditional method for specifying fonts under X, and is also supported on MS-Windows. Each XLFD consists of fourteen words or numbers, separated by dashes, like this:

-misc-固定-中-r-半凝--13-*-*-*-c-60-iso8859-1
-misc-fixed-medium-r-semicondensed--13-*-*-*-c-60-iso8859-1

通配符 ('*XLFD 中的 ') 匹配任何字符序列(包括无),并且 '' 匹配任何单个字符。但是,匹配取决于实现,并且当通配符与长名称中的破折号匹配时可能不准确。为了获得可靠的结果,请提供全部 14 个破折号并仅在字段内使用通配符。大小写在 XLFD 中无关紧要。 XLFD 的语法如下:

A wildcard character (‘*’) in an XLFD matches any sequence of characters (including none), and ‘?’ matches any single character. However, matching is implementation-dependent, and can be inaccurate when wildcards match dashes in a long name. For reliable results, supply all 14 dashes and use wildcards only within a field. Case is insignificant in an XLFD. The syntax for an XLFD is as follows:

-制造商-家庭-重量-倾斜-宽度类型-风格......
…-像素-高度-水平-垂直-间距-宽度-注册表-编码
-maker-family-weight-slant-widthtype-style…
…-pixels-height-horiz-vert-spacing-width-registry-encoding

这些条目具有以下含义:

The entries have the following meanings:

制作者
maker

字体制造商的名称。

The name of the font manufacturer.

家庭
family

字体系列的名称(例如,'导游')。

The name of the font family (e.g., ‘courier’).

重量
weight

字体粗细——通常是 '大胆的','中等的' 或者 ''。某些字体名称支持其他值。

The font weight—normally either ‘bold’, ‘medium’ or ‘light’. Some font names support other values.

倾斜
slant

字体倾斜——通常是'r'(罗马),''(斜体),''(斜),''(反向斜体),或 '奥特' (其他)。某些字体名称支持其他值。

The font slant—normally ‘r’ (roman), ‘i’ (italic), ‘o’ (oblique), ‘ri’ (reverse italic), or ‘ot’ (other). Some font names support other values.

宽度类型
widthtype

字体宽度——通常为 '普通的','浓缩的','半凝聚态', 或者 '扩展'。某些字体名称支持其他值。

The font width—normally ‘normal’, ‘condensed’, ‘semicondensed’, or ‘extended’. Some font names support other values.

风格
style

可选的附加样式名称。通常它是空的——大多数 XLFD 此时都有两个连续的连字符。样式名称还可以指定两个字母的 ISO-639 语言名称,例如 '' 或者 '';一些支持 CJK 脚本的字体在样式名称部分中有拼写。

An optional additional style name. Usually it is empty—most XLFDs have two hyphens in a row at this point. The style name can also specify a two-letter ISO-639 language name, like ‘ja’ or ‘ko’; some fonts that support CJK scripts have that spelled out in the style name part.

像素
pixels

字体高度,以像素为单位。

The font height, in pixels.

高度
height

屏幕上的字体高度,以打印机点的十分之一为单位测量。这是字体的磅值乘以十。对于给定的垂直分辨率,高度像素成正比;因此,通常只指定其中之一并使用 '*' 对于另一个。

The font height on the screen, measured in tenths of a printer’s point. This is the point size of the font, times ten. For a given vertical resolution, height and pixels are proportional; therefore, it is common to specify just one of them and use ‘*’ for the other.

水平
horiz

字体所针对的屏幕的水平分辨率(以每英寸像素为单位)。

The horizontal resolution, in pixels per inch, of the screen for which the font is intended.

垂直
vert

字体所针对的屏幕的垂直分辨率(以每英寸像素为单位)。通常,系统上字体的分辨率是适合您屏幕的值;因此,您通常指定 '*'为此和水平

The vertical resolution, in pixels per inch, of the screen for which the font is intended. Normally the resolution of the fonts on your system is the right value for your screen; therefore, you normally specify ‘*’ for this and horiz.

间距
spacing

这是 ''(等宽字体),'p'(按比例)或 'C'(字符单元格)。

This is ‘m’ (monospace), ‘p’ (proportional) or ‘c’ (character cell).

宽度
width

平均字符宽度(以像素为单位)乘以十。

The average character width, in pixels, multiplied by ten.

注册表
registry
编码
encoding

字体描述的 X 字体字符集。 (X 字体字符集与 Emacs 字符集不同,但它们很相似。)您可以使用该xfontsel程序来检查您有哪些选择。通常你应该使用 'ISO8859' 用于注册表和 '1' 用于编码

The X font character set that the font depicts. (X font character sets are not the same as Emacs character sets, but they are similar.) You can use the xfontsel program to check which choices you have. Normally you should use ‘iso8859’ for registry and ‘1’ for encoding.

指定字体的第四种也是最后一种方法是使用字体昵称。某些字体具有较短的昵称,您可以使用它们来代替正常的字体规范。例如, '6x13' 相当于

The fourth and final method of specifying a font is to use a font nickname. Certain fonts have shorter nicknames, which you can use instead of a normal font specification. For instance, ‘6x13’ is equivalent to

-misc-固定-中-r-半凝--13-*-*-*-c-60-iso8859-1
-misc-fixed-medium-r-semicondensed--13-*-*-*-c-60-iso8859-1

MS-Windows 不支持此形式。

This form is not supported on MS-Windows.

在 X 上,Emacs 识别两种类型的字体:客户端字体(由 Xft 和 Fontconfig 库提供)和 服务器端字体(由 X 服务器本身提供)。大多数客户端字体支持高级字体功能,例如抗锯齿和子像素提示,而服务器端字体则不支持。 Fontconfig 和 GTK 模式仅匹配客户端字体。

On X, Emacs recognizes two types of fonts: client-side fonts, which are provided by the Xft and Fontconfig libraries, and server-side fonts, which are provided by the X server itself. Most client-side fonts support advanced font features such as antialiasing and subpixel hinting, while server-side fonts do not. Fontconfig and GTK patterns match only client-side fonts.

您可能想要使用固定宽度的默认字体,即所有字符都具有相同宽度的字体。对于 Xft 和 Fontconfig 字体,您可以使用该fc-list命令列出可用的固定宽度字体,如下所示:

You will probably want to use a fixed-width default font—that is, a font in which all characters have the same width. For Xft and Fontconfig fonts, you can use the fc-list command to list the available fixed-width fonts, like this:

fc-列表 :spacing=mono
fc-list :spacing=charcell
fc-list :spacing=mono
fc-list :spacing=charcell

对于服务器端 X 字体,您可以使用该xlsfonts程序列出可用的固定宽度字体,如下所示:

For server-side X fonts, you can use the xlsfonts program to list the available fixed-width fonts, like this:

xlsfonts -fn '*x*' | xlsfonts -fn '*x*' | grep -E '^[0-9]+x[0-9]+'
xlsfonts -fn '*-*-*-*-*-*-*-*-*-*-*-m*'
xlsfonts -fn '*-*-*-*-*-*-*-*-*-*-*-c*'
xlsfonts -fn '*x*' | grep -E '^[0-9]+x[0-9]+'
xlsfonts -fn '*-*-*-*-*-*-*-*-*-*-*-m*'
xlsfonts -fn '*-*-*-*-*-*-*-*-*-*-*-c*'

任何带有 ' 的字体' 或者 'CXLFD 的间距字段中的 '是固定宽度字体。要查看特定字体的外观,请使用该xfd命令。例如:

Any font with ‘m’ or ‘c’ in the spacing field of the XLFD is a fixed-width font. To see what a particular font looks like, use the xfd command. For example:

xfd-fn 6x13
xfd -fn 6x13

显示整个字体 '6x13'。

displays the entire font ‘6x13’.

运行 Emacs 时,您还可以设置特定类型文本的字体(请参阅Text Faces)或特定框架(请参阅框架参数)。

While running Emacs, you can also set the font of a specific kind of text (see Text Faces), or a particular frame (see Frame Parameters).


22.9 速度条框架

22.9 Speedbar Frames

速度栏是一个特殊的框架,用于方便地在另一个框架中导航或操作。速度栏,当它存在时,总是与一个特定的框架相关联,称为它的附加框架;所有速度栏操作都作用于该帧。

The speedbar is a special frame for conveniently navigating in or operating on another frame. The speedbar, when it exists, is always associated with a specific frame, called its attached frame; all speedbar operations act on that frame.

键入M-x speedbar以创建速度栏并将其与当前帧关联。要关闭速度栏,请M-x speedbar 再次键入,或选择速度栏并键入q。 (您也可以像删除任何其他 Emacs 框架一样删除速度栏框架。)如果您希望将速度栏与其他框架关联,请将其关闭并 M-x speedbar从该框架调用。

Type M-x speedbar to create the speedbar and associate it with the current frame. To dismiss the speedbar, type M-x speedbar again, or select the speedbar and type q. (You can also delete the speedbar frame like any other Emacs frame.) If you wish to associate the speedbar with a different frame, dismiss it and call M-x speedbar from that frame.

速度栏可以在多种模式下运行。其默认模式为 文件显示模式,即显示附加框所选窗口当前目录下的文件,每行一个文件。单击非目录可在附加框架的选定窗口中访问该文件,单击目录会在速度栏中显示该目录(请参阅使用鼠标跟踪参考)。每行还有一个框,'[+]' 或者 '<+>',您可以单击它来 展开该项目的内容。展开目录会将该目录的内容添加到速度栏显示中,位于该目录自己的行下方。展开普通文件会将该文件中的标签列表添加到速度栏显示中;您可以单击标签名称以跳转到附加框架的选定窗口中的该标签。当文件或目录展开时,'[+]' 更改为 '[-]';您可以单击该框来收缩该项目,隐藏其内容。

The speedbar can operate in various modes. Its default mode is File Display mode, which shows the files in the current directory of the selected window of the attached frame, one file per line. Clicking on a non-directory visits that file in the selected window of the attached frame, and clicking on a directory shows that directory in the speedbar (see Following References with the Mouse). Each line also has a box, ‘[+]’ or ‘<+>’, that you can click on to expand the contents of that item. Expanding a directory adds the contents of that directory to the speedbar display, underneath the directory’s own line. Expanding an ordinary file adds a list of the tags in that file to the speedbar display; you can click on a tag name to jump to that tag in the selected window of the attached frame. When a file or directory is expanded, the ‘[+]’ changes to ‘[-]’; you can click on that box to contract the item, hiding its contents.

您也可以使用键盘在速度栏上导航。当点位于速度栏中的一行上时键入 RET相当于单击当前行上的项目,并SPC展开或收缩该项目。 U显示当前目录的父目录。要复制、删除或重命名当前行上的文件,请分别键入CDR。要创建新目录,请键入M

You navigate through the speedbar using the keyboard, too. Typing RET while point is on a line in the speedbar is equivalent to clicking the item on the current line, and SPC expands or contracts the item. U displays the parent directory of the current directory. To copy, delete, or rename the file on the current line, type C, D, and R respectively. To create a new directory, type M.

另一种通用的速度条模式是缓冲区显示模式;在此模式下,速度栏显示 Emacs 缓冲区列表。要切换到此模式,请b在速度栏中输入。要返回文件显示模式,请键入f。您还可以通过单击mouse-3速度栏窗口(或 mouse-1模式行)中的任意位置并选择“来更改显示模式”显示器' 在弹出菜单中。

Another general-purpose speedbar mode is Buffer Display mode; in this mode, the speedbar displays a list of Emacs buffers. To switch to this mode, type b in the speedbar. To return to File Display mode, type f. You can also change the display mode by clicking mouse-3 anywhere in the speedbar window (or mouse-1 on the mode-line) and selecting ‘Displays’ in the pop-up menu.

一些主要模式,包括Rmail模式、Info和GUD,都有专门的方法将有用的项目放入速度栏中供您选择。例如,在 Rmail 模式下,速度栏显示 Rmail 文件列表,并允许您通过单击其“将当前邮件移动到另一个 Rmail 文件”<M>' 盒子。

Some major modes, including Rmail mode, Info, and GUD, have specialized ways of putting useful items into the speedbar for you to select. For example, in Rmail mode, the speedbar shows a list of Rmail files, and lets you move the current message to another Rmail file by clicking on its ‘<M>’ box.

有关使用和编程 speedbar 的更多详细信息,请参阅Speedbar 手册中的Speedbar

For more details on using and programming the speedbar, See Speedbar in Speedbar Manual.


22.10 多重显示

22.10 Multiple Displays

一台 Emacs 可以与多个 X 显示器通信。最初,Emacs 仅使用一种显示 — 使用DISPLAY 环境变量或使用 '指定的显示- 展示' 选项(参见初始选项)。要连接到另一个显示器,请使用以下命令 make-frame-on-display

A single Emacs can talk to more than one X display. Initially, Emacs uses just one display—the one specified with the DISPLAY environment variable or with the ‘--display’ option (see Initial Options). To connect to another display, use the command make-frame-on-display:

M-x make-frame-on-display RET display RET
M-x make-frame-on-display RET display RET

在显示屏display上创建一个新框架。

Create a new frame on display display.

一台 X 服务器可以处理多个屏幕。当您在属于一台服务器的两个屏幕上打开框架时,Emacs 知道它们共享一个键盘,并且它将来自这些屏幕的所有命令视为单个输入流。

A single X server can handle more than one screen. When you open frames on two screens belonging to one server, Emacs knows they share a single keyboard, and it treats all the commands arriving from these screens as a single stream of input.

当您在不同的 X 服务器上打开框架时,Emacs 会为每个服务器创建一个单独的输入流。每个服务器也有自己选择的框架。您通过特定 X 服务器输入的命令适用于该服务器的选定框架。

When you open frames on different X servers, Emacs makes a separate input stream for each server. Each server also has its own selected frame. The commands you enter with a particular X server apply to that server’s selected frame.

在多显示器显示器上,可以使用以下命令 make-frame-on-monitor

On multi-monitor displays it is possible to use the command make-frame-on-monitor:

M-x make-frame-on-monitor RET monitor RET
M-x make-frame-on-monitor RET monitor RET

在监视器上创建一个新框架,其屏幕区域是当前显示的一部分。

Create a new frame on monitor monitor whose screen area is a part of the current display.


22.11 帧参数

22.11 Frame Parameters

您可以通过在变量中 指定默认的框架参数列表来控制所有框架的默认外观和行为default-frame-alist。它的值应该是一个条目列表,每个条目指定一个参数名称和该参数的值。每当 Emacs 创建新框架(包括初始框架)时,这些条目就会生效。

You can control the default appearance and behavior of all frames by specifying a default list of frame parameters in the variable default-frame-alist. Its value should be a list of entries, each specifying a parameter name and a value for that parameter. These entries take effect whenever Emacs creates a new frame, including the initial frame.

例如,您可以将以下行添加到 init 文件(请参阅Emacs 初始化文件),以将默认框架宽度设置为 90 个字符列,将默认框架高度设置为 40 个字符行,并将默认字体设置为 '等宽字体-10':

For example, you can add the following lines to your init file (see The Emacs Initialization File) to set the default frame width to 90 character columns, the default frame height to 40 character rows, and the default font to ‘Monospace-10’:

(添加到列表“default-frame-alist”(宽度。90))
(添加到列表“default-frame-alist”(高度。40))
(添加到列表'default-frame-alist'(字体。“Monospace-10”))
(add-to-list 'default-frame-alist '(width  . 90))
(add-to-list 'default-frame-alist '(height . 40))
(add-to-list 'default-frame-alist '(font . "Monospace-10"))

有关框架参数及其效果的列表,请参阅Emacs Lisp 参考手册中的框架参数

For a list of frame parameters and their effects, see Frame Parameters in The Emacs Lisp Reference Manual.

您还可以通过自定义变量 来指定仅适用于初始帧的帧参数列表 initial-frame-alist

You can also specify a list of frame parameters which apply to just the initial frame, by customizing the variable initial-frame-alist.

如果 Emacs 被编译为使用 X 工具包,则指定颜色和字体的框架参数不会影响菜单和菜单栏,因为它们是由工具包绘制的,而不是直接由 Emacs 绘制的。

If Emacs is compiled to use an X toolkit, frame parameters that specify colors and fonts don’t affect menus and the menu bar, since those are drawn by the toolkit and not directly by Emacs.

框架外观和行为也可以通过 X 资源进行定制(参见X 选项和资源);这些会覆盖 init 文件中指定的初始帧的参数。

Frame appearance and behavior can also be customized through X resources (see X Options and Resources); these override the parameters of the initial frame specified in your init file.

请注意,如果您使用桌面库保存和恢复会话,则要恢复的帧及其参数将记录在桌面文件中。恢复这些帧时,记录的参数优先于 init 文件中指定的帧default-frame-alist参数initial-frame-alist 。请参阅保存 Emacs 会话,了解如何避免这种情况。

Note that if you are using the desktop library to save and restore your sessions, the frames to be restored are recorded in the desktop file, together with their parameters. When these frames are restored, the recorded parameters take precedence over the frame parameters specified by default-frame-alist and initial-frame-alist in your init file. See Saving Emacs Sessions, for how to avoid that.


22.12 滚动条

22.12 Scroll Bars

在图形显示上,每个 Emacs 窗口的侧面都有一个垂直滚动条。单击mouse-1滚动条的向上和向下按钮可将窗口一次滚动一行(但某些工具包允许您自定义滚动条以不显示这些按钮)。单击mouse-1滚动条内部框的上方或下方可将窗口滚动几乎整个窗口的高度,分别与M-vC-v类似(请参阅更改点的位置)。 (对于某些工具包,这也可能有不同的行为。)拖动内部框会连续滚动。

On graphical displays, there is a vertical scroll bar on the side of each Emacs window. Clicking mouse-1 on the scroll bar’s up and down buttons scrolls the window by one line at a time (but some toolkits allow you to customize the scroll bars to not have those buttons). Clicking mouse-1 above or below the scroll bar’s inner box scrolls the window by nearly the entire height of the window, like M-v and C-v respectively (see Changing the Location of Point). (This, too, can behave differently with some toolkits.) Dragging the inner box scrolls continuously.

如果 Emacs 是在没有 X 工具包支持的 X Window 系统上编译的,则滚动条的行为会有所不同。单击mouse-1 滚动条上的任意位置,向前滚动,如C-v,而 mouse-3向后滚动,如M-v。单击mouse-2 滚动条可以上下拖动内部框。

If Emacs is compiled on the X Window System without X toolkit support, the scroll bar behaves differently. Clicking mouse-1 anywhere on the scroll bar scrolls forward like C-v, while mouse-3 scrolls backward like M-v. Clicking mouse-2 in the scroll bar lets you drag the inner box up and down.

要切换垂直滚动条的使用,请键入M-x scroll-bar-mode。该命令适用于所有帧,包括尚未创建的帧。要仅切换所选帧的垂直滚动条,请使用命令M-x toggle-scroll-bar

To toggle the use of vertical scroll bars, type M-x scroll-bar-mode. This command applies to all frames, including frames yet to be created. To toggle vertical scroll bars for just the selected frame, use the command M-x toggle-scroll-bar.

要在启动时控制垂直滚动条的使用,请自定义变量scroll-bar-mode(请参阅自定义)。它的值应该是right(将滚动条放在窗口的右侧)、left(将它们放在左侧)或nil(禁用垂直滚动条)。默认情况下,如果 Emacs 是在 X Window 系统、MS-Windows 或 macOS 上使用 GTK+ 支持编译的,那么它会将滚动条放在右侧;如果在没有 GTK+ 支持的 X Window 系统上编译,Emacs 会将滚动条放在左侧(遵循 X 应用程序的旧约定)。

To control the use of vertical scroll bars at startup, customize the variable scroll-bar-mode (see Customization). Its value should be either right (put scroll bars on the right side of windows), left (put them on the left), or nil (disable vertical scroll bars). By default, Emacs puts scroll bars on the right if it was compiled with GTK+ support on the X Window System, and on MS-Windows or macOS; Emacs puts scroll bars on the left if compiled on the X Window System without GTK+ support (following the old convention for X applications).

您还可以使用 X 资源'垂直滚动条' 启用或禁用滚动条(请参阅X 资源)。要控制滚动条宽度,请更改scroll-bar-width框架参数(请参阅Emacs Lisp 参考手册中的框架参数)。

You can also use the X resource ‘verticalScrollBars’ to enable or disable the scroll bars (see X Resources). To control the scroll bar width, change the scroll-bar-width frame parameter (see Frame Parameters in The Emacs Lisp Reference Manual).

如果您在 X 上使用 Emacs(使用 GTK+ 或 Motif),您可以自定义变量scroll-bar-adjust-thumb-portion来控制 滚动条的过度滚动,即,即使缓冲区末尾可见,也可以向下拖动拇指。如果其值为非- nil,则即使显示缓冲区末尾,滚动条也可以向下拖动;如果nil,则当显示缓冲区末尾时,拇指将位于底部。当整个缓冲区可见时,您无法过度滚动。

If you’re using Emacs on X (with GTK+ or Motif), you can customize the variable scroll-bar-adjust-thumb-portion to control overscrolling of the scroll bar, i.e., dragging the thumb down even when the end of the buffer is visible. If its value is non-nil, the scroll bar can be dragged downwards even if the end of the buffer is shown; if nil, the thumb will be at the bottom when the end of the buffer is shown. You cannot over-scroll when the entire buffer is visible.

滚动条的视觉外观由面部控制 scroll-bar。 (某些工具包,例如 GTK+ 和 MS-Windows,忽略此界面;那里的滚动条外观只能在系统范围内自定义,对于 GTK+,请参阅GTK+ 资源)。

The visual appearance of the scroll bars is controlled by the scroll-bar face. (Some toolkits, such as GTK+ and MS-Windows, ignore this face; the scroll-bar appearance there can only be customized system-wide, for GTK+ see GTK+ resources).

在图形框架上,垂直滚动条隐式地用于在视觉上分隔并排窗口。当垂直滚动条被禁用时,Emacs 默认情况下会借助一像素宽的垂直边框来分隔此类窗口。该边框占据右侧窗口的第一个像素列,因此可能会过度绘制此处显示的任何字形的最左侧像素。如果这些像素传达重要信息,您可以通过启用窗口分隔符使它们可见,请参阅 窗口分隔符。要复制垂直边框的外观,请将right-divider-width框架参数设置为 1,并让 面继承Emacs Lisp 参考手册中的窗口分隔符的 window-divider面。 vertical-border

On graphical frames, vertical scroll bars implicitly serve to separate side-by-side windows visually. When vertical scroll bars are disabled, Emacs by default separates such windows with the help of a one-pixel wide vertical border. That border occupies the first pixel column of the window on the right and may thus overdraw the leftmost pixels of any glyph displayed there. If these pixels convey important information, you can make them visible by enabling window dividers, see Window Dividers. To replicate the look of vertical borders, set the right-divider-width parameter of frames to one and have the window-divider face inherit from that of vertical-border, Window Dividers in The Emacs Lisp Reference Manual.

在具有工具包支持的图形显示上,Emacs 还可以 在每个窗口的底部提供水平滚动条。单击 mouse-1该滚动条的左右按钮可将窗口一次水平滚动一列。 (请注意,某些工具包允许自定义滚动条,从而导致这些按钮不显示。)单击mouse-1滚动条内部框的左侧或右侧可将窗口滚动四列。拖动内部框可连续滚动窗口。

On graphical displays with toolkit support, Emacs may also supply a horizontal scroll bar on the bottom of each window. Clicking mouse-1 on that scroll bar’s left and right buttons scrolls the window horizontally by one column at a time. (Note that some toolkits allow customizations of the scroll bar that cause these buttons not to be shown.) Clicking mouse-1 on the left or right of the scroll bar’s inner box scrolls the window by four columns. Dragging the inner box scrolls the window continuously.

请注意,这种水平滚动可能会使窗口的点位置在左侧或右侧消失。键入字符以插入文本或使用键盘命令移动点通常会将其带回到视图中。

Note that such horizontal scrolling can make the window’s position of point disappear on the left or the right. Typing a character to insert text or moving point with a keyboard command will usually bring it back into view.

要切换水平滚动条的使用,请键入M-x horizontal-scroll-bar-mode。该命令适用于所有帧,包括尚未创建的帧。要仅切换所选帧的水平滚动条,请使用命令M-x toggle-horizontal-scroll-bar

To toggle the use of horizontal scroll bars, type M-x horizontal-scroll-bar-mode. This command applies to all frames, including frames yet to be created. To toggle horizontal scroll bars for just the selected frame, use the command M-x toggle-horizontal-scroll-bar.

要控制启动时水平滚动条的使用,请自定义变量horizontal-scroll-bar-mode

To control the use of horizontal scroll bars at startup, customize the variable horizontal-scroll-bar-mode.

您还可以使用 X 资源'水平滚动条' 启用或禁用水平滚动条(请参阅X 资源)。要控制滚动条高度,请更改scroll-bar-height框架参数(请参阅Emacs Lisp 参考手册中的框架参数)。

You can also use the X resource ‘horizontalScrollBars’ to enable or disable horizontal scroll bars (see X Resources). To control the scroll bar height, change the scroll-bar-height frame parameter (see Frame Parameters in The Emacs Lisp Reference Manual).


22.13 窗分隔线

22.13 Window Dividers

在图形显示上,您可以使用窗口分隔线来直观地分隔窗口。窗口分隔线是可以用鼠标拖动的栏,从而使您可以轻松调整相邻窗口的大小。

On graphical displays, you can use window dividers in order to separate windows visually. Window dividers are bars that can be dragged with the mouse, thus allowing you to easily resize adjacent windows.

要切换窗口分隔线的显示,请使用命令M-x window-divider-mode

To toggle the display of window dividers, use the command M-x window-divider-mode.

要自定义分隔线应出现的位置,请使用选项 window-divider-default-places。它的值应该是 bottom-only(仅在窗口底部显示分隔线)、 right-only(仅在窗口右侧显示分隔线)或 t(在底部和右侧显示分隔线)。

To customize where dividers should appear, use the option window-divider-default-places. Its value should be either bottom-only (to show dividers only on the bottom of windows), right-only (to show dividers only on the right of windows), or t (to show them on the bottom and on the right).

要调整此模式显示的窗口分隔线的宽度,请自定义选项window-divider-default-bottom-widthwindow-divider-default-right-width

To adjust the width of window dividers displayed by this mode customize the options window-divider-default-bottom-width and window-divider-default-right-width.

当垂直滚动条被禁用时,分​​隔线也可用于使窗口的第一个像素列可见,否则该像素列将被用于分隔并排窗口的垂直边框覆盖(请参阅滚动条)。

When vertical scroll bars are disabled, dividers can be also useful to make the first pixel column of a window visible, which would be otherwise covered by the vertical border used to separate side-by-side windows (see Scroll Bars).

有关窗口分隔符的更多详细信息,请参阅Emacs Lisp 参考手册中的窗口分隔符

For more details about window dividers see Window Dividers in The Emacs Lisp Reference Manual.


22.14 拖放

22.14 Drag and Drop

在大多数图形桌面环境中,Emacs 都对拖放操作提供基本支持 。例如,将文本拖放到 Emacs 框架上会将文本插入到拖放的位置。将文件拖放到 Emacs 框架上即可访问该文件。作为一种特殊情况,将文件拖放到 Dired 缓冲区上会将该文件(根据其来源的应用程序的约定)移动或复制到该缓冲区中显示的目录中。

In most graphical desktop environments, Emacs has basic support for drag and drop operations. For instance, dropping text onto an Emacs frame inserts the text where it is dropped. Dropping a file onto an Emacs frame visits that file. As a special case, dropping the file on a Dired buffer moves or copies the file (according to the conventions of the application it came from) into the directory displayed in that buffer.

放置文件通常会在放置文件的窗口中访问该文件。如果您希望在这种情况下在新窗口中访问该文件,请自定义变量dnd-open-file-other-window

Dropping a file normally visits it in the window you drop it on. If you prefer to visit the file in a new window in such cases, customize the variable dnd-open-file-other-window.

目前支持 XDND 和 Motif 拖放协议以及旧的 KDE 1.x 协议。

The XDND and Motif drag and drop protocols, and the old KDE 1.x protocol, are currently supported.

将文本拖到 Emacs 窗口时,滚动窗口或确定插入文本的位置可能很困难。将该选项设置dnd-indicate-insertion-point为非nil值会使点移动到拖动期间鼠标在窗口中移动时插入任何放置的文本的位置,并且设置dnd-scroll-margin为整数值会导致如果鼠标在那么多行内移动则滚动窗口拖动期间窗口的顶部或底部。

It can be difficult to scroll a window or determine where dropped text will be inserted while dragging text onto an Emacs window. Setting the option dnd-indicate-insertion-point to a non-nil value makes point move to the location any dropped text will be inserted when the mouse moves in a window during drag, and setting dnd-scroll-margin to an integer value causes a window to be scrolled if the mouse moves within that many lines of the top or bottom of the window during drag.

Emacs 还可以选择使用鼠标将该区域拖动到该缓冲区或另一个缓冲区的另一部分中。要实现这一点,请将变量自定义mouse-drag-and-drop-region为非值nil 。通常,当目标与源位于同一缓冲区时,文本会被移动,即剪切和粘贴。将区域放到另一个缓冲区上会复制文本。如果此变量的值命名一个修饰键,例如 '转移','控制' 或者 '替代',然后在放置文本时按该修改键将复制它而不是剪切它,即使您放置在与文本来源相同的缓冲区上也是如此。

Emacs can also optionally drag the region with the mouse into another portion of this or another buffer. To enable that, customize the variable mouse-drag-and-drop-region to a non-nil value. Normally, the text is moved, i.e. cut and pasted, when the destination is the same buffer as the origin; dropping the region on another buffer copies the text instead. If the value of this variable names a modifier key, such as ‘shift’, ‘control’ or ‘alt’, then pressing that modifier key when dropping the text will copy it instead of cutting it, even if you drop on the same buffer as the one from which the text came.

为了在源缓冲区和目标缓冲区不同时剪切文本,请将该选项设置 mouse-drag-and-drop-region-cut-when-buffers-differ为非值nil。默认情况下,在图形显示上,选定的文本显示在工具提示中,并且在拖动过程中点与鼠标光标一起移动。要抑制此类行为,请将选项 mouse-drag-and-drop-region-show-tooltip和/或 设置mouse-drag-and-drop-region-show-cursornil

In order to cut text even when source and destination buffers differ, set the option mouse-drag-and-drop-region-cut-when-buffers-differ to a non-nil value. By default, on a graphic display the selected text is shown in a tooltip and point moves together with the mouse cursor during dragging. To suppress such behavior, set the options mouse-drag-and-drop-region-show-tooltip and/or mouse-drag-and-drop-region-show-cursor to nil.

要将文本从 Emacs 拖到其他程序,请将该选项设置 mouse-drag-and-drop-region-cross-program为非值nil

To drag text from Emacs to other programs, set the option mouse-drag-and-drop-region-cross-program to a non-nil value.

在 X window 系统上,某些程序可以将文件拖放到 Emacs 上,期望 Emacs 保存它们。通常,Emacs 会提示输入保存文件的文件名,然后打开该文件,但可以通过更改变量 来更改该行为 x-dnd-direct-save-function。请参阅《Emacs Lisp 参考手册》中的“拖放”

On the X window system, some programs can drop files on Emacs, expecting Emacs to save them. Normally, Emacs will prompt for a file name under which the file will be saved, and then open the file, but that behavior can be changed by changing the variable x-dnd-direct-save-function. See Drag and Drop in The Emacs Lisp Reference Manual.


22.16 工具栏

22.16 Tool Bars

在图形显示上,Emacs在每个框架的顶部放置一个工具栏,就在菜单栏的下方。这是一排图标,您可以用鼠标单击来调用各种命令。

On graphical displays, Emacs puts a tool bar at the top of each frame, just below the menu bar. This is a row of icons which you can click on with the mouse to invoke various commands.

全局(默认)工具栏包含常规命令。一些主要模式定义了自己的工具栏;每当具有此类主要模式的缓冲区处于当前状态时,该模式的工具栏就会替换全局工具栏。

The global (default) tool bar contains general commands. Some major modes define their own tool bars; whenever a buffer with such a major mode is current, the mode’s tool bar replaces the global tool bar.

要切换工具栏的使用,请键入M-x tool-bar-mode。该命令适用于所有帧,包括尚未创建的帧。要在启动时控制工具栏的使用,请自定义变量 tool-bar-mode

To toggle the use of tool bars, type M-x tool-bar-mode. This command applies to all frames, including frames yet to be created. To control the use of tool bars at startup, customize the variable tool-bar-mode.

当 Emacs 编译为支持 GTK+ 时,每个工具栏项都可以包含一个图像或一个文本标签,或两者都包含。默认情况下,Emacs 遵循 Gnome 桌面的工具栏样式设置;如果未定义,它将仅将工具栏项目显示为图像。要施加特定的工具栏样式,请自定义变量tool-bar-style

When Emacs is compiled with GTK+ support, each tool bar item can consist of an image, or a text label, or both. By default, Emacs follows the Gnome desktop’s tool bar style setting; if none is defined, it displays tool bar items as just images. To impose a specific tool bar style, customize the variable tool-bar-style.

您还可以使用框架参数控制 GTK+ 工具栏的工具栏位置tool-bar-position。请参阅Emacs Lisp 参考手册中的框架参数

You can also control the placement of the tool bar for the GTK+ tool bar with the frame parameter tool-bar-position. See Frame Parameters in The Emacs Lisp Reference Manual.

NS 构建将工具栏视为窗口装饰,因此当窗口未装饰时不会显示它。请参阅Emacs Lisp 参考手册中的框架参数。在 macOS 上,当框架进入全屏时,工具栏会隐藏,但可以通过将鼠标指针移动到屏幕顶部来显示。

NS builds consider the tool bar to be a window decoration, and therefore do not display it when a window is undecorated. See Frame Parameters in The Emacs Lisp Reference Manual. On macOS the tool bar is hidden when the frame is put into fullscreen, but can be displayed by moving the mouse pointer to the top of the screen.


22.17 标签栏

22.17 Tab Bars

在图形显示和文本终端上,Emacs 可以选择在每个框架的顶部、菜单栏正下方(请参阅菜单栏)以及工具栏(请参阅工具栏)上方或下方显示选项卡栏(具体取决于变量)。选项卡栏是一排选项卡按钮,您可以单击这些按钮在窗口配置之间进行切换。 tab-bar-position

On graphical displays and on text terminals, Emacs can optionally display a Tab Bar at the top of each frame, just below the menu bar (see Menu Bars) and above or below the tool bar (see Tool Bars) depending on the variable tab-bar-position. The Tab Bar is a row of tabs—buttons that you can click to switch between window configurations.

选项卡栏上的每个选项卡代表其框架的命名持久窗口配置,即该框架如何分区为窗口以及每个窗口中显示哪个缓冲区。选项卡的名称由该窗口配置的窗口中显示的缓冲区名称列表组成。点击选项卡切换到该选项卡记录的窗口配置;它是窗口和缓冲区的配置,当该选项卡是当前选项卡时,先前在框架中使用了该配置。

Each tab on the Tab Bar represents a named persistent window configuration of its frame, i.e., how that frame is partitioned into windows and which buffer is displayed in each window. The tab’s name is composed from the list of names of buffers shown in windows of that window configuration. Clicking on the tab switches to the window configuration recorded by the tab; it is a configuration of windows and buffers which was previously used in the frame when that tab was the current tab.

如果您使用桌面库来保存和恢复会话(请参阅保存 Emacs 会话),选项卡栏中的选项卡及其关联的窗口配置将记录在桌面文件中,并且在恢复会话后可用。

If you are using the desktop library to save and restore your sessions (see Saving Emacs Sessions), the tabs from the Tab Bar are recorded in the desktop file, together with their associated window configurations, and will be available after restoring the session.

请注意,选项卡栏与选项卡行不同(请参阅窗口选项卡行)。每个窗口顶部的选项卡行上的选项卡用于在窗口中的缓冲区之间切换,而每个框架顶部的选项卡栏上的选项卡用于在包含多个显示一个或多个缓冲区的窗口的窗口配置之间切换。

Note that the Tab Bar is different from the Tab Line (see Window Tab Line). Whereas tabs on the Tab Line at the top of each window are used to switch between buffers in the window, tabs on the Tab Bar at the top of each frame are used to switch between window configurations containing several windows showing one or more buffers.

要切换选项卡栏的使用,请键入M-x tab-bar-mode。该命令适用于所有帧,包括尚未创建的帧。要在启动时控制选项卡栏的使用,请自定义变量 tab-bar-mode并保存自定义设置。

To toggle the use of Tab Bars, type M-x tab-bar-mode. This command applies to all frames, including frames yet to be created. To control the use of tab bars at startup, customize the variable tab-bar-mode and save your customization.

该变量tab-bar-show控制是否自动打开选项卡栏模式。如果值为t,则 tab-bar-mode在使用创建新选项卡的命令时启用。该值1在只有一个选项卡时隐藏选项卡栏,并在创建更多选项卡时再次显示。更一般地,非负整数值会导致仅当选项卡数量大于该整数时才显示选项卡栏。该值nil始终使选项卡栏隐藏;在这种情况下,仍然可以使用 、 和其他提供选项卡名称补全功能的命令在命名窗口配置之间进行切换,而不显示选项卡M-x tab-nextM-x tab-switcher。此外,还可以使用命令 、 等在没有选项卡栏的情况下创建和关闭选项M-x tab-newM-x tab-close

The variable tab-bar-show controls whether the Tab Bar mode is turned on automatically. If the value is t, then tab-bar-mode is enabled when using the commands that create new tabs. The value 1 hides the tab bar when it has only one tab, and shows it again when more tabs are created. More generally, a value that is a non-negative integer causes the Tab Bar to be displayed only if the number of tabs is greater than that integer. The value nil always keeps the Tab Bar hidden; in this case it’s still possible to switch between named window configurations without displaying the Tab Bar by using M-x tab-next, M-x tab-switcher, and other commands that provide completion on tab names. Also it’s possible to create and close tabs without the Tab Bar by using commands M-x tab-new, M-x tab-close, etc.

请注意,数值tab-bar-show可能会导致选项卡栏显示在某些框架上,但不会显示在其他框架上,具体取决于每个框架上创建的选项卡数量。

Note that a numerical value of tab-bar-show can cause the Tab Bar to be displayed on some frames, but not on others, depending on the number of tabs created on each frame.

要仅在选定的框架上切换选项卡栏的使用,请键入 M-x toggle-frame-tab-bar。此命令允许在某些框架上启用选项卡栏的显示,并在其他框架上禁用它,无论tab-bar-mode和的值如何tab-bar-show

To toggle the use of the Tab Bar only on the selected frame, type M-x toggle-frame-tab-bar. This command allows to enable the display of the Tab Bar on some frames and disable it on others, regardless of the values of tab-bar-mode and tab-bar-show.

前缀键C-x t类似于C-x 5。尽管每个C-x 5命令都会在不同的框架中弹出缓冲区(请参阅创建框架),但这些C-x t命令在所选框架中使用具有不同窗口配置的不同选项卡。

The prefix key C-x t is analogous to C-x 5. Whereas each C-x 5 command pops up a buffer in a different frame (see Creating Frames), the C-x t commands use a different tab with a different window configuration in the selected frame.

各种C-x t命令的不同之处在于它们如何查找或创建要选择的缓冲区。以下命令可用于在新选项卡中选择缓冲区:

The various C-x t commands differ in how they find or create the buffer to select. The following commands can be used to select a buffer in a new tab:

C-x t 2
C-x t 2

添加新选项卡 ( tab-new)。您可以通过自定义变量来控制新选项卡中显示的缓冲区的选择 tab-bar-new-tab-choice。您可以通过自定义变量来控制默认为新选项卡指定的名称 tab-bar-tab-name-function

Add a new tab (tab-new). You can control the choice of the buffer displayed in a new tab by customizing the variable tab-bar-new-tab-choice. You can control the names given by default to new tabs by customizing the variable tab-bar-tab-name-function.

C-x t b bufname RET
C-x t b bufname RET

在另一个选项卡中选择缓冲区bufname 。这运行 switch-to-buffer-other-tab.

Select buffer bufname in another tab. This runs switch-to-buffer-other-tab.

C-x t f filename RET
C-x t f filename RET

访问文件filename(请参阅访问文件)并在另一个选项卡中选择其缓冲区。这运行find-file-other-tab.

Visit the file filename (see Visiting Files) and select its buffer in another tab. This runs find-file-other-tab.

C-x t d directory RET
C-x t d directory RET

在另一个选项卡中编辑指定的目录(请参阅Dired,目录编辑器)。这运行dired-other-tab.

Edit the specified directory (see Dired, the Directory Editor) in another tab. This runs dired-other-tab.

C-x t t
C-x t t

这是一个前缀命令 ( other-tab-prefix),它影响紧随该前缀命令之后调用的下一个命令。它请求下一个命令显示的缓冲区显示在另一个选项卡中。

This is a prefix command (other-tab-prefix) that affects the next command invoked immediately after this prefix command. It requests the buffer displayed by the next command to be shown in another tab.

默认情况下,新选项卡从调用添加新选项卡的命令之前的当前缓冲区开始。要使用其他缓冲区启动新选项卡,请自定义变量 tab-bar-new-tab-choice

By default, a new tab starts with the buffer that was current before calling the command that adds a new tab. To start a new tab with other buffers, customize the variable tab-bar-new-tab-choice.

该变量tab-bar-new-tab-to定义放置新选项卡的位置。默认情况下,新选项卡会添加到当前选项卡的右侧。

The variable tab-bar-new-tab-to defines where to place a new tab. By default, a new tab is added on the right side of the current tab.

以下命令可用于删除选项卡:

The following commands can be used to delete tabs:

C-x t 0
C-x t 0

关闭所选选项卡 ( tab-close)。如果只有一个选项卡,这不会产生任何影响,除非该变量tab-bar-close-last-tab-choice 被自定义为非默认值。

Close the selected tab (tab-close). This has no effect if there is only one tab, unless the variable tab-bar-close-last-tab-choice is customized to a non-default value.

C-x t 1
C-x t 1

关闭所选框架上除所选选项卡之外的所有选项卡。

Close all tabs, except the selected tab, on the selected frame.

该变量tab-bar-close-tab-select定义关闭当前选项卡后选择哪个选项卡。默认情况下,它选择最近使用的选项卡。

The variable tab-bar-close-tab-select defines what tab to select after closing the current tab. By default, it selects a recently used tab.

该命令tab-undo恢复上次关闭的选项卡。

The command tab-undo restores the last closed tab.

可以使用以下命令在选项卡之间切换:

The following commands can be used to switch between tabs:

C-x t o
C-x t o
C-TAB
C-TAB

切换到下一个选项卡 ( tab-next)。如果重复此命令,它将循环显示所选帧上的所有选项卡。使用正数值参数n,它会切换到第n个下一个选项卡;使用负参数 - n,它切换回前第n 个选项卡。

Switch to the next tab (tab-next). If you repeat this command, it cycles through all the tabs on the selected frame. With a positive numeric argument n, it switches to the nth next tab; with a negative argument −n, it switches back to the nth previous tab.

S-C-TAB
S-C-TAB

切换到上一个选项卡 ( tab-previous)。使用正数值参数n,它会切换到前n个选项卡;使用负参数 - n,它会切换到 下一个选项卡第n 个

Switch to the previous tab (tab-previous). With a positive numeric argument n, it switches to the nth previous tab; with a negative argument −n, it switches to the nth next tab.

C-x t RET tabname RET
C-x t RET tabname RET

按选项卡名称 ( tab-switch) 切换到选项卡,并完成所有选项卡名称。选项卡名称的默认值和“未来历史记录”按新近度排序,因此您可以使用M-n ( next-history-element) 获取最后访问的选项卡的名称、倒数第二个选项卡的名称,依此类推。

Switch to the tab by its name (tab-switch), with completion on all tab names. The default value and the “future history” of tab names is sorted by recency, so you can use M-n (next-history-element) to get the name of the last visited tab, the second last, and so on.

modifier-tab-number
modifier-tab-number

按选项卡编号切换到选项卡( tab-select)。自定义变量tab-bar-select-tab-modifiers以指定一个或多个修饰键后,您可以使用指定修饰符之一并结合要选择的选项卡编号,按序号选择选项卡。数字 9 可用于选择最后一个选项卡。您可以选择 Emacs 支持的任何修饰符,请参阅修饰键。要在选项卡名称旁边显示选项卡编号,您可以自定义另一个变量tab-bar-tab-hints。这将帮助您决定按哪个数字键来按编号选择选项卡。

Switch to the tab by its number tab-number (tab-select). After customizing the variable tab-bar-select-tab-modifiers to specify one or more modifier keys, you can select a tab by its ordinal number using one of the specified modifiers in combination with the tab number to select. The number 9 can be used to select the last tab. You can select any modifiers supported by Emacs, see Modifier Keys. To display the tab number alongside the tab name, you can customize another variable tab-bar-tab-hints. This will help you decide which numerical key to press to select the tab by its number.

modifier-9
modifier-9

切换到最后一个选项卡 ( tab-last)。组合键是由tab-bar-select-tab-modifiers和 键定义的修饰键9。使用数字参数n,切换到 倒数第n 个选项卡。

Switch to the last tab (tab-last). The key combination is the modifier key defined by tab-bar-select-tab-modifiers and the key 9. With a numeric argument n, switch to the nth last tab.

modifier-0
modifier-0

切换到最近的选项卡 ( tab-recent)。组合键是由tab-bar-select-tab-modifiers和 键定义的修饰键0。使用数字参数n,切换到第 n 个最近的选项卡。

Switch to the recent tab (tab-recent). The key combination is the modifier key defined by tab-bar-select-tab-modifiers and the key 0. With a numeric argument n, switch to the nth recent tab.

可以使用以下命令对选项卡进行操作:

The following commands can be used to operate on tabs:

C-x t r tabname RET
C-x t r tabname RET

将当前选项卡重命名为选项卡名称( tab-rename)。

Rename the current tab to tabname (tab-rename).

C-x t m
C-x t m

将当前选项卡向右移动一位 ( tab-move)。使用正数值参数n,将其向右移动多个位置;如果参数为负 - n,则将其 向左 移动n 个位置。

Move the current tab one position to the right (tab-move). With a positive numeric argument n, move it that many positions to the right; with a negative argument −n, move it n positions to the left.

您可以使用鼠标对选项卡进行操作。单击mouse-2 关闭选项卡。单击mouse-3会弹出上下文菜单,其中包含在单击的选项卡上操作的项目。拖动选项卡 mouse-1会将其移动到选项卡栏上的另一个位置。鼠标滚轮滚动切换到下一个或上一个选项卡。滚动期间按住该SHIFT键可将选项卡向左或向右移动。

You can use the mouse to operate on tabs. Clicking mouse-2 closes the tab. Clicking mouse-3 pops up the context menu with the items that operate on the clicked tab. Dragging the tab with mouse-1 moves it to another position on the tab bar. Mouse wheel scrolling switches to the next or previous tab. Holding down the SHIFT key during scrolling moves the tab to the left or right.

您可以启用tab-bar-history-mode记住每个选项卡中使用的窗口配置,并在以后恢复它们。

You can enable tab-bar-history-mode to remember window configurations used in every tab, and later restore them.

M-x tab-bar-history-back
M-x tab-bar-history-back

恢复当前选项卡中使用的先前窗口配置。这将导航回窗口配置的历史记录。

Restore a previous window configuration used in the current tab. This navigates back in the history of window configurations.

M-x tab-bar-history-forward
M-x tab-bar-history-forward

取消恢复以前的窗口配置。这在窗口配置的历史上向前迈进了一步。

Cancel restoration of the previous window configuration. This moves forward in the history of window configurations.

可以通过用户选项自定义选项卡栏上显示的项目tab-bar-format

It’s possible to customize the items displayed on the tab bar by the user option tab-bar-format.


22.18 使用对话框

22.18 Using Dialog Boxes

对话框是一种特殊的菜单,用于询问是或否问题或其他一些特殊问题。如果您使用鼠标调用引发问题的命令,许多 Emacs 命令都会使用对话框来询问是或否问题。

A dialog box is a special kind of menu for asking you a yes-or-no question or some other special question. Many Emacs commands use a dialog box to ask a yes-or-no question, if you used the mouse to invoke the command that led to the question.

要禁用对话框的使用,请将变量更改 use-dialog-boxnil。在这种情况下,Emacs 始终使用回显区域和键盘输入来执行是或否提示。此变量还控制是否使用文件选择窗口(但并非所有平台都支持这些窗口)。

To disable the use of dialog boxes, change the variable use-dialog-box to nil. In that case, Emacs always performs yes-or-no prompts using the echo area and keyboard input. This variable also controls whether to use file selection windows (but those are not supported on all platforms).

文件选择窗口是一种特殊的对话框,用于询问文件名。您可以自定义变量use-file-dialog 以禁止使用文件选择窗口,即使您仍然需要其他类型的对话框。如果您已使用该变量抑制所有对话框,则该变量无效use-dialog-box

A file selection window is a special kind of dialog box for asking for file names. You can customize the variable use-file-dialog to suppress the use of file selection windows, even if you still want other kinds of dialogs. This variable has no effect if you have suppressed all dialog boxes with the variable use-dialog-box.

当 Emacs 编译为支持 GTK+ 时,它使用 GTK+ 文件选择器对话框。 Emacs 在此对话框中添加了一个附加切换按钮,您可以使用该按钮启用或禁用该对话框中隐藏文件(以点开头的文件)的显示。如果您希望默认激活此切换,请将变量更改 x-gtk-show-hidden-filest。此外,Emacs 在 GTK+ 文件选择器对话框中添加了帮助文本;要禁用此帮助文本,请将变量更改x-gtk-file-dialog-help-textnil

When Emacs is compiled with GTK+ support, it uses the GTK+ file chooser dialog. Emacs adds an additional toggle button to this dialog, which you can use to enable or disable the display of hidden files (files starting with a dot) in that dialog. If you want this toggle to be activated by default, change the variable x-gtk-show-hidden-files to t. In addition, Emacs adds help text to the GTK+ file chooser dialog; to disable this help text, change the variable x-gtk-file-dialog-help-text to nil.


22.19 工具提示

22.19 Tooltips

工具提示是小的特殊框架,显示当前鼠标位置的文本信息。当鼠标在窗口中的某些重要文本、模式行或 Emacs 框架的其他部分(例如工具栏按钮或菜单项)上移动时暂停时,它们会激活。

Tooltips are small special frames that display text information at the current mouse position. They activate when there is a pause in mouse movement over some significant piece of text in a window, or the mode line, or some other part of the Emacs frame such as a tool bar button or menu item.

您可以使用命令切换工具提示的使用M-x tooltip-mode。当工具提示模式被禁用时,帮助文本将显示在回显区域中。要在启动时控制工具提示的使用,请自定义变量tooltip-mode

You can toggle the use of tooltips with the command M-x tooltip-mode. When Tooltip mode is disabled, the help text is displayed in the echo area instead. To control the use of tooltips at startup, customize the variable tooltip-mode.

以下变量提供工具提示显示的自定义选项:

The following variables provide customization options for tooltip display:

tooltip-delay
tooltip-delay

该变量指定 Emacs 在显示第一个工具提示之前应等待的时间。该值以秒为单位。

This variable specifies how long Emacs should wait before displaying the first tooltip. The value is in seconds.

tooltip-short-delay
tooltip-short-delay

该变量指定 Emacs 在显示第一个工具提示后,在不同项目上显示后续工具提示之前应等待多长时间。该值以秒为单位。

This variable specifies how long Emacs should wait before displaying subsequent tooltips on different items, having already displayed the first tooltip. The value is in seconds.

tooltip-hide-delay
tooltip-hide-delay

如果鼠标不移动,从显示工具提示到隐藏它的秒数。

The number of seconds since displaying a tooltip to hide it, if the mouse doesn’t move.

tooltip-x-offset
tooltip-x-offset
tooltip-y-offset
tooltip-y-offset

工具提示左上角距鼠标指针位置的 X 和 Y 偏移量(以像素为单位)。请注意,如果tooltip-frame-parameters自定义为分别包含left和参数,则这些将被忽略 top。应选择偏移值,以便工具提示不会覆盖鼠标指针的热点,否则可能会干扰单击鼠标。

The X and Y offsets, in pixels, of the left top corner of the tooltip from the mouse pointer position. Note that these are ignored if tooltip-frame-parameters was customized to include, respectively, the left and top parameters. The values of the offsets should be chosen so that the tooltip doesn’t cover the mouse pointer’s hot spot, or it might interfere with clicking the mouse.

tooltip-frame-parameters
tooltip-frame-parameters

用于显示工具提示的框架参数。请参阅Emacs Lisp 参考手册中的框架参数,以及 Emacs Lisp 参考手册中的工具提示

The frame parameters used for displaying tooltips. See Frame Parameters in The Emacs Lisp Reference Manual, and also Tooltips in The Emacs Lisp Reference Manual.

有关显示工具提示的其他自定义选项,请使用 . M-x customize-group RET tooltip RET

For additional customization options for displaying tooltips, use M-x customize-group RET tooltip RET.

如果 Emacs 是使用 GTK+ 工具包、Nextstep 窗口或 Haiku 窗口支持构建的,它将通过工具包显示工具提示,并使用工具包工具提示的默认外观。8要禁用此功能,请将变量更改 use-system-tooltipsnil。如果您这样做,或者如果 Emacs 是在没有适当的窗口支持的情况下构建的,则工具提示文本的大多数属性都由面tooltip和 X 资源指定(请参阅X 选项和资源)。

If Emacs is built with the GTK+ toolkit, Nextstep windowing, or Haiku windowing support, it displays tooltips via the toolkit, using the default appearance of the toolkit’s tooltips.8 To disable this, change the variable use-system-tooltips to nil. If you do this, or if Emacs is built without the appropriate windowing support, most attributes of the tooltip text are specified by the tooltip face, and by X resources (see X Options and Resources).

GUD 工具提示是使用 GUD 调试程序时显示变量值的特殊工具提示。请参阅调试器操作

GUD tooltips are special tooltips that show the values of variables when debugging a program with GUD. See Debugger Operation.


22.20 鼠标回避

22.20 Mouse Avoidance

在图形终端上,鼠标指针可能会遮挡 Emacs 框架中的文本。 Emacs 提供了两种方法来避免这个问题。

On graphical terminals, the mouse pointer may obscure the text in the Emacs frame. Emacs provides two methods to avoid this problem.

首先,如果鼠标指针位于 Emacs 框架内,则每次键入自插入字符时,Emacs 都会隐藏鼠标指针;移动鼠标指针使其再次可见。要禁用此功能,请将变量设置make-pointer-invisiblenil。请参阅显示的自定义

Firstly, Emacs hides the mouse pointer each time you type a self-inserting character, if the pointer lies inside an Emacs frame; moving the mouse pointer makes it visible again. To disable this feature, set the variable make-pointer-invisible to nil. See Customization of Display.

其次,您可以使用鼠标回避模式(一种次要模式)来使鼠标指针远离点。要使用鼠标回避模式,请自定义变量mouse-avoidance-mode。您可以将其设置为各种值,以通过多种方式移动鼠标:

Secondly, you can use Mouse Avoidance mode, a minor mode, to keep the mouse pointer away from point. To use Mouse Avoidance mode, customize the variable mouse-avoidance-mode. You can set this to various values to move the mouse in several ways:

banish
banish

在任意按键上将指针移动到框架的一角。您可以自定义该变量mouse-avoidance-banish-position以指定指针被消除时的去向。

Move the pointer to a corner of the frame on any key-press. You can customize the variable mouse-avoidance-banish-position to specify where the pointer goes when it is banished.

exile
exile

仅当光标太靠近时才消除指针,并在光标移开后允许其返回。

Banish the pointer only if the cursor gets too close, and allow it to return once the cursor is out of the way.

jump
jump

如果光标距离指针太近,请将指针移动随机距离和方向。

If the cursor gets too close to the pointer, displace the pointer by a random distance and direction.

animate
animate

作为jump,但显示了运动错觉的沿途步骤。

As jump, but shows steps along the way for illusion of motion.

cat-and-mouse
cat-and-mouse

与 相同animate

The same as animate.

proteus
proteus

与 一样animate,但也会更改鼠标指针的形状。

As animate, but changes the shape of the mouse pointer too.

您还可以使用该命令M-x mouse-avoidance-mode来启用该模式。每当鼠标回避模式移动鼠标时,它也会升高框架。

You can also use the command M-x mouse-avoidance-mode to enable the mode. Whenever Mouse Avoidance mode moves the mouse, it also raises the frame.


22.21 文本终端

22.21 Text Terminals

在文本终端上,Emacs 一次只能显示一个 Emacs 框架。但是,您仍然可以创建多个 Emacs 框架,并在它们之间进行切换。在这些终端上切换框架很像在不同的窗口配置之间切换。

On a text terminal, Emacs can display only one Emacs frame at a time. However, you can still create multiple Emacs frames, and switch between them. Switching frames on these terminals is much like switching between different window configurations.

用于C-x 5 2创建新框架并切换到它;用于C-x 5 o循环浏览现有帧;用于C-x 5 0删除当前帧。

Use C-x 5 2 to create a new frame and switch to it; use C-x 5 o to cycle through the existing frames; use C-x 5 0 to delete the current frame.

每个帧都有一个编号来区分。如果您的终端一次只能显示一帧,则所选帧的编号n 出现在模式行开头附近,格式为 'Fn'。

Each frame has a number to distinguish it. If your terminal can display only one frame at a time, the selected frame’s number n appears near the beginning of the mode line, in the form ‘Fn’.

'Fn' 实际上是框架的初始名称。如果您愿意,您可以为框架指定更有意义的名称,并且可以通过名称选择框架。使用该命令为所选框架指定新名称,然后使用 根据名称选择框架。当选择框架时,您指定的名称将出现在模式行中。 M-x set-frame-name RET name RETM-x select-frame-by-name RET name RET

Fn’ is in fact the frame’s initial name. You can give frames more meaningful names if you wish, and you can select a frame by its name. Use the command M-x set-frame-name RET name RET to specify a new name for the selected frame, and use M-x select-frame-by-name RET name RET to select a frame according to its name. The name you specify appears in the mode line when the frame is selected.


22.22 在文本终端中使用鼠标

22.22 Using a Mouse in Text Terminals

某些文本终端支持在终端窗口中单击鼠标。

Some text terminals support mouse clicks in the terminal window.

在与 兼容的终端仿真器中xterm,您可以使用M-x xterm-mouse-mode来让 Emacs 控制鼠标的简单使用 — 基本上,仅支持未经修改的单击。新版本xterm还支持鼠标跟踪。通过在按下鼠标按钮时按住该键,此类单击的正常xterm鼠标功能仍然可用。 SHIFTXterm 鼠标模式是全局次要模式(请参阅次要模式)。重复该命令会再次关闭该模式。

In a terminal emulator which is compatible with xterm, you can use M-x xterm-mouse-mode to give Emacs control over simple uses of the mouse—basically, only non-modified single clicks are supported. Newer versions of xterm also support mouse-tracking. The normal xterm mouse functionality for such clicks is still available by holding down the SHIFT key when you press the mouse button. Xterm Mouse mode is a global minor mode (see Minor Modes). Repeating the command turns the mode off again.

在 GNU/Linux 的控制台中,您可以使用M-x gpm-mouse-mode来启用鼠标支持。您必须在系统上安装并运行 gpm 服务器才能使其正常工作。请注意,启用此模式后,您无法使用鼠标在 Emacs 和其他使用 GPM 的程序之间传输文本。这是由于 GPM 和 Linux 内核的限制。

In the console on GNU/Linux, you can use M-x gpm-mouse-mode to enable mouse support. You must have the gpm server installed and running on your system in order for this to work. Note that when this mode is enabled, you cannot use the mouse to transfer text between Emacs and other programs which use GPM. This is due to limitations in GPM and the Linux kernel.

有关 MS-DOS 上鼠标支持的信息, 请参阅MS-DOS 上的鼠标使用。

See Mouse Usage on MS-DOS, for information about mouse support on MS-DOS.


23 国际字符集支持

23 International Character Set Support

Emacs 支持多种国际字符集,包括拉丁字母的欧洲和越南语变体,以及阿拉伯文字、婆罗米文字(用于孟加拉语、印地语和泰语等语言)、西里尔文、埃塞俄比亚文、格鲁吉亚文、希腊文、汉文(适用于中文和日语)、Hangul(适用于韩语)、希伯来语和 IPA。 Emacs 还支持其他国际化软件(例如文字处理程序和邮件程序)使用的这些字符的各种编码。

Emacs supports a wide variety of international character sets, including European and Vietnamese variants of the Latin alphabet, as well as Arabic scripts, Brahmic scripts (for languages such as Bengali, Hindi, and Thai), Cyrillic, Ethiopic, Georgian, Greek, Han (for Chinese and Japanese), Hangul (for Korean), Hebrew and IPA. Emacs also supports various encodings of these characters that are used by other internationalized software, such as word processors and mailers.

Emacs 通过支持所有相关活动,允许使用国际字符编辑文本:

Emacs allows editing text with international characters by supporting all the related activities:

  • 您可以访问包含非ASCII字符的文件、保存非ASCII文本以及在 Emacs 和它调用的程序(例如编译器、拼写检查器和邮件程序)之间传递非ASCII文本。设置语言环境(请参阅语言环境)负责为特定语言或文化设置编码系统和其他选项。或者,您可以指定 Emacs 如何对每个命令的文本进行编码或解码;请参阅指定文件文本的编码系统
  • You can visit files with non-ASCII characters, save non-ASCII text, and pass non-ASCII text between Emacs and programs it invokes (such as compilers, spell-checkers, and mailers). Setting your language environment (see Language Environments) takes care of setting up the coding systems and other options for a specific language or culture. Alternatively, you can specify how Emacs should encode or decode text for each command; see Specifying a Coding System for File Text.
  • 您可以显示由各种脚本编码的非ASCII字符。这是通过在图形显示上使用适当的字体(请参阅定义字体集)以及将特殊代码发送到文本显示(请参阅终端 I/O 的编码系统)来实现的。如果某些字符显示不正确,请参阅无法显示的字符,其中描述了可能出现的问题并解释了如何解决这些问题。
  • You can display non-ASCII characters encoded by the various scripts. This works by using appropriate fonts on graphics displays (see Defining Fontsets), and by sending special codes to text displays (see Coding Systems for Terminal I/O). If some characters are displayed incorrectly, refer to Undisplayable Characters, which describes possible problems and explains how to solve them.
  • 文本自然顺序为从右到左的脚本中的字符将重新排序以进行显示(请参阅双向编辑)。这些文字包括阿拉伯语、希伯来语、叙利亚语、塔纳语和其他一些文字。
  • Characters from scripts whose natural ordering of text is from right to left are reordered for display (see Bidirectional Editing). These scripts include Arabic, Hebrew, Syriac, Thaana, and a few others.
  • 您可以插入非ASCII字符或搜索它们。为此,您可以指定适合您的语言的 Emacs 输入法(请参阅选择输入法),或者使用选择语言环境时设置的默认输入法。如果您的键盘可以产生非ASCII字符,您可以选择适当的键盘编码系统(请参阅终端 I/O 的编码系统),Emacs 将接受这些字符。在图形显示上,现代系统通常提供其本机输入方法,也可以使用前缀输入 Latin-1 字符C-x 8,请参阅Unibyte 编辑模式

    对于 X Window 系统,您的区域设置应设置为适当的值,以确保 Emacs 正确解释键盘输入;请参阅 区域设置X 键盘输入的编码系统

  • You can insert non-ASCII characters or search for them. To do that, you can specify an Emacs input method (see Selecting an Input Method) suitable for your language, or use the default input method set up when you choose your language environment. If your keyboard can produce non-ASCII characters, you can select an appropriate keyboard coding system (see Coding Systems for Terminal I/O), and Emacs will accept those characters. On graphical displays, modern systems typically provide their native input methods, and Latin-1 characters can also be input by using the C-x 8 prefix, see Unibyte Editing Mode.

    With the X Window System, your locale should be set to an appropriate value to make sure Emacs interprets keyboard input correctly; see locales, and Coding Systems for X Keyboard Input.

本章的其余部分详细描述了这些问题。

The rest of this chapter describes these issues in detail.


23.1 国际字符集简介

23.1 Introduction to International Character Sets

国际字符集和脚本的用户已经建立了许多或多或少的标准编码系统来存储文件。这些编码系统通常是多字节的,这意味着两个或多个字节的序列用于表示单个非ASCII字符。

The users of international character sets and scripts have established many more-or-less standard coding systems for storing files. These coding systems are typically multibyte, meaning that sequences of two or more bytes are used to represent individual non-ASCII characters.

在内部,Emacs 使用自己的多字节字符编码,它是Unicode标准的超集。这种内部编码允许几乎所有已知脚本中的字符混合在单个缓冲区或字符串中。当读写文件以及与子进程交换数据时,Emacs 在多字节字符编码和各种其他编码系统之间进行转换。

Internally, Emacs uses its own multibyte character encoding, which is a superset of the Unicode standard. This internal encoding allows characters from almost every known script to be intermixed in a single buffer or string. Emacs translates between the multibyte character encoding and various other coding systems when reading and writing files, and when exchanging data with subprocesses.

命令C-h h( view-hello-file) 显示文件 等/你好,它通过展示如何用多种语言说“你好”来说明各种脚本。如果某些字符无法在您的终端上显示,它们将显示为 '' 或空心框(请参阅不可显示的字符)。

The command C-h h (view-hello-file) displays the file etc/HELLO, which illustrates various scripts by showing how to say “hello” in many languages. If some characters can’t be displayed on your terminal, they appear as ‘?’ or as hollow boxes (see Undisplayable Characters).

即使在使用这些字符集的国家/地区,键盘通常也没有适用于其中所有字符的按键。您可以使用( )插入键盘不支持的字符 。请参阅插入文本。一些常用字符有简写;例如,您可以通过键入 来插入左单引号,或者在电子报价模式下,通常只需键入即可。请参阅引号。 Emacs 还支持各种输入法,通常每种脚本或语言都有一种输入法,这使得在脚本中键入字符变得更加容易。请参阅输入法C-x 8 RETinsert-charC-x 8 [`

Keyboards, even in the countries where these character sets are used, generally don’t have keys for all the characters in them. You can insert characters that your keyboard does not support, using C-x 8 RET (insert-char). See Inserting Text. Shorthands are available for some common characters; for example, you can insert a left single quotation mark by typing C-x 8 [, or in Electric Quote mode, usually by simply typing `. See Quotation Marks. Emacs also supports various input methods, typically one for each script or language, which make it easier to type characters in the script. See Input Methods.

前缀键用于与多字节字符、编码系统和输入法有关的命令。 C-x RET

The prefix key C-x RET is used for commands that pertain to multibyte characters, coding systems, and input methods.

命令C-x =( what-cursor-position) 显示有关该点的字符的信息。除了光标位置信息中描述的字符位置之外,此命令还显示字符的编码方式。例如,它在字符 ' 的回显区域中显示以下行C':

The command C-x = (what-cursor-position) shows information about the character at point. In addition to the character position, which was described in Cursor Position Information, this command displays how the character is encoded. For instance, it displays the following line in the echo area for the character ‘c’:

字符:c (99, #o143, #x63) 点 = 36168 (78%) 中的 28062 列 = 53
Char: c (99, #o143, #x63) point=28062 of 36168 (78%) column=53

' 后面的四个值字符:' 描述点后面的字符,首先显示它,然后给出其十进制、八进制和十六进制的字符代码。对于非ASCII多字节字符,这些字符后跟 '文件' 以及缓冲区编码系统中字符的十六进制表示,前提是该编码系统使用单个字节安全地对字符进行编码(请参阅编码系统)。如果字符的编码长度超过 1 个字节,Emacs 将显示 '文件 ...'。

The four values after ‘Char:’ describe the character that follows point, first by showing it and then by giving its character code in decimal, octal and hex. For a non-ASCII multibyte character, these are followed by ‘file’ and the character’s representation, in hex, in the buffer’s coding system, if that coding system encodes the character safely and with a single byte (see Coding Systems). If the character’s encoding is longer than one byte, Emacs shows ‘file ...’.

在极少数情况下,Emacs 会遇到原始字节:值在 128(八进制 0200)到 255(八进制 0377)范围内的单个字节,Emacs 无法将其解释为某些非 ASCII 字符的已知编码的一部分。这些原始字节被视为属于特殊字符集eight-bit; Emacs 将它们显示为转义八进制代码(这可以自定义;请参阅显示的自定义)。在这种情况下,C-x =显示 '原始字节' 代替 '文件'。此外,C-x =显示原始字节的字符代码,就好像它们在范围内一样#x3FFF80..#x3FFFFF,这是 Emacs 映射它们以将它们与范围内的 Unicode 字符区分开来的地方#x0080..#x00FF

On rare occasions, Emacs encounters raw bytes: single bytes whose values are in the range 128 (0200 octal) through 255 (0377 octal), which Emacs cannot interpret as part of a known encoding of some non-ASCII character. Such raw bytes are treated as if they belonged to a special character set eight-bit; Emacs displays them as escaped octal codes (this can be customized; see Customization of Display). In this case, C-x = shows ‘raw-byte’ instead of ‘file’. In addition, C-x = shows the character codes of raw bytes as if they were in the range #x3FFF80..#x3FFFFF, which is where Emacs maps them to distinguish them from Unicode characters in the range #x0080..#x00FF.

通过前缀参数 ( C-u C-x =),此命令另外调用命令describe-char,该命令显示字符的详细描述:

With a prefix argument (C-u C-x =), this command additionally calls the command describe-char, which displays a detailed description of the character:

  • 字符集名称以及标识该字符集中字符的代码;ASCII字符被标识为属于ascii字符集。
  • The character set name, and the codes that identify the character within that character set; ASCII characters are identified as belonging to the ascii character set.
  • 角色的脚本、语法和类别。
  • The character’s script, syntax and categories.
  • 在当前输入法(如果支持该字符)下按什么键输入该字符。
  • What keys to type to input the character in the current input method (if it supports the character).
  • 字符的编码,既在缓冲区内部,又在外部(如果要将缓冲区保存到文件中)。
  • The character’s encodings, both internally in the buffer, and externally if you were to save the buffer to a file.
  • 如果您在图形显示器上运行 Emacs,则该字符的字体名称和字形代码。如果您在文本终端上运行 Emacs,则代码会发送到终端。
  • If you are running Emacs on a graphical display, the font name and glyph code for the character. If you are running Emacs on a text terminal, the code(s) sent to the terminal.
  • 如果该字符在显示器上与任何后续字符组合以形成一个或多个字素簇,则组合信息:如果该帧在图形显示器上则字体字形,以及所组合的字符。
  • If the character was composed on display with any following characters to form one or more grapheme clusters, the composition information: the font glyphs if the frame is on a graphical display, and the characters that were composed.
  • 字符的文本属性(请参阅Emacs Lisp 参考手册中的文本属性),包括用于显示字符的任何非默认面以及包含该字符的任何覆盖层(请参阅同一手册中的覆盖层)。
  • The character’s text properties (see Text Properties in the Emacs Lisp Reference Manual), including any non-default faces used to display the character, and any overlays containing it (see Overlays in the same manual).

这是一个示例,其中一些行被折叠以适合本手册:

Here’s an example, with some lines folded to fit into this manual:

             位置:1 of 1 (0%),列:0
            字符:ê(显示为 ê)(代码点 234、#o352、#xea)
    首选字符集:unicode (Unicode (ISO10646))
字符集中的代码点:0xEA
               脚本: 拉丁语
               语法:w 表示:单词
             类别:.:基础,L:从左到右(强),c:中文,
                       j:日语,l:拉丁语,v:越南语
             输入:输入“Cx 8 RET ea”或
                       “Cx 8 RET 带抑扬音的拉丁文小写字母 E”
          缓冲代码:#xC3 #xAA
            文件代码:#xC3 #xAA(编码系统utf-8-unix编码)
              显示:按此字体(字形代码)
    xft:-PfEd-DejaVu Sans Mono-正常-正常-
        正常-*-15-*-*-*-m-0-iso10646-1 (#xAC)

字符代码属性:自定义显示内容
  名称:带抑扬音的拉丁文小写字母 E
  旧名称:拉丁文小写字母 E CircumFLEX
  一般类别:Ll(字母,小写)
  分解:(101 770) ('e' '^')
             position: 1 of 1 (0%), column: 0
            character: ê (displayed as ê) (codepoint 234, #o352, #xea)
    preferred charset: unicode (Unicode (ISO10646))
code point in charset: 0xEA
               script: latin
               syntax: w        which means: word
             category: .:Base, L:Left-to-right (strong), c:Chinese,
                       j:Japanese, l:Latin, v:Viet
             to input: type "C-x 8 RET ea" or
                       "C-x 8 RET LATIN SMALL LETTER E WITH CIRCUMFLEX"
          buffer code: #xC3 #xAA
            file code: #xC3 #xAA (encoded by coding system utf-8-unix)
              display: by this font (glyph code)
    xft:-PfEd-DejaVu Sans Mono-normal-normal-
        normal-*-15-*-*-*-m-0-iso10646-1 (#xAC)

Character code properties: customize what to show
  name: LATIN SMALL LETTER E WITH CIRCUMFLEX
  old-name: LATIN SMALL LETTER E CIRCUMFLEX
  general-category: Ll (Letter, Lowercase)
  decomposition: (101 770) ('e' '^')

23.2 语​​言环境

23.2 Language Environments

只要启用多字节字符,Emacs 缓冲区就支持所有支持的字符集;无需选择特定语言即可显示其字符。但是,选择语言环境以设置各种默认值非常重要。粗略地说,语言环境代表的是首选脚本的选择,而不是语言的选择。

All supported character sets are supported in Emacs buffers whenever multibyte characters are enabled; there is no need to select a particular language in order to display its characters. However, it is important to select a language environment in order to set various defaults. Roughly speaking, the language environment represents a choice of preferred script rather than a choice of language.

语言环境控制在阅读文本时识别哪些编码系统(请参阅识别编码系统)。这适用于文件、传入邮件以及您在 Emacs 中读入的任何其他文本。它还可以指定创建文件时要使用的默认编码系统。每种语言环境还指定一种默认输入法。

The language environment controls which coding systems to recognize when reading text (see Recognizing Coding Systems). This applies to files, incoming mail, and any other text you read into Emacs. It may also specify the default coding system to use when you create a file. Each language environment also specifies a default input method.

要选择语言环境,请自定义 current-language-environment或使用命令M-x set-language-environment。使用此命令时,哪个缓冲区是当前缓冲区都没有区别,因为其效果全局适用于 Emacs 会话。请参阅该变量language-info-alist以获取支持的语言环境列表,并使用命令 ( ) 了解有关语言环境lang-env的更多信息。支持的语言环境包括: C-h L lang-env RETdescribe-language-environment

To select a language environment, customize current-language-environment or use the command M-x set-language-environment. It makes no difference which buffer is current when you use this command, because the effects apply globally to the Emacs session. See the variable language-info-alist for the list of supported language environments, and use the command C-h L lang-env RET (describe-language-environment) for more information about the language environment lang-env. Supported language environments include:

ASCII、阿拉伯语、 白俄罗斯语、孟加拉语、 巴西葡萄牙语、保加利亚语、 缅甸、占族、 中文-BIG5、中文-CNS、中文-EUC-TW、中文-GB、中文-GB18030、中文-GBK、 克罗地亚语、西里尔字母-ALT、西里尔字母-ISO、西里尔字母-KOI8、 捷克语、梵文、 荷兰语、英语、 世界语、埃塞俄比亚语、 法语、格鲁吉亚语、 德语、希腊语、古吉拉特语、 希伯来语、国际音标、 意大利语, 日语、卡纳达语、 高棉语、韩语、老挝语、 拉丁语 1、拉丁语 2、拉丁语 3、拉丁语 4、拉丁语 5、拉丁语 6、拉丁语 7、拉丁语 8、拉丁语 9、 拉脱维亚语、立陶宛语、 马拉雅拉姆语、奥里亚语、 波斯语、波兰语、 旁遮普语、罗马尼亚语、 俄语、僧伽罗语、 斯洛伐克语、斯洛文尼亚语、西班牙语、 瑞典语、TaiViet、 塔吉克语、泰米尔语、 泰卢固语、泰语、 藏语、土耳其语、 UTF-8、乌克兰语、 越南语、威尔士语、 和Windows-1255。

ASCII, Arabic, Belarusian, Bengali, Brazilian Portuguese, Bulgarian, Burmese, Cham, Chinese-BIG5, Chinese-CNS, Chinese-EUC-TW, Chinese-GB, Chinese-GB18030, Chinese-GBK, Croatian, Cyrillic-ALT, Cyrillic-ISO, Cyrillic-KOI8, Czech, Devanagari, Dutch, English, Esperanto, Ethiopic, French, Georgian, German, Greek, Gujarati, Hebrew, IPA, Italian, Japanese, Kannada, Khmer, Korean, Lao, Latin-1, Latin-2, Latin-3, Latin-4, Latin-5, Latin-6, Latin-7, Latin-8, Latin-9, Latvian, Lithuanian, Malayalam, Oriya, Persian, Polish, Punjabi, Romanian, Russian, Sinhala, Slovak, Slovenian, Spanish, Swedish, TaiViet, Tajik, Tamil, Telugu, Thai, Tibetan, Turkish, UTF-8, Ukrainian, Vietnamese, Welsh, and Windows-1255.

要在图形显示器上显示您的语言环境使用的脚本,您需要有合适的字体。有关设置字体的更多详细信息, 请参阅字体集。

To display the script(s) used by your language environment on a graphical display, you need to have suitable fonts. See Fontsets, for more details about setting up your fonts.

某些操作系统允许您通过设置区域设置环境变量LC_ALLLC_CTYPE或 来指定正在使用的字符集区域设置LANG。 (如果设置了多个这些,则第一个非空指定用于此目的的区域设置。)在启动期间,Emacs 在系统区域设置别名表中查找字符集区域设置的名称,将其规范名称与中的条目进行匹配。变量locale-charset-language-names和的值 locale-language-names (前者覆盖后者),如果找到匹配则选择相应的语言环境。它还会调整显示表和终端编码系统、区域设置编码系统、区域设置所需的首选编码系统,以及最后但并非最不重要的 Emacs 解码键盘发送的 非ASCII字符的方式。

Some operating systems let you specify the character-set locale you are using by setting the locale environment variables LC_ALL, LC_CTYPE, or LANG. (If more than one of these is set, the first one that is nonempty specifies your locale for this purpose.) During startup, Emacs looks up your character-set locale’s name in the system locale alias table, matches its canonical name against entries in the value of the variables locale-charset-language-names and locale-language-names (the former overrides the latter), and selects the corresponding language environment if a match is found. It also adjusts the display table and terminal coding system, the locale coding system, the preferred coding system as needed for the locale, and—last but not least—the way Emacs decodes non-ASCII characters sent by your keyboard.

如果您在运行 Emacs 时修改LC_ALLLC_CTYPELANG 环境变量(通过使用M-x setenv),您可能需要set-locale-environment 随后调用该命令以从新的语言环境重新调整语言环境。

If you modify the LC_ALL, LC_CTYPE, or LANG environment variables while running Emacs (by using M-x setenv), you may want to invoke the set-locale-environment command afterwards to readjust the language environment from the new locale.

set-locale-environment函数通常使用语言环境建立的首选编码系统来解码系统消息。但是如果您的语言环境与变量中的条目匹配 locale-preferred-coding-systems,Emacs 就会使用相应的编码系统。例如,如果区域设置 'ja_JP.PCK' 匹配japanese-shift-jislocale-preferred-coding-systemsEmacs 使用该编码,即使它通常可能使用utf-8.

The set-locale-environment function normally uses the preferred coding system established by the language environment to decode system messages. But if your locale matches an entry in the variable locale-preferred-coding-systems, Emacs uses the corresponding coding system instead. For example, if the locale ‘ja_JP.PCK’ matches japanese-shift-jis in locale-preferred-coding-systems, Emacs uses that encoding even though it might normally use utf-8.

您可以通过显式使用命令set-language-environmentcurrent-language-environment在初始化文件中自定义来覆盖启动时选择的语言环境。

You can override the language environment chosen at startup with explicit use of the command set-language-environment, or with customization of current-language-environment in your init file.

要显示有关特定语言环境lang-env的效果的信息,请使用命令( )。这会告诉您该语言环境适用于哪些语言,并列出了与其配套的字符集、编码系统和输入法。它还显示了一些示例文本来说明此语言环境中使用的脚本。如果您为lang-env提供空输入,则此命令描述所选的语言环境。 C-h L lang-env RETdescribe-language-environment

To display information about the effects of a certain language environment lang-env, use the command C-h L lang-env RET (describe-language-environment). This tells you which languages this language environment is useful for, and lists the character sets, coding systems, and input methods that go with it. It also shows some sample text to illustrate scripts used in this language environment. If you give an empty input for lang-env, this command describes the chosen language environment.

您可以使用普通的 hook 自定义任何语言环境 set-language-environment-hook。该命令 set-language-environment在设置新语言环境后运行该挂钩。钩子函数可以通过检查变量来测试特定的语言环境 current-language-environment。您应该在该钩子中放置特定语言环境的非默认设置,例如键盘输入和终端输出的编码系统、默认输入法等。

You can customize any language environment with the normal hook set-language-environment-hook. The command set-language-environment runs that hook after setting up the new language environment. The hook functions can test for a specific language environment by checking the variable current-language-environment. This hook is where you should put non-default settings for specific language environments, such as coding systems for keyboard input and terminal output, the default input method, etc.

在开始设置新的语言环境之前, set-language-environment首先运行 hook exit-language-environment-hook。此挂钩对于撤消使用set-language-environment-hook.例如,如果您使用 在特定语言环境中设置特殊键绑定set-language-environment-hook,则应设置exit-language-environment-hook恢复该键的正常绑定。

Before it starts to set up the new language environment, set-language-environment first runs the hook exit-language-environment-hook. This hook is useful for undoing customizations that were made with set-language-environment-hook. For instance, if you set up a special key binding in a specific language environment using set-language-environment-hook, you should set up exit-language-environment-hook to restore the normal binding for that key.


23.3 输入法

23.3 Input Methods

输入是一种专门为交互输入而设计的字符转换。本节介绍 Emacs 自带的输入法;对于底层操作系统提供的本机输入法,请参阅Unibyte 编辑模式

An input method is a kind of character conversion designed specifically for interactive input. This section describes input methods that come with Emacs; for native input methods provided by the underlying OS, see Unibyte Editing Mode.

在 Emacs 中,通常每种语言都有自己的输入法;有时,使用相同字符的多种语言可以共享一种输入法。一些语言支持多种输入法。

In Emacs, typically each language has its own input method; sometimes several languages that use the same characters can share one input method. A few languages support several input methods.

最简单的输入法是将ASCII字母映射到另一个字母表中。这允许您使用另一种字母表而不是ASCII。希腊语和俄语输入法就是这样工作的。

The simplest kind of input method works by mapping ASCII letters into another alphabet; this allows you to use one other alphabet instead of ASCII. The Greek and Russian input methods work this way.

一种更强大的技术是组合:将字符序列转换为一个字母。许多欧洲输入法使用组合从由字母后跟重音字符组成的序列中生成单个非ASCII字母(反之亦然)。例如,某些方法将序列转换o ^为单个重音字母。这些输入法没有自己的特殊命令;他们所做的只是组成打印字符序列。

A more powerful technique is composition: converting sequences of characters into one letter. Many European input methods use composition to produce a single non-ASCII letter from a sequence that consists of a letter followed by accent characters (or vice versa). For example, some methods convert the sequence o ^ into a single accented letter. These input methods have no special commands of their own; all they do is compose sequences of printing characters.

音节文字的输入方法通常使用先映射后组合的方式。泰语和韩语的输入法就是这样工作的。首先,字母被映射成特定声音或音调标记的符号;然后,构成一个完整音节的这些序列被映射为一个音节符号。

The input methods for syllabic scripts typically use mapping followed by composition. The input methods for Thai and Korean work this way. First, letters are mapped into symbols for particular sounds or tone marks; then, sequences of these that make up a whole syllable are mapped into one syllable sign.

中文和日文需要更复杂的方法。在中文输入法中,首先输入中文单词的拼音(在输入法chinese-py等中),或字符的一系列部分(在输入法chinese-4cornerchinese-sw等中)。一个输入序列通常对应于许多可能的汉字。您可以使用C-fC-bC-nC-p(或箭头键)和数字 等键和数字来选择您想要的选项,这些键在这种情况下具有特殊含义。

Chinese and Japanese require more complex methods. In Chinese input methods, first you enter the phonetic spelling of a Chinese word (in input method chinese-py, among others), or a sequence of portions of the character (input methods chinese-4corner and chinese-sw, and others). One input sequence typically corresponds to many possible Chinese characters. You select the one you mean using keys such as C-f, C-b, C-n, C-p (or the arrow keys), and digits, which have special meanings in this situation.

可能的字符在概念上排列成几行,每行最多可容纳 10 个选项。通常,Emacs 在回显区域一次只显示一行; 出现在开头,表示这是总共j行中的第i行。键入或以显示下一行或上一行。 (i/j)C-nC-p

The possible characters are conceptually arranged in several rows, with each row holding up to 10 alternatives. Normally, Emacs displays just one row at a time, in the echo area; (i/j) appears at the beginning, to indicate that this is the ith row out of a total of j rows. Type C-n or C-p to display the next row or the previous row.

键入C-fC-b可在当前行的选项中向前和向后移动。当您执行此操作时,Emacs 使用特殊颜色突出显示当前的替代方案;键入 以选择当前替代项并将其用作输入。该行中的备选方案也已编号;该数字出现在替代项之前。键入数字会选择当前行的关联替代项并将其用作输入。 C-SPC

Type C-f and C-b to move forward and backward among the alternatives in the current row. As you do this, Emacs highlights the current alternative with a special color; type C-SPC to select the current alternative and use it as input. The alternatives in the row are also numbered; the number appears before the alternative. Typing a number selects the associated alternative of the current row and uses it as input.

TAB在这些中文输入法中,会显示一个缓冲区,同时显示所有可能的字符;然后单击mouse-2其中一个即可选择该替代方案。键C-fC-bC-nC-p和数字继续照常工作,但它们在缓冲区中突出显示可能的字符,而不是在回显区域中。

TAB in these Chinese input methods displays a buffer showing all the possible characters at once; then clicking mouse-2 on one of them selects that alternative. The keys C-f, C-b, C-n, C-p, and digits continue to work as usual, but they do the highlighting in the buffer showing the possible characters, rather than in the echo area.

要改为根据pīnyīn音译方法输入字符,请使用chinese-sisheng输入法。这是一种基于组合的方法,其中例如pi1导致''。

To enter characters according to the pīnyīn transliteration method instead, use the chinese-sisheng input method. This is a composition based method, where e.g. pi1 results in ‘’.

在日语输入法中,首先使用拼音输入整个单词;然后,当该单词进入缓冲区后,Emacs 使用一个大字典将其转换为一个或多个字符。一种拼音对应于许多不同的日语单词;选择其中之一,使用C-nC-p循环选择选项。

In Japanese input methods, first you input a whole word using phonetic spelling; then, after the word is in the buffer, Emacs converts it into one or more characters using a large dictionary. One phonetic spelling corresponds to a number of different Japanese words; to select one of them, use C-n and C-p to cycle through the alternatives.

有时,切断输入法处理很有用,这样您刚刚输入的字符就不会与后续字符组合。例如,在输入法中latin-1-postfix,序列o ^组合起来形成 '' 带口音。如果您想将它们作为单独的字符输入怎么办?

Sometimes it is useful to cut off input method processing so that the characters you have just entered will not combine with subsequent characters. For example, in input method latin-1-postfix, the sequence o ^ combines to form an ‘o’ with an accent. What if you want to enter them as separate characters?

一种方法是输入重音符号两次;这是输入单独字母和重音符号的特殊功能。例如,o ^ ^给您两个字符 '哦^'。另一种方法是在后面键入另一个字母o(不会与该字母组合的内容),然后立即将其删除。例如,您可以输入单独的 'o o DEL ^' 和 '^'。另一种更通用但不太容易键入的方法是C-\ C-\在两个字符之间使用以阻止它们组合。这是命令 C-\( toggle-input-method) 使用了两次。请参阅选择输入法

One way is to type the accent twice; this is a special feature for entering the separate letter and accent. For example, o ^ ^ gives you the two characters ‘o^’. Another way is to type another letter after the o—something that won’t combine with that—and immediately delete it. For example, you could type o o DEL ^ to get separate ‘o’ and ‘^’. Another method, more general but not quite as easy to type, is to use C-\ C-\ between two characters to stop them from combining. This is the command C-\ (toggle-input-method) used twice. See Selecting an Input Method.

C-\ C-\在增量搜索中特别有用,因为它不再等待更多字符组合,而是开始搜索您已经输入的内容。

C-\ C-\ is especially useful inside an incremental search, because it stops waiting for more characters to combine, and starts searching for what you have already entered.

要了解如何使用当前输入法输入点后的字符,请键入C-u C-x =。请参阅光标位置信息

To find out how to input the character after point using the current input method, type C-u C-x =. See Cursor Position Information.

变量input-method-highlight-flaginput-method-verbose-flag控制输入法如何解释正在发生的事情。如果input-method-highlight-flag为非nil,则部分序列在缓冲区中突出显示(对于大多数输入法 - 有些禁用此功能)。如果 input-method-verbose-flag是非- nil,则接下来可能要键入的字符列表将显示在回显区域中(但当您位于迷你缓冲区中时不会显示)。

The variables input-method-highlight-flag and input-method-verbose-flag control how input methods explain what is happening. If input-method-highlight-flag is non-nil, the partial sequence is highlighted in the buffer (for most input methods—some disable this feature). If input-method-verbose-flag is non-nil, the list of possible characters to type next is displayed in the echo area (but not when you are in the minibuffer).

您可以通过在添加到挂钩变量的函数中进行更改来修改输入法的工作方式quail-activate-hook。请参阅钩子。例如,您可以通过quail-translation-keymap使用函数返回的键映射中定义键绑定来重新定义输入法的某些键define-key。请参阅在初始化文件中重新绑定键

You can modify how an input method works by making your changes in a function that you add to the hook variable quail-activate-hook. See Hooks. For example, you can redefine some of the input method’s keys by defining key bindings in the keymap returned by the function quail-translation-keymap, using define-key. See Rebinding Keys in Your Init File.

当缓冲区中的文本由于某种原因为只读时,输入法将被禁止。因此,即使输入法处于活动状态, 单字符键绑定也可以在使缓冲区文本或其部分只读的模式下工作,例如 read-only-mode和。image-mode

Input methods are inhibited when the text in the buffer is read-only for some reason. This is so single-character key bindings work in modes that make buffer text or parts of it read-only, such as read-only-mode and image-mode, even when an input method is active.

键入不在键盘上的字符的另一种方法是使用( ) 根据其 Unicode 名称或代码点插入单个字符;请参阅插入文本C-x 8 RETinsert-char

Another facility for typing characters not on your keyboard is by using C-x 8 RET (insert-char) to insert a single character based on its Unicode name or code-point; see Inserting Text.

有用于插入表情符号的专门命令,这些命令可以在C-x 8 e键盘映射上找到。 C-x 8 e e ( emoji-insert) 将让您浏览不同的表情符号类别,然后选择一个。 C-x 8 e l( emoji-list) 会弹出一个新的缓冲区并列出所有 Emoji;单击(或使用 RET)表情符号字符会将其插入当前缓冲区中。最后,C-x 8 e s( emoji-search) 将允许您根据名称搜索表情符号。

There are specialized commands for inserting Emoji, and these can be found on the C-x 8 e keymap. C-x 8 e e (emoji-insert) will let you navigate through different Emoji categories and then choose one. C-x 8 e l (emoji-list) will pop up a new buffer and list all the Emoji; clicking (or using RET) on an emoji character will insert it in the current buffer. Finally, C-x 8 e s (emoji-search) will allow you to search for Emoji based on their names.

describe-char显示有关点下的字符/字形的大量信息(包括表情符号)。有时获得名称的快速描述很有用,您可以使用 C-x 8 e d( emoji-describe) 命令来执行此操作。它的主要目的是帮助区分不同的表情符号变体(它们看起来非常相似),但它也会告诉您非表情符号字符的名称。

describe-char displays a lot of information about the character/glyphs under point (including emojis). It’s sometimes useful to get a quick description of the name, and you can use the C-x 8 e d (emoji-describe) command to do that. It’s meant primarily to help distinguish between different Emoji variants (which can look very similar), but it will also tell you the names of non-Emoji characters.


23.4 选择输入法

23.4 Selecting an Input Method

C-\
C-\

启用或禁用所选输入法 ( toggle-input-method)。

Enable or disable use of the selected input method (toggle-input-method).

C-x RET C-\ method RET
C-x RET C-\ method RET

为当前缓冲区选择新的输入法 ( set-input-method)。

Select a new input method for the current buffer (set-input-method).

C-x \ method RET
C-x \ method RET

暂时启用所选瞬态输入方式;插入单个字符( )后,它将自动禁用activate-transient-input-method

Temporarily enable the selected transient input method ; it will be automatically disabled after inserting a single character (activate-transient-input-method).

C-h I method RET
C-h I method RET
C-h C-\ method RET
C-h C-\ method RET

描述输入法方法describe-input-method)。默认情况下,它描述当前的输入法(如果有)。此说明应为您提供如何使用任何特定输入法的完整详细信息。

Describe the input method method (describe-input-method). By default, it describes the current input method (if any). This description should give you the full details of how to use any particular input method.

M-x list-input-methods
M-x list-input-methods

显示所有支持的输入法的列表。

Display a list of all the supported input methods.

要为当前缓冲区选择输入方法,请使用( )。该命令从minibuffer中读取输入法名称;该名称通常以其要使用的语言环境开头。该变量 记录选择了哪种输入法。 C-x RET C-\set-input-methodcurrent-input-method

To choose an input method for the current buffer, use C-x RET C-\ (set-input-method). This command reads the input method name from the minibuffer; the name normally starts with the language environment that it is meant to be used with. The variable current-input-method records which input method is selected.

输入方法使用各种ASCII字符序列来代表非ASCII字符。有时暂时关闭输入法很有用。为此,请键入C-\ ( toggle-input-method)。要重新启用输入法,请 C-\再次键入。

Input methods use various sequences of ASCII characters to stand for non-ASCII characters. Sometimes it is useful to turn off the input method temporarily. To do this, type C-\ (toggle-input-method). To reenable the input method, type C-\ again.

如果您在键入C-\时尚未选择输入法,则会提示您指定一种输入法。这与使用指定输入法 具有相同的效果 。C-x RET C-\

If you type C-\ and you have not yet selected an input method, it prompts you to specify one. This has the same effect as using C-x RET C-\ to specify an input method.

当使用数字参数调用时(如 中所示)C-u C-\toggle-input-method始终提示您输入输入法,并建议将最近选择的输入法作为默认值。

When invoked with a numeric argument, as in C-u C-\, toggle-input-method always prompts you for an input method, suggesting the most recently selected one as the default.

选择语言环境指定在各种缓冲区中使用的默认输入方法。当您有默认输入法时,可以通过键入 在当前缓冲区中选择它C-\。该变量 default-input-method指定默认输入法(nil表示没有)。

Selecting a language environment specifies a default input method for use in various buffers. When you have a default input method, you can select it in the current buffer by typing C-\. The variable default-input-method specifies the default input method (nil means there is none).

在某些支持多种不同输入法的语言环境中,您可能希望使用与 所选择的默认输入法不同的输入法set-language-environment。如果您愿意,您可以指示 Emacs 为特定语言环境选择不同的默认输入法 set-language-environment-hook(请参阅set-language-environment-hook)。例如:

In some language environments, which support several different input methods, you might want to use an input method different from the default chosen by set-language-environment. You can instruct Emacs to select a different default input method for a certain language environment, if you wish, by using set-language-environment-hook (see set-language-environment-hook). For example:

(defun my-chinese-setup ()
  “设置我的私人中文环境。”
  (if (等于当前语言环境“Chinese-GB”)
      (setq 默认输入法“chinese-tonepy”)))
(add-hook 'set-language-environment-hook 'my-chinese-setup)
(defun my-chinese-setup ()
  "Set up my private Chinese environment."
  (if (equal current-language-environment "Chinese-GB")
      (setq default-input-method "chinese-tonepy")))
(add-hook 'set-language-environment-hook 'my-chinese-setup)

这会将默认输入法设置为chinese-tonepy 每当您选择 Chinese-GB 语言环境时。

This sets the default input method to be chinese-tonepy whenever you choose a Chinese-GB language environment.

您可以指示 Emacs 自动激活某种输入法。例如:

You can instruct Emacs to activate a certain input method automatically. For example:

(添加钩子'文本模式钩子
  (lambda () (设置输入方法“德语前缀”)))
(add-hook 'text-mode-hook
  (lambda () (set-input-method "german-prefix")))

german-prefix这会自动在文本模式下 激活输入法。

This automatically activates the input method german-prefix in Text mode.

字母脚本的某些输入方法通过(实际上)重新映射键盘来模拟这些脚本常用的各种键盘布局。如何正确执行此重新映射取决于您的实际键盘布局。要指定键盘的布局,请使用命令M-x quail-set-keyboard-layout

Some input methods for alphabetic scripts work by (in effect) remapping the keyboard to emulate various keyboard layouts commonly used for those scripts. How to do this remapping properly depends on your actual keyboard layout. To specify which layout your keyboard has, use the command M-x quail-set-keyboard-layout.

您可以使用该命令M-x quail-show-key显示要键入哪个键(或键序列),以便使用选定的键盘布局输入点后面的字符。C-u C-x =除了有关角色的其他信息之外, 该命令还显示该信息。

You can use the command M-x quail-show-key to show what key (or key sequence) to type in order to input the character following point, using the selected keyboard layout. The command C-u C-x = also shows that information, in addition to other information about the character.

M-x list-input-methods显示所有支持的输入法的列表。该列表提供了有关每种输入法的信息,包括模式行中代表该输入法的字符串。

M-x list-input-methods displays a list of all the supported input methods. The list gives information about each input method, including the string that stands for it in the mode line.

有时,暂时启用输入法 以便仅插入单个字符会很方便。键入 C-x \( activate-transient-input-method) 将暂时启用输入法,让您使用输入法规则插入单个字符,然后自动禁用输入法。如果尚未选择瞬态输入法,C-x \将提示您选择输入法;后续调用此命令将启用所选的瞬态输入法。要选择不同的瞬态输入方法,请键入C-u C-x \。您可以选择与使用 选择的输入法不同的瞬态方法C-u C-\

Sometimes it can be convenient to enable an input method transiently, for inserting only a single character. Typing C-x \ (activate-transient-input-method) will temporarily enable an input method, let you insert a single character using the input method rules, and then automatically disable the input method. If no transient input method was selected yet, C-x \ will prompt you for an input method; subsequent invocations of this command will enable the selected transient input method. To select a different transient input method, type C-u C-x \. You can select a transient method that is different from the input method which you selected using C-u C-\.


23.5 编码系统

23.5 Coding Systems

各种语言的用户已经建立了许多或多或少的标准编码系统来表示它们。 Emacs 内部不使用这些编码系统;相反,它在读取数据时从各种编码系统转换为自己的编码系统,在写入数据时将内部编码系统转换为其他编码系统。可以在读取或写入文件、从终端发送或接收文件以及与子进程交换数据时进行转换。

Users of various languages have established many more-or-less standard coding systems for representing them. Emacs does not use these coding systems internally; instead, it converts from various coding systems to its own system when reading data, and converts the internal coding system to other coding systems when writing data. Conversion is possible in reading or writing files, in sending or receiving from the terminal, and in exchanging data with subprocesses.

Emacs 为每个编码系统分配一个名称。大多数编码系统用于一种语言,编码系统的名称以语言名称开头。有些编码系统可用于多种语言;他们的名字通常以 ' 开头'。还有一些特殊的编码系统,例如no-conversionraw-text、 和emacs-internal

Emacs assigns a name to each coding system. Most coding systems are used for one language, and the name of the coding system starts with the language name. Some coding systems are used for several languages; their names usually start with ‘iso’. There are also special coding systems, such as no-conversion, raw-text, and emacs-internal.

一类特殊的编码系统,统称为 代码页,旨在支持 MS-Windows 和 MS-DOS 软件编码的文本。这些编码系统的名称为 ,其中nnnn是代码页的 3 或 4 位数字。您可以像任何其他编码系统一样使用这些编码;例如,要访问以代码页 850 编码的文件,请键入 . cpnnnnC-x RET c cp850 RET C-x C-f filename RET

A special class of coding systems, collectively known as codepages, is designed to support text encoded by MS-Windows and MS-DOS software. The names of these coding systems are cpnnnn, where nnnn is a 3- or 4-digit number of the codepage. You can use these encodings just like any other coding system; for example, to visit a file encoded in codepage 850, type C-x RET c cp850 RET C-x C-f filename RET.

除了转换非ASCII 字符的各种表示形式之外,编码系统还可以执行行尾转换。 Emacs 处理如何在文件中分隔行的三种不同约定:换行符 (Unix)、回车符后换行符 (DOS) 以及仅回车符 (Mac)。

In addition to converting various representations of non-ASCII characters, a coding system can perform end-of-line conversion. Emacs handles three different conventions for how to separate lines in a file: newline (Unix), carriage return followed by linefeed (DOS), and just carriage return (Mac).

C-h C coding RET
C-h C coding RET

描述编码系统编码describe-coding-system)。

Describe coding system coding (describe-coding-system).

C-h C RET
C-h C RET

描述当前使用的编码系统(describe-coding-system)。

Describe the coding systems currently in use (describe-coding-system).

M-x list-coding-systems
M-x list-coding-systems

显示所有支持的编码系统的列表。

Display a list of all the supported coding systems.

命令C-h C( describe-coding-system) 显示有关特定编码系统的信息,包括这些编码系统指定的行尾转换。您可以指定编码系统名称作为参数;或者,使用空参数,它描述当前为各种目的选择的编码系统(在当前缓冲区中和默认值)以及用于识别编码系统的优先级列表(请参阅识别编码系统)。

The command C-h C (describe-coding-system) displays information about particular coding systems, including the end-of-line conversion specified by those coding systems. You can specify a coding system name as the argument; alternatively, with an empty argument, it describes the coding systems currently selected for various purposes, both in the current buffer and as the defaults, and the priority list for recognizing coding systems (see Recognizing Coding Systems).

要显示所有支持的编码系统的列表,请键入M-x list-coding-systems。该列表提供了有关每个编码系统的信息,包括模式行中代表它的字母(请参阅模式行)。

To display a list of all the supported coding systems, type M-x list-coding-systems. The list gives information about each coding system, including the letter that stands for it in the mode line (see The Mode Line).

此列表中出现的每个编码系统(除了 no-conversion,表示不进行任何类型的转换)指定如何以及是否转换打印字符,但行尾转换的选择取决于每个文件。例如,如果文件似乎使用顺序回车和换行来分隔行,则将使用 DOS 行尾转换。

Each of the coding systems that appear in this list—except for no-conversion, which means no conversion of any kind—specifies how and whether to convert printing characters, but leaves the choice of end-of-line conversion to be decided based on the contents of each file. For example, if the file appears to use the sequence carriage return and linefeed to separate lines, DOS end-of-line conversion will be used.

列出的每个编码系统都有三个变体,它们准确地指定了行尾转换的操作:

Each of the listed coding systems has three variants, which specify exactly what to do for end-of-line conversion:

…-unix
…-unix

不进行任何行尾转换;假设文件使用换行符来分隔行。 (这是 Unix 和 GNU 系统以及 macOS 上通常使用的约定。)

Don’t do any end-of-line conversion; assume the file uses newline to separate lines. (This is the convention normally used on Unix and GNU systems, and macOS.)

…-dos
…-dos

假设文件使用回车符和换行符来分隔行,并进行适当的转换。 (这是 Microsoft 系统上通常使用的约定。9

Assume the file uses carriage return followed by linefeed to separate lines, and do the appropriate conversion. (This is the convention normally used on Microsoft systems.9)

…-mac
…-mac

假设文件使用回车符分隔行,并进行适当的转换。 (这是经典 Mac OS 中使用的约定。)

Assume the file uses carriage return to separate lines, and do the appropriate conversion. (This was the convention used in Classic Mac OS.)

为了简洁起见,这些变体编码系统在 list-coding-systems显示中被省略,因为它们是完全可预测的。例如,编码系统iso-latin-1有变体iso-latin-1-unixiso-latin-1-dosiso-latin-1-mac

These variant coding systems are omitted from the list-coding-systems display for brevity, since they are entirely predictable. For example, the coding system iso-latin-1 has variants iso-latin-1-unix, iso-latin-1-dos and iso-latin-1-mac.

编码系统unixdos和分别macundecided-unixundecided-dos和 的别名undecided-mac。这些编码系统仅指定行尾转换,并让字符代码转换从文本本身推断出来。

The coding systems unix, dos, and mac are aliases for undecided-unix, undecided-dos, and undecided-mac, respectively. These coding systems specify only the end-of-line conversion, and leave the character code conversion to be deduced from the text itself.

该编码系统raw-text适用于主要是 ASCII文本的文件,但可能包含大于 127 的字节值,这些字节值不打算对非ASCII字符进行编码。使用 时 raw-text,Emacs 会原封不动地复制这些字节值,并将其设置 enable-multibyte-charactersnil当前缓冲区中,以便正确解释它们。 raw-text根据遇到的数据以通常的方式处理行尾转换,并具有通常的三个变体来指定要使用的行尾转换类型。

The coding system raw-text is good for a file which is mainly ASCII text, but may contain byte values above 127 that are not meant to encode non-ASCII characters. With raw-text, Emacs copies those byte values unchanged, and sets enable-multibyte-characters to nil in the current buffer so that they will be interpreted properly. raw-text handles end-of-line conversion in the usual way, based on the data encountered, and has the usual three variants to specify the kind of end-of-line conversion to use.

相反,编码系统no-conversion根本不指定任何字符代码转换——对于非ASCII字节值不指定任何字符代码转换,对于行尾也不指定任何字符代码转换。这对于读取或写入二进制文件、tar 文件和其他必须逐字检查的文件非常有用。它也设置enable-multibyte-charactersnil

In contrast, the coding system no-conversion specifies no character code conversion at all—none for non-ASCII byte values and none for end of line. This is useful for reading or writing binary files, tar files, and other files that must be examined verbatim. It, too, sets enable-multibyte-characters to nil.

编辑文件而不进行任何类型转换的最简单方法是使用M-x find-file-literally命令。这会使用 no-conversion,并且还会抑制其他 Emacs 功能,这些功能可能会在您看到文件内容之前对其进行转换。请参阅访问文件

The easiest way to edit a file with no conversion of any kind is with the M-x find-file-literally command. This uses no-conversion, and also suppresses other Emacs features that might convert the file contents before you see them. See Visiting Files.

编码系统emacs-internal(或utf-8-emacs,等效的)意味着文件包含 使用内部 Emacs 编码存储的非ASCII字符。该编码系统根据遇到的数据处理行尾转换,并具有通常的三种变体来指定行尾转换的类型。

The coding system emacs-internal (or utf-8-emacs, which is equivalent) means that the file contains non-ASCII characters stored with the internal Emacs encoding. This coding system handles end-of-line conversion based on the data encountered, and has the usual three variants to specify the kind of end-of-line conversion.


23.6 识别编码系统

23.6 Recognizing Coding Systems

每当 Emacs 读取给定的文本片段时,它都会尝试识别要使用的编码系统。这适用于正在读取的文件、子进程的输出、X 选择的文本等。大多数情况下,一旦您指定了首选项,Emacs 就可以自动选择正确的编码系统。

Whenever Emacs reads a given piece of text, it tries to recognize which coding system to use. This applies to files being read, output from subprocesses, text from X selections, etc. Emacs can select the right coding system automatically most of the time—once you have specified your preferences.

一些编码系统可以通过数据中出现的字节序列来识别或区分。然而,有些编码系统无法区分,甚至无法区分。例如,没有办法区分Latin-1和Latin-2;它们使用具有不同含义的相同字节值。

Some coding systems can be recognized or distinguished by which byte sequences appear in the data. However, there are coding systems that cannot be distinguished, not even potentially. For example, there is no way to distinguish between Latin-1 and Latin-2; they use the same byte values with different meanings.

Emacs 通过编码系统优先级列表来处理这种情况。每当 Emacs 读取文件时,如果您没有指定要使用的编码系统,Emacs 会根据每个编码系统检查数据,从优先级最高的第一个系统开始,沿着列表向下查找,直到找到适合该数据的编码系统。然后它会转换文件内容,假设它们在此编码系统中表示。

Emacs handles this situation by means of a priority list of coding systems. Whenever Emacs reads a file, if you do not specify the coding system to use, Emacs checks the data against each coding system, starting with the first in priority and working down the list, until it finds a coding system that fits the data. Then it converts the file contents assuming that they are represented in this coding system.

编码系统的优先级列表取决于所选的语言环境(请参阅语言环境)。例如,如果您使用法语,您可能希望 Emacs 更喜欢 Latin-1 而不是 Latin-2;如果您使用捷克语,您可能希望首选 Latin-2。这是指定语言环境的原因之一。

The priority list of coding systems depends on the selected language environment (see Language Environments). For example, if you use French, you probably want Emacs to prefer Latin-1 to Latin-2; if you use Czech, you probably want Latin-2 to be preferred. This is one of the reasons to specify a language environment.

但是,您可以使用命令详细更改编码系统优先级列表M-x prefer-coding-system。该命令从迷你缓冲区中读取编码系统的名称,并将其添加到优先级列表的前面,以便它优先于所有其他系统。如果多次使用此命令,则每次使用都会在优先级列表的前面添加一个元素。

However, you can alter the coding system priority list in detail with the command M-x prefer-coding-system. This command reads the name of a coding system from the minibuffer, and adds it to the front of the priority list, so that it is preferred to all others. If you use this command several times, each use adds one element to the front of the priority list.

如果您使用指定行尾转换类型的编码系统,例如iso-8859-1-dos,这意味着 Emacs 应尝试iso-8859-1优先识别,并且在识别时应使用 DOS 行尾转换iso-8859-1

If you use a coding system that specifies the end-of-line conversion type, such as iso-8859-1-dos, what this means is that Emacs should attempt to recognize iso-8859-1 with priority, and should use DOS end-of-line conversion when it does recognize iso-8859-1.

有时,文件名指示该文件使用哪种编码系统。该变量file-coding-system-alist指定了这种对应关系。有一个特殊的函数 modify-coding-system-alist可以将元素添加到此列表中。例如,读取和写入所有 '。TXT' 使用编码系统的文件 chinese-iso-8bit,您可以执行这个 Lisp 表达式:

Sometimes a file name indicates which coding system to use for the file. The variable file-coding-system-alist specifies this correspondence. There is a special function modify-coding-system-alist for adding elements to this list. For example, to read and write all ‘.txt’ files using the coding system chinese-iso-8bit, you can execute this Lisp expression:

(修改编码系统-alist'文件“\\.txt\\'”'chinese-iso-8bit)
(modify-coding-system-alist 'file "\\.txt\\'" 'chinese-iso-8bit)

第一个参数应该是file,第二个参数应该是一个正则表达式,用于确定该文件适用于哪些文件,第三个参数表示这些文件使用哪种编码系统。

The first argument should be file, the second argument should be a regular expression that determines which files this applies to, and the third argument says which coding system to use for these files.

Emacs 根据文件的内容识别要使用哪种行尾转换:如果它只看到回车符,或者只看到回车符后跟换行序列,那么它会相应地选择行尾转换。您可以通过将变量设置inhibit-eol-conversion为非 来禁止自动使用行尾转换 nil。如果这样做,DOS 风格的文件将显示为带有“^M' 缓冲区中可见的字符;有些人更喜欢这个而不是更微妙的'(DOS)' 模式行左边缘附近的行尾类型指示(请参阅eol-mnemonic)。

Emacs recognizes which kind of end-of-line conversion to use based on the contents of the file: if it sees only carriage returns, or only carriage return followed by linefeed sequences, then it chooses the end-of-line conversion accordingly. You can inhibit the automatic use of end-of-line conversion by setting the variable inhibit-eol-conversion to non-nil. If you do that, DOS-style files will be displayed with the ‘^M’ characters visible in the buffer; some people prefer this to the more subtle ‘(DOS)’ end-of-line type indication near the left edge of the mode line (see eol-mnemonic).

默认情况下,编码系统的自动检测对转义序列敏感。如果 Emacs 看到以转义字符开头的字符序列,并且该序列作为 ISO-2022 代码有效,则会告诉 Emacs 使用其中一种 ISO-2022 编码来解码文件。

By default, the automatic detection of the coding system is sensitive to escape sequences. If Emacs sees a sequence of characters that begin with an escape character, and the sequence is valid as an ISO-2022 code, that tells Emacs to use one of the ISO-2022 encodings to decode the file.

但是,在某些情况下,您可能希望按原样读取文件中的转义序列。在这种情况下,您可以将该变量设置 inhibit-iso-escape-detection为非nil。然后,代码检测会忽略任何转义序列,并且从不使用 ISO-2022 编码。结果是所有转义序列在缓冲区中都变得可见。

However, there may be cases that you want to read escape sequences in a file as is. In such a case, you can set the variable inhibit-iso-escape-detection to non-nil. Then the code detection ignores any escape sequences, and never uses an ISO-2022 encoding. The result is that all escape sequences become visible in the buffer.

inhibit-iso-escape-detection的 默认值为nil。我们建议您不要永久更改它,仅针对一项特定操作进行更改。这是因为 Emacs 发行版中的某些 Emacs Lisp 源文件包含在编码系统中编码的非ASCIIiso-2022-7bit字符,如果您抑制转义序列检测,当您访问这些文件时,它们将无法正确解码。

The default value of inhibit-iso-escape-detection is nil. We recommend that you not change it permanently, only for one specific operation. That’s because some Emacs Lisp source files in the Emacs distribution contain non-ASCII characters encoded in the coding system iso-2022-7bit, and they won’t be decoded correctly when you visit those files if you suppress the escape sequence detection.

变量auto-coding-alistauto-coding-regexp-alist是分别为某些文件名模式或包含某些模式的文件指定编码系统的最强方法。这些变量甚至会覆盖 '-*-编码:-*-' 文件本身中的标记(请参阅指定文件的编码系统)。例如,Emacs 用于auto-coding-alisttar 和归档文件,以防止其被 ' 混淆。-*-编码:-*-' 标记在存档的成员中,并认为它适用于整个存档文件。

The variables auto-coding-alist and auto-coding-regexp-alist are the strongest way to specify the coding system for certain patterns of file names, or for files containing certain patterns, respectively. These variables even override ‘-*-coding:-*-’ tags in the file itself (see Specifying a File’s Coding System). For example, Emacs uses auto-coding-alist for tar and archive files, to prevent it from being confused by a ‘-*-coding:-*-’ tag in a member of the archive and thinking it applies to the archive file as a whole.

指定编码系统的另一种方法是使用变量 auto-coding-functions。例如,其中一个内置函数 auto-coding-functions会检测 XML 文件的编码。与前两个不同,此变量不会覆盖任何 '-*-编码:-*-' 标签。

Another way to specify a coding system is with the variable auto-coding-functions. For example, one of the builtin auto-coding-functions detects the encoding for XML files. Unlike the previous two, this variable does not override any ‘-*-coding:-*-’ tag.


23.7 指定文件的编码系统

23.7 Specifying a File’s Coding System

如果 Emacs 错误地识别文件的编码,您可以使用正确的编码系统通过( ) 重新读取该文件。该命令提示输入要使用的编码系统。要查看 Emacs 实际使用什么编码系统来解码文件,请查看模式行左边缘附近的编码系统助记符字母(请参阅模式行),或键入( )。 C-x RET rrevert-buffer-with-coding-systemC-h Cdescribe-coding-system

If Emacs recognizes the encoding of a file incorrectly, you can reread the file using the correct coding system with C-x RET r (revert-buffer-with-coding-system). This command prompts for the coding system to use. To see what coding system Emacs actually used to decode the file, look at the coding system mnemonic letter near the left edge of the mode line (see The Mode Line), or type C-h C (describe-coding-system).

您可以使用 ' 在文件本身中指定特定文件的编码系统-*--*-'在开头构造,或在末尾构造局部变量列表(请参阅文件中的局部变量)。您可以通过为名为 的“变量”定义一个值来完成此操作coding。 Emacs 并没有真正的变量coding;这不是设置变量,而是使用文件的指定编码系统。例如, '-*-模式:  C;编码:  latin-1; -*-'指定使用 Latin-1 编码系统以及 C 模式。当您在文件中显式指定编码时,它将覆盖 file-coding-system-alist.

You can specify the coding system for a particular file in the file itself, using the ‘-*--*- construct at the beginning, or a local variables list at the end (see Local Variables in Files). You do this by defining a value for the “variable” named coding. Emacs does not really have a variable coding; instead of setting a variable, this uses the specified coding system for the file. For example, ‘-*-mode: C; coding: latin-1; -*- specifies use of the Latin-1 coding system, as well as C mode. When you specify the coding explicitly in the file, that overrides file-coding-system-alist.


23.8 选择输出编码系统

23.8 Choosing Coding Systems for Output

一旦 Emacs 为缓冲区选择了编码系统,它就会将该编码系统存储在buffer-file-coding-system.这使得它成为从此缓冲区写入文件的操作的默认值,例如save-bufferwrite-region。您可以使用指定不同的编码系统以进一步从缓冲区输出文件 set-buffer-file-coding-system(请参阅为文件文本指定编码系统)。

Once Emacs has chosen a coding system for a buffer, it stores that coding system in buffer-file-coding-system. That makes it the default for operations that write from this buffer into a file, such as save-buffer and write-region. You can specify a different coding system for further file output from the buffer using set-buffer-file-coding-system (see Specifying a Coding System for File Text).

您可以将 Emacs 支持的任何字符插入到任何 Emacs 缓冲区中,但大多数编码系统只能处理这些字符的子集。因此,您插入的字符可能无法使用用于保存缓冲区的编码系统进行编码。例如,您可以访问以 编码的波兰语文本文件 iso-8859-2,并向其中添加一些俄语单词。当您保存该缓冲区时,Emacs 无法使用 的当前值 buffer-file-coding-system,因为您添加的字符无法由该编码系统进行编码。

You can insert any character Emacs supports into any Emacs buffer, but most coding systems can only handle a subset of these characters. Therefore, it’s possible that the characters you insert cannot be encoded with the coding system that will be used to save the buffer. For example, you could visit a text file in Polish, encoded in iso-8859-2, and add some Russian words to it. When you save that buffer, Emacs cannot use the current value of buffer-file-coding-system, because the characters you added cannot be encoded by that coding system.

当发生这种情况时,Emacs 会尝试最首选的编码系统(由M-x prefer-coding-system或设置M-x set-language-environment)。如果该编码系统可以安全地对缓冲区中的所有字符进行编码,Emacs 就会使用它,并将其值存储在buffer-file-coding-system.否则,Emacs 将显示适合对缓冲区内容进行编码的编码系统列表,并要求您选择其中一种编码系统。

When that happens, Emacs tries the most-preferred coding system (set by M-x prefer-coding-system or M-x set-language-environment). If that coding system can safely encode all of the characters in the buffer, Emacs uses it, and stores its value in buffer-file-coding-system. Otherwise, Emacs displays a list of coding systems suitable for encoding the buffer’s contents, and asks you to choose one of those coding systems.

如果您在邮件消息中插入不合适的字符,Emacs 的行为会略有不同。它还检查是否建议在 MIME 消息中使用最优选的编码系统;如果没有,它会通知您这一事实并提示您使用另一个编码系统。这样您就不会无意中发送以收件人的邮件软件难以解码的方式编码的消息。 (如果您在提示符下输入其名称,您仍然可以使用不合适的编码系统。)

If you insert the unsuitable characters in a mail message, Emacs behaves a bit differently. It additionally checks whether the most-preferred coding system is recommended for use in MIME messages; if not, it informs you of this fact and prompts you for another coding system. This is so you won’t inadvertently send a message encoded in a way that your recipient’s mail software will have difficulty decoding. (You can still use an unsuitable coding system if you enter its name at the prompt.)

当您发送邮件消息(请参阅发送邮件)时,Emacs 有四种不同的方法来确定用于对消息文本进行编码的编码系统。它首先尝试缓冲区自身的值( buffer-file-coding-system如果不是)nil。否则,它使用 的值sendmail-coding-system(如果该值非 )nil。第三,它利用了 的值 default-sendmail-coding-system。如果这三个值全部为nil,Emacs 将使用新文件的默认编码系统(即默认值buffer-file-coding-system)对外发邮件进行编码,该编码系统由您选择的语言环境控制。

When you send a mail message (see Sending Mail), Emacs has four different ways to determine the coding system to use for encoding the message text. It first tries the buffer’s own value of buffer-file-coding-system, if that is non-nil. Otherwise, it uses the value of sendmail-coding-system, if that is non-nil. Thirdly, it uses the value of default-sendmail-coding-system. If all of these three values are nil, Emacs encodes outgoing mail using the default coding system for new files (i.e., the default value of buffer-file-coding-system), which is controlled by your choice of language environment.


23.9 指定文件文本的编码系统

23.9 Specifying a Coding System for File Text

如果 Emacs 不会自动为文件内容选择正确的编码系统,您可以使用以下命令来指定一个:

In cases where Emacs does not automatically choose the right coding system for a file’s contents, you can use these commands to specify one:

C-x RET f coding RET
C-x RET f coding RET

使用编码系统编码保存或重新访问当前缓冲区 ( ) 中的文件set-buffer-file-coding-system

Use coding system coding to save or revisit the file in the current buffer (set-buffer-file-coding-system).

C-x RET c coding RET
C-x RET c coding RET

指定紧随其后的命令 ( ) 的编码系统编码universal-coding-system-argument

Specify coding system coding for the immediately following command (universal-coding-system-argument).

C-x RET r coding RET
C-x RET r coding RET

使用编码系统编码 ( revert-buffer-with-coding-system) 重新访问当前文件。

Revisit the current file using the coding system coding (revert-buffer-with-coding-system).

M-x recode-region RET right RET wrong RET
M-x recode-region RET right RET wrong RET

转换使用错误的编码系统解码的区域,使用正确的编码系统对其进行解码。

Convert a region that was decoded using coding system wrong, decoding it using coding system right instead.

命令 ( ) 设置当前缓冲区的文件编码系统(即保存或恢复文件时使用的编码系统)。您可以指定使用迷你缓冲区的编码系统。您还可以通过单击 模式行中编码系统指示器上的 来调用此命令(请参阅模式行)。 C-x RET fset-buffer-file-coding-systemmouse-3

The command C-x RET f (set-buffer-file-coding-system) sets the file coding system for the current buffer (i.e., the coding system to use when saving or reverting the file). You specify which coding system using the minibuffer. You can also invoke this command by clicking with mouse-3 on the coding system indicator in the mode line (see The Mode Line).

如果您指定的编码系统无法处理缓冲区中的所有字符,则当您尝试保存缓冲区时,Emacs 将警告您有关麻烦字符的信息,并要求您选择另一个编码系统(请参阅选择输出的编码系统)。

If you specify a coding system that cannot handle all the characters in the buffer, Emacs will warn you about the troublesome characters, and ask you to choose another coding system, when you try to save the buffer (see Choosing Coding Systems for Output).

您还可以使用此命令指定行尾转换(请参阅行尾转换)以对当前缓冲区进行编码。例如,将导致 Emacs 使用 DOS 风格的回车符后跟换行符来保存当前缓冲区的文本。 C-x RET f dos RET

You can also use this command to specify the end-of-line conversion (see end-of-line conversion) for encoding the current buffer. For example, C-x RET f dos RET will cause Emacs to save the current buffer’s text with DOS-style carriage return followed by linefeed line endings.

指定文件编码系统的另一种方法是在访问该文件时。首先使用命令 ();该命令使用迷你缓冲区来读取编码系统名称。退出迷你缓冲区后,指定的编码系统将用于紧随其后的命令C-x RET cuniversal-coding-system-argument

Another way to specify the coding system for a file is when you visit the file. First use the command C-x RET c (universal-coding-system-argument); this command uses the minibuffer to read a coding system name. After you exit the minibuffer, the specified coding system is used for the immediately following command.

因此,例如,如果紧随其后的命令是C-x C-f,它将使用该编码系统读取文件(并记录稍后保存文件时的编码系统)。或者,如果紧随其后的命令是C-x C-w,则它使用该编码系统写入文件。当您以这种方式而不是 with 指定保存的编码系统时,如果缓冲区包含编码系统无法处理的字符,则不会发出警告。 C-x RET f

So if the immediately following command is C-x C-f, for example, it reads the file using that coding system (and records the coding system for when you later save the file). Or if the immediately following command is C-x C-w, it writes the file using that coding system. When you specify the coding system for saving in this way, instead of with C-x RET f, there is no warning if the buffer contains characters that the coding system cannot handle.

受指定编码系统影响的其他文件命令包括 C-x iC-x C-v,以及 的其他窗口变体C-x C-f。 还会影响启动子进程的命令,包括(请参阅从 Emacs 运行 Shell 命令)。如果紧随其后的命令不使用编码系统,则 最终没有效果。 C-x RET cM-x shellC-x RET c

Other file commands affected by a specified coding system include C-x i and C-x C-v, as well as the other-window variants of C-x C-f. C-x RET c also affects commands that start subprocesses, including M-x shell (see Running Shell Commands from Emacs). If the immediately following command does not use the coding system, then C-x RET c ultimately has no effect.

无需转换即可访问文件的简单方法是使用M-x find-file-literally命令。请参阅访问文件

An easy way to visit a file with no conversion is with the M-x find-file-literally command. See Visiting Files.

变量的默认值buffer-file-coding-system 指定创建新文件时要使用的编码系统的选择。当您找到新文件以及创建缓冲区然后将其保存在文件中时,它适用。选择语言环境通常会将此变量设置为该语言环境的默认编码系统的良好选择。

The default value of the variable buffer-file-coding-system specifies the choice of coding system to use when you create a new file. It applies when you find a new file, and when you create a buffer and then save it in a file. Selecting a language environment typically sets this variable to a good choice of default coding system for that language environment.

如果您访问的文件具有错误的编码系统,您可以使用( ) 进行更正。这将使用您指定的编码系统再次访问当前文件。 C-x RET rrevert-buffer-with-coding-system

If you visit a file with a wrong coding system, you can correct this with C-x RET r (revert-buffer-with-coding-system). This visits the current file again, using a coding system you specify.

如果一段文本已经使用错误的编码系统插入到缓冲区中,您可以使用 重新对其进行解码M-x recode-region。这会提示您输入正确的编码系统,然后提示您输入实际使用的错误编码系统,并进行转换。它首先使用错误的编码系统对该区域进行编码,然后使用正确的编码系统再次对其进行解码。

If a piece of text has already been inserted into a buffer using the wrong coding system, you can redo the decoding of it using M-x recode-region. This prompts you for the proper coding system, then for the wrong coding system that was actually used, and does the conversion. It first encodes the region using the wrong coding system, then decodes it again using the proper coding system.


23.10 进程间通信的编码系统

23.10 Coding Systems for Interprocess Communication

本节说明如何指定用于与其他进程通信的编码系统。

This section explains how to specify coding systems for use in communication with other processes.

C-x RET x coding RET
C-x RET x coding RET

使用编码系统编码在其他图形应用程序之间传输选择 ( set-selection-coding-system)。

Use coding system coding for transferring selections to and from other graphical applications (set-selection-coding-system).

C-x RET X coding RET
C-x RET X coding RET

使用编码系统编码将一个 选择(下一个选择)传输到另一个图形应用程序或从另一个图形应用程序传输( set-next-selection-coding-system)。

Use coding system coding for transferring one selection—the next one—to or from another graphical application (set-next-selection-coding-system).

C-x RET p input-coding RET output-coding RET
C-x RET p input-coding RET output-coding RET

对当前缓冲区 ( ) 中的子进程输入和输出使用编码系统输入编码输出编码set-buffer-process-coding-system

Use coding systems input-coding and output-coding for subprocess input and output in the current buffer (set-buffer-process-coding-system).

命令( ) 指定用于将所选文本发送到其他窗口应用程序以及用于接收在其他应用程序中做出的选择的文本的编码系统。此命令适用于所有后续选择,直到您再次使用该命令覆盖它。命令( ) 指定在 Emacs 中进行的下一次选择或由 Emacs 读取的编码系统。 C-x RET xset-selection-coding-systemC-x RET Xset-next-selection-coding-system

The command C-x RET x (set-selection-coding-system) specifies the coding system for sending selected text to other windowing applications, and for receiving the text of selections made in other applications. This command applies to all subsequent selections, until you override it by using the command again. The command C-x RET X (set-next-selection-coding-system) specifies the coding system for the next selection made in Emacs or read by Emacs.

该变量x-select-request-type指定从 X Window 系统请求的数据类型,以接收来自其他应用程序的文本选择。如果值为nil(默认值),Emacs 将按此顺序尝试UTF8_STRING和,并使用各种启发法来选择两个结果中更合适的一个;COMPOUND_TEXT如果这些都没有成功,Emacs 就会依靠STRING.如果 的值x-select-request-type是符号 COMPOUND_TEXTUTF8_STRINGSTRING或 之一TEXT,则 Emacs 仅使用该请求类型。如果该值是其中一些符号的列表,则 Emacs 仅按顺序尝试列表中的请求类型,直到其中之一成功,或者直到列表耗尽。

The variable x-select-request-type specifies the data type to request from the X Window System for receiving text selections from other applications. If the value is nil (the default), Emacs tries UTF8_STRING and COMPOUND_TEXT, in this order, and uses various heuristics to choose the more appropriate of the two results; if none of these succeed, Emacs falls back on STRING. If the value of x-select-request-type is one of the symbols COMPOUND_TEXT, UTF8_STRING, STRING, or TEXT, Emacs uses only that request type. If the value is a list of some of these symbols, Emacs tries only the request types in the list, in order, until one of them succeeds, or until the list is exhausted.

命令( ) 指定子进程的输入和输出的编码系统。该命令适用于当前缓冲区;通常,每个子进程都有自己的缓冲区,因此您可以使用此命令通过在相应缓冲区中给出命令来指定与特定子进程之间的转换。 C-x RET pset-buffer-process-coding-system

The command C-x RET p (set-buffer-process-coding-system) specifies the coding system for input and output to a subprocess. This command applies to the current buffer; normally, each subprocess has its own buffer, and thus you can use this command to specify translation to and from a particular subprocess by giving the command in the corresponding buffer.

您还可以在运行或启动子进程的命令之前使用 ( ) 来指定与该子进程通信的编码系统。请参阅指定文件文本的编码系统C-x RET cuniversal-coding-system-argument

You can also use C-x RET c (universal-coding-system-argument) just before the command that runs or starts a subprocess, to specify the coding system for communicating with that subprocess. See Specifying a Coding System for File Text.

进程输入和输出的默认翻译取决于当前的语言环境。

The default for translation of process input and output depends on the current language environment.

该变量指定在编码和解码系统字符串(例如系统错误消息和格式以及时间戳)locale-coding-system时要使用的编码系统。format-time-string该编码系统还可以用于解码 X Window 系统上的非ASCII 键盘输入,并且还可以用于以批处理模式对发送到标准输出和错误流的文本进行编码。您应该选择与底层系统的文本表示兼容的编码系统,通常由环境变量LC_ALLLC_CTYPE和 之一指定LANG。 (按照上面指定的顺序,第一个值非空的值决定文本表示形式。)

The variable locale-coding-system specifies a coding system to use when encoding and decoding system strings such as system error messages and format-time-string formats and time stamps. That coding system might also be used for decoding non-ASCII keyboard input on the X Window System and will also be used to encode text sent to the standard output and error streams in batch mode. You should choose a coding system that is compatible with the underlying system’s text representation, which is normally specified by one of the environment variables LC_ALL, LC_CTYPE, and LANG. (The first one, in the order specified above, whose value is nonempty is the one that determines the text representation.)


23.11 文件名编码系统

23.11 Coding Systems for File Names

C-x RET F coding RET
C-x RET F coding RET

使用编码系统编码对文件名进行编码和解码 ( set-file-name-coding-system)。

Use coding system coding for encoding and decoding file names (set-file-name-coding-system).

命令( ) 指定用于编码文件的编码系统。它对文件内容的读写没有影响。 C-x RET Fset-file-name-coding-system

The command C-x RET F (set-file-name-coding-system) specifies a coding system to use for encoding file names. It has no effect on reading and writing the contents of files.

事实上,这个命令所做的只是设置变量的值 file-name-coding-system。如果将变量设置为编码系统名称(作为 Lisp 符号或字符串),Emacs 会使用该编码系统对所有文件操作的文件名进行编码。这使得在文件名中使用非ASCII字符成为可能,或者至少使用指定编码系统可以编码的 非ASCII字符。

In fact, all this command does is set the value of the variable file-name-coding-system. If you set the variable to a coding system name (as a Lisp symbol or a string), Emacs encodes file names using that coding system for all file operations. This makes it possible to use non-ASCII characters in file names—or, at least, those non-ASCII characters that the specified coding system can encode.

如果file-name-coding-systemnil,Emacs 使用由所选语言环境确定的默认编码系统,并存储在default-file-name-coding-system变量中(通常为 UTF-8)。

If file-name-coding-system is nil, Emacs uses a default coding system determined by the selected language environment, and stored in the default-file-name-coding-system variable (normally UTF-8).

当 Emacs 在 NT 系列后代的 MS-Windows 版本(Windows 2000、XP 和所有更高版本)上运行时, 的值在 file-name-coding-system很大程度上被忽略,因为 Emacs 默认情况下使用允许直接传递 Unicode 文件名的 API。相比之下,在 Windows 9X 上,文件名使用 进行编码 file-name-coding-system,应将其设置为与当前系统区域设置相关的代码页(请参阅代码页)。该变量的值w32-unicode-filenames 控制 Emacs 在调用接受文件名的操作系统函数时是否使用 Unicode API。nil在 Windows 9X 上以及t较新版本的 MS-Windows 上, 此变量由启动代码设置。

When Emacs runs on MS-Windows versions that are descendants of the NT family (Windows 2000, XP, and all the later versions), the value of file-name-coding-system is largely ignored, as Emacs by default uses APIs that allow passing Unicode file names directly. By contrast, on Windows 9X, file names are encoded using file-name-coding-system, which should be set to the codepage (see codepage) pertinent for the current system locale. The value of the variable w32-unicode-filenames controls whether Emacs uses the Unicode APIs when it calls OS functions that accept file names. This variable is set by the startup code to nil on Windows 9X, and to t on newer versions of MS-Windows.

警告:如果您file-name-coding-system在 Emacs 会话中更改(或语言环境),并且您已经访问过其名称使用早期编码系统编码且无法在新编码系统下编码(或以不同方式编码)的文件,则可能会导致问题编码系统。如果您尝试以访问的文件名保存这些缓冲区之一,则保存可能会使用错误的文件名,或者可能会遇到错误。如果发生此类问题,请使用C-x C-w为该缓冲区指定一个新文件名。

Warning: if you change file-name-coding-system (or the language environment) in the middle of an Emacs session, problems can result if you have already visited files whose names were encoded using the earlier coding system and cannot be encoded (or are encoded differently) under the new coding system. If you try to save one of these buffers under the visited file name, saving may use the wrong file name, or it may encounter an error. If such a problem happens, use C-x C-w to specify a new file name for that buffer.

如果文件名编码出现错误,可以使用该命令 M-x recode-file-name更改文件名的编码系统。这会提示输入现有文件名、其旧编码系统以及您希望转换到的编码系统。

If a mistake occurs when encoding a file name, use the command M-x recode-file-name to change the file name’s coding system. This prompts for an existing file name, its old coding system, and the coding system to which you wish to convert.


23.12 X 键盘输入的编码系统

23.12 Coding Systems for X Keyboard Input

X Window 系统下的输入方法指定了必须用于解码键盘输入的自己的编码系统。默认情况下,Emacs 在与输入法服务器建立连接时自动确定每种输入法使用的编码系统,并使用该特定编码系统对键盘输入进行解码。然而,这种决定有时可能会失败。在这种情况下,将使用 区域设置编码系统(请参阅进程间通信的编码系统)。

Input methods under the X Window System specify their own coding systems that must be used to decode keyboard input. By default, Emacs determines the coding system used for each input method automatically upon establishing the connection to the input method server, and uses that specific coding system to decode keyboard input. However, that determination can sometimes fail; in that situation, the locale coding system (see Coding Systems for Interprocess Communication) is used instead.

如果输入法未正确声明其用于对文本进行编码的编码系统,则必须手动指定 Emacs 用于从输入法解码文本的编码系统。当变量 的值x-input-coding-system设置为符号时,将无条件地用作用于解码来自输入法的键盘输入的编码系统。

If the input method does not correctly announce the coding system it uses to encode text, then the coding system used by Emacs to decode text from input methods must be manually specified. The value of the variable x-input-coding-system, when set to a symbol, is unconditionally used as the coding system used to decode keyboard input from input methods.


23.13 终端 I/O 的编码系统

23.13 Coding Systems for Terminal I/O

C-x RET t coding RET
C-x RET t coding RET

终端输出使用编码系统编码set-terminal-coding-system( )。

Use coding system coding for terminal output (set-terminal-coding-system).

C-x RET k coding RET
C-x RET k coding RET

使用键盘输入的编码系统编码set-keyboard-coding-system( )。

Use coding system coding for keyboard input (set-keyboard-coding-system).

命令( )指定终端输出的编码系统。如果为终端输出指定字符代码,则输出到终端的所有字符都将转换为该编码系统。 C-x RET tset-terminal-coding-system

The command C-x RET t (set-terminal-coding-system) specifies the coding system for terminal output. If you specify a character code for terminal output, all characters output to the terminal are translated into that coding system.

此功能对于某些为支持特定语言或字符集而构建的纯字符终端非常有用,例如,支持 ISO 拉丁字符集之一的欧洲终端。使用多字节文本时需要指定终端编码系统,以便 Emacs 知道终端实际可以处理哪些字符。

This feature is useful for certain character-only terminals built to support specific languages or character sets—for example, European terminals that support one of the ISO Latin character sets. You need to specify the terminal coding system when using multibyte text, so that Emacs knows which characters the terminal can actually handle.

默认情况下,终端的输出根本不会被翻译,除非 Emacs 可以根据您的终端类型或语言环境规范推断出正确的编码系统(请参阅语言环境)。

By default, output to the terminal is not translated at all, unless Emacs can deduce the proper coding system from your terminal type or your locale specification (see Language Environments).

命令( ) 或变量指定键盘输入的编码系统。键盘输入的字符代码转换对于带有发送非ASCII 图形字符的按键的终端非常有用,例如,为 ISO Latin-1 或其子集设计的某些终端。 C-x RET kset-keyboard-coding-systemkeyboard-coding-system

The command C-x RET k (set-keyboard-coding-system), or the variable keyboard-coding-system, specifies the coding system for keyboard input. Character-code translation of keyboard input is useful for terminals with keys that send non-ASCII graphic characters—for example, some terminals designed for ISO Latin-1 or subsets of it.

默认情况下,键盘输入根据您的系统区域设置进行翻译。如果您的终端并不真正支持您的区域设置所隐含的编码(例如,如果您发现在键入 时它会插入非ASCIIM-i字符),则需要设置 keyboard-coding-systemnil来关闭编码。你可以通过放置来做到这一点

By default, keyboard input is translated based on your system locale setting. If your terminal does not really support the encoding implied by your locale (for example, if you find it inserts a non-ASCII character if you type M-i), you will need to set keyboard-coding-system to nil to turn off encoding. You can do this by putting

(设置键盘编码系统为零)
(set-keyboard-coding-system nil)

在你的初始化文件中。

in your init file.

设置keyboard-coding-system对 MS-Windows 没有影响,但旧的 Windows 9X 系统除外,在这种情况下,编码必须与 MS-Windows 控制台的当前代码页匹配,可以通过调用w32-set-console-codepage.

Setting keyboard-coding-system has no effect on MS-Windows, except on old Windows 9X systems, in which case the encoding must match the current codepage of the MS-Windows console, which can be changed by calling w32-set-console-codepage.

使用编码系统翻译进行键盘输入与使用输入法之间存在相似之处:两者都定义翻译为单个字符的键盘输入序列。然而,输入法被设计为方便人类交互使用,并且翻译的序列通常是ASCII 打印字符的序列。编码系统通常翻译非图形字符序列。

There is a similarity between using a coding system translation for keyboard input, and using an input method: both define sequences of keyboard input that translate into single characters. However, input methods are designed to be convenient for interactive use by humans, and the sequences that are translated are typically sequences of ASCII printing characters. Coding systems typically translate sequences of non-graphic characters.


23.14 字体集

23.14 Fontsets

字体通常定义单个字母或脚本的形状。因此,显示 Emacs 支持的整个脚本范围需要许多字体的集合。在 Emacs 中,这样的集合称为fontset。字体集由一系列字体规范定义,每个字体规范被分配来处理一定范围的字符代码,并且可以依靠另一个字体集来处理其指定的字体未涵盖的字符。

A font typically defines shapes for a single alphabet or script. Therefore, displaying the entire range of scripts that Emacs supports requires a collection of many fonts. In Emacs, such a collection is called a fontset. A fontset is defined by a list of font specifications, each assigned to handle a range of character codes, and may fall back on another fontset for characters that are not covered by the fonts it specifies.

每个字体集都有一个名称,就像字体一样。然而,虽然字体存储在系统中并且可用的字体名称由系统定义,但字体集是在 Emacs 本身内定义的。一旦定义了字体集,您就可以在 Emacs 中通过指定其名称来使用它,无论您可以在任何可以使用单一字体的地方。当然,Emacs 字体集只能使用您的系统支持的字体。如果某些字符在屏幕上显示为空框或十六进制代码,则意味着它们使用的字体集没有适合这些字符的字体。在这种情况下,或者如果显示了字符,但效果不如您想要的那样,您可能需要安装额外的字体或修改字体集以使用系统上已安装的特定字体(见下文)。您的操作系统可能有可供安装的可选字体;或者您可以安装 GNU Intlfonts 包,其中包括大多数受支持脚本的字体。10

Each fontset has a name, like a font. However, while fonts are stored in the system and the available font names are defined by the system, fontsets are defined within Emacs itself. Once you have defined a fontset, you can use it within Emacs by specifying its name, anywhere that you could use a single font. Of course, Emacs fontsets can use only the fonts that your system supports. If some characters appear on the screen as empty boxes or hex codes, this means that the fontset in use for them has no font for those characters. In this case, or if the characters are shown, but not as well as you would like, you may need to install extra fonts or modify the fontset to use specific fonts already installed on your system (see below). Your operating system may have optional fonts that you can install; or you can install the GNU Intlfonts package, which includes fonts for most supported scripts.10

Emacs 自动创建三种字体集:标准字体集启动字体集默认字体集。默认字体集很可能具有适用于各种非ASCII字符的字体,并且如果您设置默认字体而不是字体集,则它是其他两个字体集的默认后备字体。但是,它没有指定字体系列名称,因此如果直接使用它,结果可能会有些随机。您可以通过使用 ' 启动 Emacs 来指定特定的字体集-fn' 选项。例如,

Emacs creates three fontsets automatically: the standard fontset, the startup fontset and the default fontset. The default fontset is most likely to have fonts for a wide variety of non-ASCII characters, and is the default fallback for the other two fontsets, and if you set a default font rather than fontset. However, it does not specify font family names, so results can be somewhat random if you use it directly. You can specify a particular fontset by starting Emacs with the ‘-fn’ option. For example,

emacs -fn 字体集标准
emacs -fn fontset-standard

您还可以使用 ' 指定字体集字体' 资源(参见X 选项和资源)。

You can also specify a fontset with the ‘Font’ resource (see X Options and Resources).

如果没有指定使用字体集,则 Emacs 使用 ASCII字体,并带有 '默认字体集' 作为字体未覆盖的字符的后备。标准字体集仅在明确请求时才使用,无论其名称如何。

If no fontset is specified for use, then Emacs uses an ASCII font, with ‘fontset-default’ as a fallback for characters the font does not cover. The standard fontset is only used if explicitly requested, despite its name.

要显示有关特定字体集的信息,请使用该 命令。它提示输入字体集名称,默认为当前帧使用的字体集名称,然后显示所有字符子范围以及在该字体集中分配给它们的字体。要查看 Emacs 在没有特定字体集的情况下启动的会话中使用哪些字体(这是正常情况),请在提示符处键入,或者仅 描述当前框架使用的字体集。 M-x describe-fontsetfontset-default RETRET

To show the information about a specific fontset, use the M-x describe-fontset command. It prompts for a fontset name, defaulting to the one used by the current frame, and then displays all the subranges of characters and the fonts assigned to them in that fontset. To see which fonts Emacs is using in a session started without a specific fontset (which is what happens normally), type fontset-default RET at the prompt, or just RET to describe the fontset used by the current frame.

字体集不一定为每个字符代码指定字体。如果字体集没有为某个字符指定字体,或者指定的字体在您的系统上不存在,则无法正确显示该字符。它将将该字符显示为十六进制代码或薄空格或空框。 (有关详细信息,请参阅无字形字符。)或者字体集可能为某些字符范围指定字体,但您可能不喜欢它们的视觉外观。如果发生这种情况,您可能希望修改您的字体集;有关如何执行此操作的信息, 请参阅 修改字体集。

A fontset does not necessarily specify a font for every character code. If a fontset specifies no font for a certain character, or if it specifies a font that does not exist on your system, then it cannot display that character properly. It will display that character as a hex code or thin space or an empty box instead. (See glyphless characters, for details.) Or a fontset might specify a font for some range of characters, but you may not like their visual appearance. If this happens, you may wish to modify your fontset; see Modifying Fontsets, for how to do that.


23.15 定义字体集

23.15 Defining Fontsets

当在 X 上运行时,Emacs 根据 的值自动创建标准字体集standard-fontset-spec。这个字体集的名字是

When running on X, Emacs creates a standard fontset automatically according to the value of standard-fontset-spec. This fontset’s name is

-*-固定中-r-正常-*-16-*-*-*-*-*-字体集标准
-*-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-standard

要不就 '字体集标准' 简而言之。

or just ‘fontset-standard’ for short.

在 GNUstep 和 macOS 上,标准字体集是使用 的值创建的 ns-standard-fontset-spec,在 MS Windows 上,它是使用 的值创建的w32-standard-fontset-spec

On GNUstep and macOS, the standard fontset is created using the value of ns-standard-fontset-spec, and on MS Windows it is created using the value of w32-standard-fontset-spec.

标准字体集的粗体、斜体和粗斜体变体是自动创建的。他们的名字有‘大胆的' 代替 '中等的', 或者 '' 代替 'r', 或两者。

Bold, italic, and bold-italic variants of the standard fontset are created automatically. Their names have ‘bold’ instead of ‘medium’, or ‘i’ instead of ‘r’, or both.

Emacs 会根据您使用 ' 指定的任何默认ASCII字体自动生成字体集 字体'资源或'-fn' 参数,或者 Emacs 启动时发现的默认字体。这是启动字体集,其名称为 fontset-startup。 Emacs 通过将charset_registry字段替换为 ' 来生成此字体集 字体集',并将 charset_encoding字段替换为 '启动',然后使用结果字符串来指定字体集。

Emacs generates a fontset automatically, based on any default ASCII font that you specify with the ‘Font’ resource or the ‘-fn’ argument, or the default font that Emacs found when it started. This is the startup fontset and its name is fontset-startup. Emacs generates this fontset by replacing the charset_registry field with ‘fontset’, and replacing the charset_encoding field with ‘startup’, then using the resulting string to specify a fontset.

例如,如果您使用这种形式的字体启动 Emacs,

For instance, if you start Emacs with a font of this form,

emacs -fn "*courier-medium-r-normal--14-140-*-iso8859-1"
emacs -fn "*courier-medium-r-normal--14-140-*-iso8859-1"

Emacs 生成以下字体集并将其用于初始 X 窗口框架:

Emacs generates the following fontset and uses it for the initial X window frame:

-*-courier-medium-r-normal-*-14-140-*-*-*-*-fontset-startup
-*-courier-medium-r-normal-*-14-140-*-*-*-*-fontset-startup

启动字体集将使用您指定的字体或具有不同注册表和编码的变体,用于该字体支持的所有字符,并回退到 '默认字体集' 对于其他字符。

The startup fontset will use the font that you specify, or a variant with a different registry and encoding, for all the characters that are supported by that font, and fallback on ‘fontset-default’ for other characters.

与 X 资源'Emacs.字体',您可以像实际字体名称一样指定字体集名称。但请注意不要在通配符资源中指定字体集名称,例如 'Emacs*字体'—该通配符规范与各种其他资源相匹配,例如菜单,并且菜单无法处理字体集。请参阅X 选项和资源

With the X resource ‘Emacs.Font’, you can specify a fontset name just like an actual font name. But be careful not to specify a fontset name in a wildcard resource like ‘Emacs*Font’—that wildcard specification matches various other resources, such as for menus, and menus cannot handle fontsets. See X Options and Resources.

您可以使用名为 ' 的 X 资源指定其他字体集字体集-n',其中n是从 0 开始的整数。资源值应具有以下形式:

You can specify additional fontsets using X resources named ‘Fontset-n’, where n is an integer starting from 0. The resource value should have this form:

字体模式[字符集字体]…
fontpattern, [charset:font]…

其中fontpattern应具有标准 X 字体名称的形式(请参阅前面的 fontset-startup 示例),最后两个字段除外。他们应该具有以下形式 '字体集别名'。

where fontpattern should have the form of a standard X font name (see the previous fontset-startup example), except for the last two fields. They should have the form ‘fontset-alias’.

每个字体集都有两个名称,一长一短。长名称是 fontpattern。简称是 '字体集别名',长名称的最后 2 个字段(例如,'字体集启动' 对于启动时自动创建的字体集)。您可以通过任一名称引用字体集。

Each fontset has two names, one long and one short. The long name is fontpattern. The short name is ‘fontset-alias’, the last 2 fields of the long name (e.g., ‘fontset-startup’ for the fontset automatically created at startup). You can refer to the fontset by either name.

构造 '字符集字体' 指定对于一个特定字符集使用哪种字体(在此字体集中)。这里, charset是字符集的名称,font是该字符集使用的字体。您可以在定义一种字体集时多次使用此构造。

The construct ‘charset:font’ specifies which font to use (in this fontset) for one particular character set. Here, charset is the name of a character set, and font is the font to use for that character set. You can use this construct any number of times in defining one fontset.

对于其他字符集,Emacs 根据 fontpattern选择字体。它取代了 '字体集别名' 带有描述字符集的值。对于ASCII字符字体,'字体集别名' 被替换为 'ISO8859-1'。

For the other character sets, Emacs chooses a font based on fontpattern. It replaces ‘fontset-alias’ with values that describe the character set. For the ASCII character font, ‘fontset-alias’ is replaced with ‘ISO8859-1’.

此外,当多个连续字段为通配符时,Emacs 会将它们折叠为单个通配符。这是为了防止使用自动缩放字体。缩放较大字体制作的字体无法用于编辑,缩放较小的字体也没有什么用处,因为最好使用较小的字体本身的大小,这就是 Emacs 的做法。

In addition, when several consecutive fields are wildcards, Emacs collapses them into a single wildcard. This is to prevent use of auto-scaled fonts. Fonts made by scaling larger fonts are not usable for editing, and scaling a smaller font is also not useful, because it is better to use the smaller font in its own size, which is what Emacs does.

因此,如果fontpattern是这样的,

Thus if fontpattern is this,

-*-固定中-r-正常-*-24-*-*-*-*-*-fontset-24
-*-fixed-medium-r-normal-*-24-*-*-*-*-*-fontset-24

ASCII字符的字体规范如下:

the font specification for ASCII characters would be this:

-*-固定中-r-正常-*-24-*-ISO8859-1
-*-fixed-medium-r-normal-*-24-*-ISO8859-1

中文 GB2312 字符的字体规范如下:

and the font specification for Chinese GB2312 characters would be this:

-*-固定中-r-正常-*-24-*-gb2312*-*
-*-fixed-medium-r-normal-*-24-*-gb2312*-*

您可能没有符合上述字体规格的中文字体。大多数 X 发行版仅包含具有 '宋体' 或者 '放送提’在家庭领域。在这种情况下, '字体集-n' 可以指定为:

You may not have any Chinese font matching the above font specification. Most X distributions include only Chinese fonts that have ‘song ti’ or ‘fangsong ti’ in the family field. In such a case, ‘Fontset-n’ can be specified as:

Emacs.Fontset-0: -*-fixed-medium-r-normal-*-24-*-*-*-*-*-fontset-24,\
        中文-gb2312:-*-*-medium-r-normal-*-24-*-gb2312*-*
Emacs.Fontset-0: -*-fixed-medium-r-normal-*-24-*-*-*-*-*-fontset-24,\
        chinese-gb2312:-*-*-medium-r-normal-*-24-*-gb2312*-*

那么,除了中文 GB2312 字符之外的所有字符的字体规范都有 '固定的' 在family字段中,中文 GB2312 字符的字体规范有通配符 '*’在家庭 领域。

Then, the font specifications for all but Chinese GB2312 characters have ‘fixed’ in the family field, and the font specification for Chinese GB2312 characters has a wild card ‘*’ in the family field.

处理字体集资源值以创建字体集的函数称为create-fontset-from-fontset-spec。您还可以显式调用此函数来创建字体集。

The function that processes the fontset resource value to create the fontset is called create-fontset-from-fontset-spec. You can also call this function explicitly to create a fontset.

有关字体命名的更多信息,请参阅字体

See Fonts, for more information about font naming.


23.16 修改字体集

23.16 Modifying Fontsets

字体集并不总是需要从头开始创建。如果只需要进行较小的更改,则修改现有字体集可能会更容易,通常是“默认字体集'。修改'默认字体集' 也会影响使用它作为后备的其他字体集,因此可以是解决 Emacs 为特定脚本选择的字体问题的有效方法。

Fontsets do not always have to be created from scratch. If only minor changes are required it may be easier to modify an existing fontset, usually ‘fontset-default’. Modifying ‘fontset-default’ will also affect other fontsets that use it as a fallback, so can be an effective way of fixing problems with the fonts that Emacs chooses for a particular script.

可以使用 函数 来修改字体集set-fontset-font,指定要修改字体的字符、字符集、脚本或字符范围,以及要使用的字体的字体规范。一些例子是:

Fontsets can be modified using the function set-fontset-font, specifying a character, a charset, a script, or a range of characters to modify the font for, and a font specification for the font to be used. Some examples are:

;;汉字最好使用 big5 字体。
(设置字体集字体“字体集默认”
                  'han(字体规格:注册表“big5”)
                  nil '前置)

;;将 MyPrivateFont 用于 Unicode 私人使用区域。
(set-fontset-font "fontset-default" '(#xe000 . #xf8ff)
                  “我的私人字体”)

;;对 latin-3 字符集使用 Liberation Mono。
(设置字体集字体“字体集默认”'iso-8859-3
                  《解放单声道》)

;;使用 DejaVu Sans Mono 作为 fontset-startup 的后备
;;在求助于默认字体之前。
(set-fontset-font“fontset-startup”nil“DejaVu Sans Mono”
                  零'追加)
;; Prefer a big5 font for han characters.
(set-fontset-font "fontset-default"
                  'han (font-spec :registry "big5")
                  nil 'prepend)

;; Use MyPrivateFont for the Unicode private use area.
(set-fontset-font "fontset-default"  '(#xe000 . #xf8ff)
                  "MyPrivateFont")

;; Use Liberation Mono for latin-3 charset.
(set-fontset-font "fontset-default" 'iso-8859-3
                  "Liberation Mono")

;; Use DejaVu Sans Mono as a fallback in fontset-startup
;; before resorting to fontset-default.
(set-fontset-font "fontset-startup" nil "DejaVu Sans Mono"
                  nil 'append)

有关使用该函数的更多详细信息,请参阅GNU Emacs Lisp 参考手册中的字体集set-fontset-font

See Fontsets in GNU Emacs Lisp Reference Manual, for more details about using the set-fontset-font function.

如果您不知道该字符的代码点或其所属的脚本,您可以询问 Emacs。将鼠标指向该字符,然后键入 ( ),该信息以及更多信息将显示在 C-u C-x =what-cursor-position*帮助*Emacs 弹出的缓冲区。请参阅光标位置信息。例如,日语字符属于 '假名' 脚本,但日语文本也将它们与汉字混合,因此以下使用 '' 设置 Emacs 使用 ' 的脚本高知哥特式' 日语文本的字体:

If you don’t know the character’s codepoint or the script to which it belongs, you can ask Emacs. With point at the character, type C-u C-x = (what-cursor-position), and this information, together with much more, will be displayed in the *Help* buffer that Emacs pops up. See Cursor Position Information. For example, Japanese characters belong to the ‘kana’ script, but Japanese text also mixes them with Chinese characters so the following uses the ‘han’ script to set up Emacs to use the ‘Kochi Gothic’ font for Japanese text:

(set-fontset-font "fontset-default" 'han "高知哥特式")
(set-fontset-font "fontset-default" 'han "Kochi Gothic")

(为方便起见,'' Emacs 中的脚本设置为支持所有中文、日文和韩文(又名CJK )字符,而不仅仅是中文字符。)

(For convenience, the ‘han’ script in Emacs is set up to support all of the Chinese, Japanese, and Korean, a.k.a. CJK, characters, not just Chinese characters.)

有关已知脚本的列表,请参阅变量 script-representative-chars

For the list of known scripts, see the variable script-representative-chars.

如上所述的字体集设置仅影响默认字体不支持的字符,因此如果 '高知哥特式' 字体涵盖拉丁字符,它不会用于显示拉丁脚本,因为 Emacs 使用的默认字体通常涵盖基本拉丁语。

Fontset settings like those above only affect characters that the default font doesn’t support, so if the ‘Kochi Gothic’ font covers Latin characters, it will not be used for displaying Latin scripts, since the default font used by Emacs usually covers Basic Latin.

系统上安装的某些字体可能会损坏,或者对使用它们的字符产生令人不快的结果,并且您可能希望指示 Emacs 在搜索显示字符所需的合适字体时完全忽略它们。您可以通过将有问题的字体添加到变量face-ignored-fonts(一个列表)的值来做到这一点 。这是一个要放入您的示例〜/.emacs:

Some fonts installed on your system might be broken, or produce unpleasant results for characters for which they are used, and you may wish to instruct Emacs to completely ignore them while searching for a suitable font required to display a character. You can do that by adding the offending fonts to the value of the variable face-ignored-fonts, which is a list. Here’s an example to put in your ~/.emacs:

(添加到列表'face-ignored-fonts“一些不好的字体”)
(add-to-list 'face-ignored-fonts "Some Bad Font")

23.17 不可显示的字符

23.17 Undisplayable Characters

您的终端可能无法显示某些非ASCII字符。大多数文本终端仅支持单一字符集(使用变量default-terminal-coding-system 告诉 Emacs 是哪一个,终端 I/O 的编码系统);无法在该编码系统中编码的字符显示为 '' 默认情况下。

There may be some non-ASCII characters that your terminal cannot display. Most text terminals support just a single character set (use the variable default-terminal-coding-system to tell Emacs which one, Coding Systems for Terminal I/O); characters that can’t be encoded in that coding system are displayed as ‘?’ by default.

图形显示器可以显示更广泛的字符,但您可能没有为所有这些字符安装字体;没有字体的字符显示为空心框。

Graphical displays can display a broader range of characters, but you may not have fonts installed for all of them; characters that have no font appear as a hollow box.

如果您使用 Latin-1 字符,但您的终端无法显示 Latin-1,您可以安排显示助记符ASCII序列,例如 '“哦' 为 o 元音变音。加载库 iso-ascii去做这个。

If you use Latin-1 characters but your terminal can’t display Latin-1, you can arrange to display mnemonic ASCII sequences instead, e.g., ‘"o’ for o-umlaut. Load the library iso-ascii to do this.

如果您的终端可以显示 Latin-1,则可以使用等效的 Latin-1 字符和ASCII助记符的混合来显示其他欧洲字符集中的字符。自定义变量 latin1-display以启用此功能。助记符ASCII 序列大多与前缀输入法的助记符ASCII序列相对应。

If your terminal can display Latin-1, you can display characters from other European character sets using a mixture of equivalent Latin-1 characters and ASCII mnemonics. Customize the variable latin1-display to enable this. The mnemonic ASCII sequences mostly correspond to those of the prefix input methods.


23.18 单字节编辑模式

23.18 Unibyte Editing Mode

ISO 8859 Latin -n字符集定义了八进制 0240 到 0377(十进制 160 到 255)范围内的字符代码,以处理各种欧洲语言(以及一些非欧洲语言)所需的重音字母和标点符号。请注意,即使在单字节缓冲区中(即,如果您禁用多字节字符),Emacs 也会将具有此范围内的代码的字节视为原始字节,而不是字符。但是,Emacs 仍然可以处理这些字符代码,就好像它们 一次属于单字节字符集之一一样。要指定使用哪些 代码,请调用M-x set-language-environment并指定合适的语言环境,例如 '拉丁语-n'。请参阅《GNU Emacs Lisp 参考手册》中的“禁用多字节字符”

The ISO 8859 Latin-n character sets define character codes in the range 0240 to 0377 octal (160 to 255 decimal) to handle the accented letters and punctuation needed by various European languages (and some non-European ones). Note that Emacs considers bytes with codes in this range as raw bytes, not as characters, even in a unibyte buffer, i.e., if you disable multibyte characters. However, Emacs can still handle these character codes as if they belonged to one of the single-byte character sets at a time. To specify which of these codes to use, invoke M-x set-language-environment and specify a suitable language environment such as ‘Latin-n’. See Disabling Multibyte Characters in GNU Emacs Lisp Reference Manual.

Emacs 还可以将 160 到 255 范围内的字节显示为可读字符,前提是所使用的终端或字体支持它们。这会自动进行。在图形显示上,Emacs 还可以通过字体集显示单字节字符,实际上是根据当前语言环境显示等效的多字节字符。要请求此操作,请将变量设置 unibyte-display-via-language-environment为非值nil 。请注意,设置此项仅影响这些字节的显示方式,但不会改变 Emacs 将它们视为原始字节而不是字符的基本事实。

Emacs can also display bytes in the range 160 to 255 as readable characters, provided the terminal or font in use supports them. This works automatically. On a graphical display, Emacs can also display single-byte characters through fontsets, in effect by displaying the equivalent multibyte characters according to the current language environment. To request this, set the variable unibyte-display-via-language-environment to a non-nil value. Note that setting this only affects how these bytes are displayed, but does not change the fundamental fact that Emacs treats them as raw bytes, not as characters.

如果您的终端不支持显示 Latin-1 字符集,Emacs 可以将这些字符显示为ASCII序列,这至少可以让您清楚地了解这些字符是什么。为此,请加载库iso-ascii。可以实现其他拉丁字符集的类似库,但到目前为止尚未实现。

If your terminal does not support display of the Latin-1 character set, Emacs can display these characters as ASCII sequences which at least give you a clear idea of what the characters are. To do this, load the library iso-ascii. Similar libraries for other Latin-n character sets could be implemented, but have not been so far.

通常非 ISO-8859 字符(128 到 159 之间的十进制代码)显示为八进制转义符。您可以使用库standard-display-8bit中的函数为 ISO-8859 字符集的非标准扩展版本更改此设置disp-table

Normally non-ISO-8859 characters (decimal codes between 128 and 159 inclusive) are displayed as octal escapes. You can change this for non-standard extended versions of ISO-8859 character sets by using the function standard-display-8bit in the disp-table library.

输入单字节非ASCII 字符有两种方法:

There are two ways to input single-byte non-ASCII characters:

  • 您可以使用适合所选语言环境的输入法。请参阅输入法。当您在单字节缓冲区中使用输入法时,您用它指定的非ASCII字符将转换为单字节。
  • You can use an input method for the selected language environment. See Input Methods. When you use an input method in a unibyte buffer, the non-ASCII character you specify with it is converted to unibyte.
  • 如果您的键盘可以生成代表非ASCII字符的 128(十进制)及以上字符代码,您可以直接键入这些字符代码。

    在图形显示上,您不需要执行任何特殊操作即可使用这些键;他们应该只是工作。在文本终端上,您应该使用命令M-x set-keyboard-coding-system或自定义变量keyboard-coding-system来指定键盘使用的编码系统(请参阅终端 I/O 的编码系统)。启用此功能可能需要您用来ESC输入元字符;但是,在控制台终端或终端仿真器(例如 )上xterm,您可以安排将 Meta 转换为ESC 并且仍然能够直接在键盘上或使用ComposeAltGr键键入 8 位字符。请参阅用户输入的类型

    许多现代系统为许多语言提供本机输入方法,这些语言的字符没有分配给它们的键盘按键。如果 Emacs 是在支持这些本机输入法的情况下构建的,则您可以激活此类输入法并键入它们支持的字符。如何激活和使用这些输入法取决于系统和输入法,这里不再赘述;请参阅您的系统文档。这里我们描述一些 Emacs 工具来控制本机输入法的使用。

    在使用 GTK 工具包构建的 Emacs 中,该变量 x-gtk-use-native-input控制 Emacs 是否应该接收 GTK 输入法生成的字符。如果值为nil,则默认情况下,Emacs 使用 X 输入法 ( XIM ),否则使用 GTK 输入法。 X资源useXIM控制是否使用XIMinputStyleX 资源控制原生输入法生成的预览文本在 X 上的显示;请参阅Emacs 的 X 资源表

    在 MS-Windows 上,Emacs 支持IMM (输入法管理器)提供的本机输入法 ,但如果需要可以将其关闭;请参阅MS-Windows 上的键盘使用

  • If your keyboard can generate character codes 128 (decimal) and up, representing non-ASCII characters, you can type those character codes directly.

    On a graphical display, you should not need to do anything special to use these keys; they should simply work. On a text terminal, you should use the command M-x set-keyboard-coding-system or customize the variable keyboard-coding-system to specify which coding system your keyboard uses (see Coding Systems for Terminal I/O). Enabling this feature will probably require you to use ESC to type Meta characters; however, on a console terminal or a terminal emulator such as xterm, you can arrange for Meta to be converted to ESC and still be able to type 8-bit characters present directly on the keyboard or using Compose or AltGr keys. See Kinds of User Input.

    Many modern systems provide native input methods for many languages whose characters don’t have keyboard keys assigned to them. If Emacs was built with support for these native input methods, you can activate such an input method and type the characters they support. How to activate and use these input methods depends on the system and the input method, and will not be described here; see your system documentation. Here we describe some Emacs facilities to control the use of the native input methods.

    In Emacs built with the GTK toolkit, the variable x-gtk-use-native-input controls whether Emacs should receive characters produced by GTK input methods. If the value is nil, the default, Emacs uses the X input methods (XIM), otherwise it uses the GTK input methods. The useXIM X resource controls whether to use XIM, and inputStyle X resource controls the display on X of preview text generated by the native input methods; see Table of X Resources for Emacs.

    On MS-Windows, Emacs supports native inputs methods provided by IMM, the Input Method Manager, but that can be turned off if needed; see Keyboard Usage on MS-Windows.

  • 您可以使用该键作为输入非ASCII Latin-1 和其他打印字符 C-x 8的组合字符前缀。适合插入(在迷你缓冲区以及其他缓冲区中)、搜索以及允许键序列的任何其他上下文。 C-x 8

    C-x 8通过加载库来工作iso-transl。加载该库后,Alt修改键(如果键盘有的话)的作用与:与重音字符一起C-x 8使用来修改后面的字母。Alt此外,如果键盘上有 Latin-1 死重音字符的键,则它们也被定义为在 iso-transl加载后与后面的字符组合。

    用于C-x 8 C-h列出所有可用的C-x 8翻译。

  • You can use the key C-x 8 as a compose-character prefix for entry of non-ASCII Latin-1 and other printing characters. C-x 8 is good for insertion (in the minibuffer as well as other buffers), for searching, and in any other context where a key sequence is allowed.

    C-x 8 works by loading the iso-transl library. Once that library is loaded, the Alt modifier key, if the keyboard has one, serves the same purpose as C-x 8: use Alt together with an accent character to modify the following letter. In addition, if the keyboard has keys for the Latin-1 dead accent characters, they too are defined to compose with the following character, once iso-transl is loaded.

    Use C-x 8 C-h to list all the available C-x 8 translations.


23.19 字符集

23.19 Charsets

在 Emacs 中,charset是“字符集”的缩写。 Emacs除了支持一些它自己的字符集(例如asciiiso-8859-1、和)之外,还支持大多数流行的字符集(例如、 、 、 和cp1250)。所有受支持的字符都属于一个或多个字符集。 big5unicodeemacsunicode-bmpeight-bit

In Emacs, charset is short for “character set”. Emacs supports most popular charsets (such as ascii, iso-8859-1, cp1250, big5, and unicode), in addition to some charsets of its own (such as emacs, unicode-bmp, and eight-bit). All supported characters belong to one or more charsets.

Emacs 通常会针对字符集执行正确的操作,因此您不必担心它们。然而,了解一些有关字符集的基本细节有时会很有帮助。

Emacs normally does the right thing with respect to charsets, so that you don’t have to worry about them. However, it is sometimes helpful to know some of the underlying details about charsets.

一个例子是字体选择(请参阅字体)。每个语言环境(请参阅语言环境)定义了各种字符集的优先级列表。当搜索字体时,Emacs 首先尝试查找可以显示最高优先级字符集的字体。例如,在日语环境中,字符集japanese-jisx0208具有最高优先级,因此 Emacs 尝试使用属性为registry'JISX0208.1983-0'。

One example is font selection (see Fonts). Each language environment (see Language Environments) defines a priority list for the various charsets. When searching for a font, Emacs initially attempts to find one that can display the highest-priority charsets. For instance, in the Japanese language environment, the charset japanese-jisx0208 has the highest priority, so Emacs tries to use a font whose registry property is ‘JISX0208.1983-0’.

有两个命令可用于获取有关字符集的信息。该命令M-x list-charset-chars提示输入字符集名称,并显示该字符集中的所有字符。该命令M-x describe-character-set提示输入字符集名称,并显示有关该字符集的信息,包括其在 Emacs 中的内部表示形式。

There are two commands that can be used to obtain information about charsets. The command M-x list-charset-chars prompts for a charset name, and displays all the characters in that character set. The command M-x describe-character-set prompts for a charset name, and displays information about that charset, including its internal representation within Emacs.

M-x list-character-sets显示所有支持的字符集的列表。该列表给出了字符集的名称以及用于标识每个字符集的附加信息;有关详细信息,请参阅 由日本信息处理学会/日本信息技术标准委员会 (IPSJ/ITSCJ)维护的ISO 国际编码字符集与转义序列一起使用的寄存器 (ISO-IR)。在此列表中,字符集分为两类:首先列出正常字符集,然后列出补充字符集。补充字符集用于定义另一个字符集(作为父字符集或子集),或为旧版 Emacs 提供向后兼容性。

M-x list-character-sets displays a list of all supported charsets. The list gives the names of charsets and additional information to identity each charset; for more details, see the ISO International Register of Coded Character Sets to be Used with Escape Sequences (ISO-IR) maintained by the Information Processing Society of Japan/Information Technology Standards Commission of Japan (IPSJ/ITSCJ). In this list, charsets are divided into two categories: normal charsets are listed first, followed by supplementary charsets. A supplementary charset is one that is used to define another charset (as a parent or a subset), or to provide backward-compatibility for older Emacs versions.

要找出缓冲区中的字符属于哪个字符集,请在其前面添加点并键入C-u C-x =(请参阅国际字符集简介)。

To find out which charset a character in the buffer belongs to, put point before it and type C-u C-x = (see Introduction to International Character Sets).


23.20 双向编辑

23.20 Bidirectional Editing

Emacs 支持编辑用脚本编写的文本,例如阿拉伯语、波斯语和希伯来语,其水平文本的自然显示顺序是从右到左。但是,这些脚本中嵌入的数字和拉丁文本仍然从左到右显示。在拉丁文文档中嵌入一小部分阿拉伯语或希伯来语文本的情况也并不罕见。例如,作为程序源文件中的注释和字符串。由于这些原因,使用这些脚本的文本实际上是双向的:从左到右和从右到左字符的混合运行。

Emacs supports editing text written in scripts, such as Arabic, Farsi, and Hebrew, whose natural ordering of horizontal text for display is from right to left. However, digits and Latin text embedded in these scripts are still displayed left to right. It is also not uncommon to have small portions of text in Arabic or Hebrew embedded in an otherwise Latin document; e.g., as comments and strings in a program source file. For these reasons, text that uses these scripts is actually bidirectional: a mixture of runs of left-to-right and right-to-left characters.

本节介绍 Emacs 提供的用于编辑双向文本的工具和选项。

This section describes the facilities and options provided by Emacs for editing bidirectional text.

Emacs 按照所谓的逻辑(或读取)顺序存储从右到左的双向文本 :您读取的第一个字符的缓冲区或字符串位置先于下一个字符。在显示时将双向文本重新排序为视觉顺序。因此,字符位置不再随着其显示位置单调增加。 Emacs 实现Unicode 标准附件 #9中描述的 Unicode 双向算法 (UBA) ,用于对双向文本进行重新排序以供显示。它与 UBA 的区别仅在于当文本方向与基本段落方向相反时(例如,当从右到左的段落中出现一长行英文文本时)如何显示续行。

Emacs stores right-to-left and bidirectional text in the so-called logical (or reading) order: the buffer or string position of the first character you read precedes that of the next character. Reordering of bidirectional text into the visual order happens at display time. As a result, character positions no longer increase monotonically with their positions on display. Emacs implements the Unicode Bidirectional Algorithm (UBA) described in the Unicode Standard Annex #9, for reordering of bidirectional text for display. It deviates from the UBA only in how continuation lines are displayed when text direction is opposite to the base paragraph direction, e.g., when a long line of English text appears in a right-to-left paragraph.

缓冲区局部变量bidi-display-reordering控制缓冲区中的文本是否重新排序以供显示。如果其值为 non- nil,则 Emacs 在显示时会对具有从右到左方向性的字符重新排序。默认值为 t

The buffer-local variable bidi-display-reordering controls whether text in the buffer is reordered for display. If its value is non-nil, Emacs reorders characters that have right-to-left directionality when they are displayed. The default value is t.

双向文本的每个段落都可以有自己的基本方向,从右到左或从左到右。从左到右段落中的文本从屏幕上窗口的左边距开始,并在到达右边距时被截断或继续。相比之下,从右到左的段落中的文本从右侧边距开始显示,并在左侧边距处继续或截断。默认情况下,段落边界是空行,即完全由空白字符组成的行。要改变这一点,您可以自定义两个变量bidi-paragraph-start-rebidi-paragraph-separate-re,其值应该是正则表达式(字符串);例如,要使用单个换行符开始一个新段落,请将这两个变量设置为"^"。这两个变量是缓冲区局部变量(请参阅局部变量)。

Each paragraph of bidirectional text can have its own base direction, either right-to-left or left-to-right. Text in left-to-right paragraphs begins on the screen at the left margin of the window and is truncated or continued when it reaches the right margin. By contrast, text in right-to-left paragraphs is displayed starting at the right margin and is continued or truncated at the left margin. By default, paragraph boundaries are empty lines, i.e., lines consisting entirely of whitespace characters. To change that, you can customize the two variables bidi-paragraph-start-re and bidi-paragraph-separate-re, whose values should be regular expressions (strings); e.g., to have a single newline start a new paragraph, set both of these variables to "^". These two variables are buffer-local (see Local Variables).

Emacs 根据段落开头的文本动态确定每个段落的基本方向。然而,有时缓冲区可能需要强制其段落采用某个基本方向。变量bidi-paragraph-direction如果非nil,则禁用基本方向的动态确定,而是强制缓冲区中的所有段落具有由其缓冲区本地值指定的方向。该值可以是 right-to-leftleft-to-right。任何其他值都被解释为nil

Emacs determines the base direction of each paragraph dynamically, based on the text at the beginning of the paragraph. However, sometimes a buffer may need to force a certain base direction for its paragraphs. The variable bidi-paragraph-direction, if non-nil, disables the dynamic determination of the base direction, and instead forces all paragraphs in the buffer to have the direction specified by its buffer-local value. The value can be either right-to-left or left-to-right. Any other value is interpreted as nil.

或者,您可以通过在段落前面插入特殊格式字符来控制段落的基本方向。特殊字符RIGHT-TO-LEFT MARKRLM强制下一段从右到左方向,而 LEFT-TO-RIGHT MARKLRM强制从左到右方向。 (您可以使用来插入这些字符。)在 GUI 会话中,LRMRLM字符显示为非常细的空白字符;在文本终端上它们显示为空白。 C-x 8 RET

Alternatively, you can control the base direction of a paragraph by inserting special formatting characters in front of the paragraph. The special character RIGHT-TO-LEFT MARK, or RLM, forces the right-to-left direction on the following paragraph, while LEFT-TO-RIGHT MARK, or LRM forces the left-to-right direction. (You can use C-x 8 RET to insert these characters.) In a GUI session, the LRM and RLM characters display as very thin blank characters; on text terminals they display as blanks.

由于字符会重新排序以供显示,因此按逻辑顺序或在缓冲区位置上运行的 Emacs 命令可能会产生不寻常的效果。例如,命令C-fC-b移动点按逻辑顺序排列,因此当点遍历重新排序的双向文本时,光标有时会跳转。类似地,如果覆盖连续范围的字符位置的突出显示区域跨越重新排序的文本,则该区域可能看起来不连续。这是正常现象,与支持双向文本的其他程序的行为类似。

Because characters are reordered for display, Emacs commands that operate in the logical order or on stretches of buffer positions may produce unusual effects. For example, the commands C-f and C-b move point in the logical order, so the cursor will sometimes jump when point traverses reordered bidirectional text. Similarly, a highlighted region covering a contiguous range of character positions may look discontinuous if the region spans reordered text. This is normal and similar to the behavior of other programs that support bidirectional text.

与箭头键绑定的光标移动命令(例如LEFT和 )对当前段落的基本方向敏感。在从左到右的段落中,绑定到 带或不带修饰符的命令将在缓冲区文本中向前移动,但在从右到左的段落中,它们会 向后移动。这反映了这样的事实:在从右到左的段落中,当向左移动时,缓冲区位置主要增加。 C-RIGHTRIGHT

Cursor motion commands bound to arrow keys, such as LEFT and C-RIGHT, are sensitive to the base direction of the current paragraph. In a left-to-right paragraph, commands bound to RIGHT with or without modifiers move forward through buffer text, but in a right-to-left paragraph they move backward instead. This reflects the fact that in a right-to-left paragraph buffer positions predominantly increase when moving to the left on display.

当您移出段落时,如果前一个或后一个段落的基本方向与您移出的段落不同,则箭头键的含义可能会发生变化。发生这种情况时,您需要将按下的箭头键调整到新的基本方向。

When you move out of a paragraph, the meaning of the arrow keys might change if the base direction of the preceding or the following paragraph is different from the paragraph out of which you moved. When that happens, you need to adjust the arrow key you press to the new base direction.

默认情况下,LEFTRIGHT按逻辑顺序移动,但如果visual-order-cursor-movement为非nil,则这些命令相应地移动到当前屏幕位置左侧或右侧的字符,并根据需要移动到下一个或上一个屏幕行。请注意,这可能会将点移开许多缓冲区位置,具体取决于周围的双向上下文。

By default, LEFT and RIGHT move in the logical order, but if visual-order-cursor-movement is non-nil, these commands move to the character that is, correspondingly, to the left or right of the current screen position, moving to the next or previous screen line as appropriate. Note that this might potentially move point many buffer positions away, depending on the surrounding bidirectional context.

双向文本有时使用特殊格式字符来影响显示文本的重新排序。上面提到的 LRM 和RLM角色就是 两个这样的角色,但还有更多。默认情况下,它们在 GUI 框架上显示为细空格字形,在文本模式框架上显示为简单空格。如果您想了解这些特殊控制字符,以便它们对显示的影响不会令人意外,您可以打开 glyphless-display-mode(请参阅如何显示文本)。此次要模式将使这些格式字符在小框中显示为首字母缩略词,以便它们在显示时脱颖而出,并使它们的效果更容易理解。

Bidirectional text sometimes uses special formatting characters to affect the reordering of text for display. The LRM and RLM characters, mentioned above, are two such characters, but there are more of them. They are by default displayed as thin space glyphs on GUI frames, and as simple spaces on text-mode frames. If you want to be aware of these special control characters, so that their effect on display does not come as a surprise, you can turn on the glyphless-display-mode (see How Text Is Displayed). This minor mode will cause these formatting characters to be displayed as acronyms inside a small box, so that they stand out on display, and make their effect easier to understand.


24种主要和次要模式

24 Major and Minor Modes

Emacs 包含许多编辑模式,可以以有用的方式改变其基本行为。这些模式分为主要模式次要模式

Emacs contains many editing modes that alter its basic behavior in useful ways. These are divided into major modes and minor modes.

主要模式提供了专门的工具来处理特定的文件类型,例如 C 源文件(请参阅编辑程序),或特定类型的非文件缓冲区,例如 shell 缓冲区(请参阅从 Emacs 运行 Shell 命令)。主要模式是相互排斥的;每个缓冲区在任何时候都有一个且只有一个主要模式。

Major modes provide specialized facilities for working on a particular file type, such as a C source file (see Editing Programs), or a particular type of non-file buffer, such as a shell buffer (see Running Shell Commands from Emacs). Major modes are mutually exclusive; each buffer has one and only one major mode at any time.

次要模式是可选功能,您可以打开或关闭它们,不一定特定于文件或缓冲区的类型。例如,自动填充模式是一种次要模式,在该模式下,SPC您键入时会在单词之间换行(请参阅自动填充模式)。小调模式彼此独立,并且独立于所选的大调模式。

Minor modes are optional features which you can turn on or off, not necessarily specific to a type of file or buffer. For example, Auto Fill mode is a minor mode in which SPC breaks lines between words as you type (see Auto Fill Mode). Minor modes are independent of one another, and of the selected major mode.


24.1 主要模式

24.1 Major Modes

每个缓冲区都拥有一个主模式,它决定了该缓冲区当前时 Emacs 的编辑行为。模式行通常在括号中显示当前主模式的名称(请参阅模式行)。

Every buffer possesses a major mode, which determines the editing behavior of Emacs while that buffer is current. The mode line normally shows the name of the current major mode, in parentheses (see The Mode Line).

最不专业的主要模式称为基本模式。此模式没有特定于模式的重新定义或变量设置,因此每个 Emacs 命令以其最通用的方式运行,并且每个用户选项变量都处于其默认状态。

The least specialized major mode is called Fundamental mode. This mode has no mode-specific redefinitions or variable settings, so that each Emacs command behaves in its most general manner, and each user option variable is in its default state.

要编辑 Emacs 识别的特定类型的文本(例如 Lisp 代码或英语文本),通常使用更专门的主要模式,例如 Lisp 模式或文本模式。大多数主要模式分为三大类。第一组包含普通文本的模式,可以是纯文本,也可以是带有标记的文本。它包括Text模式、HTML模式、SGML模式、TeX模式和Outline模式。第二组包含特定编程语言的模式。其中包括 Lisp 模式(有多种变体)、C 模式、Fortran 模式等。第三组由与文件不直接关联的主要模式组成;它们被用在 Emacs 为特定目的创建的缓冲区中。示例包括由 Dired 创建的缓冲区的 Dired 模式(请参阅Dired,目录编辑器)、由 的创建的缓冲区的消息模式C-x m (请参阅发送邮件)以及用于与下级 shell 进程通信的缓冲区的 Shell 模式(请参阅交互式子 shell)。

For editing text of a specific type that Emacs knows about, such as Lisp code or English text, you typically use a more specialized major mode, such as Lisp mode or Text mode. Most major modes fall into three major groups. The first group contains modes for normal text, either plain or with mark-up. It includes Text mode, HTML mode, SGML mode, TeX mode and Outline mode. The second group contains modes for specific programming languages. These include Lisp mode (which has several variants), C mode, Fortran mode, and others. The third group consists of major modes that are not associated directly with files; they are used in buffers created for specific purposes by Emacs. Examples include Dired mode for buffers made by Dired (see Dired, the Directory Editor), Message mode for buffers made by C-x m (see Sending Mail), and Shell mode for buffers used to communicate with an inferior shell process (see Interactive Subshell).

通常,当您第一次访问文件或创建缓冲区时,Emacs 会自动设置主要模式(请参阅选择文件模式)。您可以使用命令显式选择新的主要模式M-x。获取模式名称并添加-mode以获取选择该模式的命令名称(例如,M-x lisp-mode进入 Lisp 模式)。由于每个缓冲区都只有一种主要模式,因此无法“关闭”主要模式;相反,您必须切换到另一个。

Usually, the major mode is automatically set by Emacs, when you first visit a file or create a buffer (see Choosing File Modes). You can explicitly select a new major mode by using an M-x command. Take the name of the mode and add -mode to get the name of the command to select that mode (e.g., M-x lisp-mode enters Lisp mode). Since every buffer has exactly one major mode, there is no way to “turn off” a major mode; instead you must switch to a different one.

缓冲区局部变量的值major-mode是一个与主模式命令同名的符号(例如lisp-mode)。该变量是自动设置的;你不应该自己改变它。

The value of the buffer-local variable major-mode is a symbol with the same name as the major mode command (e.g., lisp-mode). This variable is set automatically; you should not change it yourself.

的默认值major-mode决定了未指定主要模式的文件以及使用 . 创建的新缓冲区使用的主要模式C-x b。通常,该默认值是符号 fundamental-mode,它指定基本模式。您可以通过自定义界面(请参阅轻松自定义界面)或通过在 init 文件中添加类似这样的行(请参阅Emacs 初始化文件)来更改此默认值:

The default value of major-mode determines the major mode to use for files that do not specify a major mode, and for new buffers created with C-x b. Normally, this default value is the symbol fundamental-mode, which specifies Fundamental mode. You can change this default value via the Customization interface (see Easy Customization Interface), or by adding a line like this to your init file (see The Emacs Initialization File):

(setq-默认主要模式'文本模式)
(setq-default major-mode 'text-mode)

major-mode如果的默认值为nil,则主要模式将从先前的当前缓冲区中获取。

If the default value of major-mode is nil, the major mode is taken from the previously current buffer.

专门的主要模式通常会更改某些键的含义以执行更适合该模式的操作。例如,编程语言模式绑定TAB根据语言规则缩进当前行(请参阅缩进)。经常更改的键是TABDEL、 和C-j。许多模式还定义了自己的特殊命令,通常绑定到前缀为 key 的键序列C-c(请参阅Keys)。主要模式还可以改变用户选项和变量;例如,编程语言模式通常为变量设置一个缓冲区本地值 comment-start,该值确定如何分隔源代码注释(请参阅操作注释)。

Specialized major modes often change the meanings of certain keys to do something more suitable for the mode. For instance, programming language modes bind TAB to indent the current line according to the rules of the language (see Indentation). The keys that are commonly changed are TAB, DEL, and C-j. Many modes also define special commands of their own, usually bound to key sequences whose prefix key is C-c (see Keys). Major modes can also alter user options and variables; for instance, programming language modes typically set a buffer-local value for the variable comment-start, which determines how source code comments are delimited (see Manipulating Comments).

要查看当前主要模式的文档,包括其键绑定列表,请键入C-h m( describe-mode)。请参阅其他帮助命令

To view the documentation for the current major mode, including a list of its key bindings, type C-h m (describe-mode). See Other Help Commands.

除了基本模式之外,每个主要模式都定义了一个模式钩子,这是每次在缓冲区中启用该模式时运行的可定制的 Lisp 函数列表。有关钩子的更多信息,请参阅钩子。每个模式钩子都以其主要模式命名,例如,Fortran 模式有fortran-mode-hook.此外,所有基于文本的主要模式都会运行text-mode-hook,并且许多编程语言模式 11(包括所有随 Emacs 一起分发的模式) prog-mode-hook都会在运行它们自己的模式挂钩之前运行。钩子函数可以查看变量的值major-mode以了解实际进入的模式。

Every major mode, apart from Fundamental mode, defines a mode hook, a customizable list of Lisp functions to run each time the mode is enabled in a buffer. See Hooks, for more information about hooks. Each mode hook is named after its major mode, e.g., Fortran mode has fortran-mode-hook. Furthermore, all text-based major modes run text-mode-hook, and many programming language modes 11 (including all those distributed with Emacs) run prog-mode-hook, prior to running their own mode hooks. Hook functions can look at the value of the variable major-mode to see which mode is actually being entered.

模式挂钩通常用于启用次要模式(请参阅次要模式)。例如,您可以将以下行放入 init 文件中,以在所有基于文本的主要模式中启用 Flyspell 次要模式(请参阅检查和更正拼写),以及在 Emacs Lisp 模式中启用 ElDoc 次要模式(请参阅编程语言文档查找):

Mode hooks are commonly used to enable minor modes (see Minor Modes). For example, you can put the following lines in your init file to enable Flyspell minor mode in all text-based major modes (see Checking and Correcting Spelling), and ElDoc minor mode in Emacs Lisp mode (see Programming Language Documentation Lookup):

(add-hook 'text-mode-hook 'flyspell-mode)
(add-hook 'emacs-lisp-mode-hook 'eldoc-mode)
(add-hook 'text-mode-hook 'flyspell-mode)
(add-hook 'emacs-lisp-mode-hook 'eldoc-mode)

24.2 次要模式

24.2 Minor Modes

次要模式是一种可选的编辑模式,它以某种明确定义的方式改变 Emacs 的行为。与主要模式不同,任意数量的次要模式可以随时生效。一些次要模式是 缓冲区本地的,可以在某些缓冲区中打开(启用),在其他缓冲区中关闭(禁用)。其他次要模式是全局的:启用后,它们会影响您在 Emacs 会话中的所有缓冲区中执行的所有操作。大多数次要模式默认情况下处于禁用状态,但也有少数模式默认情况下处于启用状态。

A minor mode is an optional editing mode that alters the behavior of Emacs in some well-defined way. Unlike major modes, any number of minor modes can be in effect at any time. Some minor modes are buffer-local, and can be turned on (enabled) in certain buffers and off (disabled) in others. Other minor modes are global: while enabled, they affect everything you do in the Emacs session, in all buffers. Most minor modes are disabled by default, but a few are enabled by default.

大多数缓冲区本地次要模式在启用时会在模式行中显示,就在主要模式指示符之后。例如, '充满模式行中的 ' 表示自动填充模式已启用。请参阅模式行

Most buffer-local minor modes say in the mode line when they are enabled, just after the major mode indicator. For example, ‘Fill’ in the mode line means that Auto Fill mode is enabled. See The Mode Line.

与主要模式一样,每个次要模式都与一个模式命令相关联,其名称由模式名称后跟 '-模式'。例如,自动填充模式的模式命令是 auto-fill-mode。但与仅启用该模式的主要模式命令不同,次要模式的模式命令可以启用或禁用它:

Like major modes, each minor mode is associated with a mode command, whose name consists of the mode name followed by ‘-mode’. For instance, the mode command for Auto Fill mode is auto-fill-mode. But unlike a major mode command, which simply enables the mode, the mode command for a minor mode can either enable or disable it:

  • 如果您直接调用不带前缀参数的模式命令(通过M-x,或将其绑定到某个键并键入该键;请参阅自定义键绑定),则会切换次要模式。次要模式关闭则开启,开启则关闭。
  • If you invoke the mode command directly with no prefix argument (either via M-x, or by binding it to a key and typing that key; see Customizing Key Bindings), that toggles the minor mode. The minor mode is turned on if it was off, and turned off if it was on.
  • 如果您使用前缀参数调用模式命令,则当该参数为零或负数时,次要模式将无条件关闭;否则无条件开启。
  • If you invoke the mode command with a prefix argument, the minor mode is unconditionally turned off if that argument is zero or negative; otherwise, it is unconditionally turned on.
  • 如果通过 Lisp 调用 mode 命令,则如果省略参数 或 ,则无条件打开次要模式nil。这使得从主要模式的模式挂钩打开次要模式变得容易(请参阅主要模式)。nil如上所述, 非参数的处理方式类似于交互式前缀参数。
  • If the mode command is called via Lisp, the minor mode is unconditionally turned on if the argument is omitted or nil. This makes it easy to turn on a minor mode from a major mode’s mode hook (see Major Modes). A non-nil argument is handled like an interactive prefix argument, as described above.

大多数次要模式还有一个模式变量,其名称与模式命令相同。nil如果模式已启用,则其值为非- ,nil如果模式已禁用,则其值为非。一般来说,你不应该尝试通过直接在 Lisp 中更改 mode 变量的值来启用或禁用该模式;您应该运行模式命令。但是,通过自定义界面(请参阅轻松自定义界面)设置模式变量将始终正确启用或禁用该模式,因为自定义会自动为您运行模式命令。

Most minor modes also have a mode variable, with the same name as the mode command. Its value is non-nil if the mode is enabled, and nil if it is disabled. In general, you should not try to enable or disable the mode by changing the value of the mode variable directly in Lisp; you should run the mode command instead. However, setting the mode variable through the Customize interface (see Easy Customization Interface) will always properly enable or disable the mode, since Customize automatically runs the mode command for you.

以下是一些缓冲区本地次要模式的列表:

The following is a list of some buffer-local minor modes:

  • 缩写模式根据预定义的缩写定义自动扩展文本。参见缩写
  • Abbrev mode automatically expands text based on pre-defined abbreviation definitions. See Abbrevs.
  • 自动填充模式会在您键入时插入换行符,以防止行变得太长。请参阅填充文本
  • Auto Fill mode inserts newlines as you type to prevent lines from becoming too long. See Filling Text.
  • 自动保存模式会定期保存缓冲区内容,以减少崩溃时可能丢失的工作量。请参阅自动保存:灾难防护
  • Auto Save mode saves the buffer contents periodically to reduce the amount of work you can lose in case of a crash. See Auto-Saving: Protection Against Disasters.
  • 电子报价模式自动转换引号。例如,它重新引用输入`like this'到 text 的文本‘like this’。您可以控制它运行的文本类型,并且可以在各个缓冲区中完全禁用它。请参阅引号
  • Electric Quote mode automatically converts quotation marks. For example, it requotes text typed `like this' to text ‘like this’. You can control what kind of text it operates in, and you can disable it entirely in individual buffers. See Quotation Marks.
  • 丰富模式可以编辑和保存格式化文本。请参阅丰富文本
  • Enriched mode enables editing and saving of formatted text. See Enriched Text.
  • Flyspell 模式会自动突出显示拼写错误的单词。请参阅检查和更正拼写
  • Flyspell mode automatically highlights misspelled words. See Checking and Correcting Spelling.
  • 字体锁定模式自动突出显示程序中找到的某些文本单元。默认情况下,它是全局启用的,但您可以在各个缓冲区中禁用它。请参阅文本面孔
  • Font-Lock mode automatically highlights certain textual units found in programs. It is enabled globally by default, but you can disable it in individual buffers. See Text Faces.
  • 显示行号模式是一个方便的包装 display-line-numbers,使用 的值进行设置 display-line-numbers-type。请参阅显示的自定义
  • Display Line Numbers mode is a convenience wrapper around display-line-numbers, setting it using the value of display-line-numbers-type. See Customization of Display.
  • 大纲次要模式提供与主要模式类似的功能,称为大纲模式。请参阅轮廓模式
  • Outline minor mode provides similar facilities to the major mode called Outline mode. See Outline Mode.
  • 覆盖模式会导致普通打印字符替换现有文本,而不是将其推到右侧。例如,如果点位于 ' 前面' 在 '福巴',然后在覆盖模式下输入 aG将其更改为 '福格',而不是生产 '福巴' 照常。在覆盖模式下,该命令C-q 将插入下一个字符,无论它是什么,即使它是数字,这为您提供了一种插入字符而不是替换现有字符的方法。模式命令 overwrite-mode与按键绑定Insert
  • Overwrite mode causes ordinary printing characters to replace existing text instead of shoving it to the right. For example, if point is in front of the ‘B’ in ‘FOOBAR’, then in Overwrite mode typing a G changes it to ‘FOOGAR’, instead of producing ‘FOOGBAR’ as usual. In Overwrite mode, the command C-q inserts the next character whatever it may be, even if it is a digit—this gives you a way to insert a character instead of replacing an existing character. The mode command, overwrite-mode, is bound to the Insert key.
  • 二进制覆盖模式是覆盖模式的变体,用于编辑二进制文件;它像对待其他字符一样对待换行符和制表符,以便它们覆盖其他字符并且可以被它们覆盖。在二进制覆盖模式下,后面的数字C-q照常指定八进制字符代码。
  • Binary Overwrite mode is a variant of Overwrite mode for editing binary files; it treats newlines and tabs like other characters, so that they overwrite other characters and can be overwritten by them. In Binary Overwrite mode, digits after C-q specify an octal character code, as usual.
  • Visual Line 模式执行自动换行,导致长行在单词边界处自动换行。请参见视线模式
  • Visual Line mode performs word wrapping, causing long lines to be wrapped at word boundaries. See Visual Line Mode.

这里有一些有用的全局次要模式:

And here are some useful global minor modes:

  • 列号模式允许在模式行中显示当前列号。请参阅模式行
  • Column Number mode enables display of the current column number in the mode line. See The Mode Line.
  • 如果该区域处于活动状态,“删除选择”模式会导致文本插入首先删除该区域中的文本。请参阅在区域上操作
  • Delete Selection mode causes text insertion to first delete the text in the region, if the region is active. See Operating on the Region.
  • 当您位于迷你缓冲区中并且完成处于活动状态时,Icomplete 模式会显示可用完成的指示。请参阅快速迷你缓冲区选择
  • Icomplete mode displays an indication of available completions when you are in the minibuffer and completion is active. See Fast minibuffer selection.
  • 行号模式可以在模式行中显示当前行号。默认情况下它是启用的。请参阅模式行
  • Line Number mode enables display of the current line number in the mode line. It is enabled by default. See The Mode Line.
  • 菜单栏模式为每个框架提供一个菜单栏。默认情况下它是启用的。请参阅菜单栏
  • Menu Bar mode gives each frame a menu bar. It is enabled by default. See Menu Bars.
  • 滚动条模式为每个窗口提供一个滚动条。默认情况下启用,但滚动条仅显示在图形终端上。请参阅滚动条
  • Scroll Bar mode gives each window a scroll bar. It is enabled by default, but the scroll bar is only displayed on graphical terminals. See Scroll Bars.
  • 工具栏模式为每个框架提供一个工具栏。默认情况下启用,但工具栏仅显示在图形终端上。请参阅工具栏
  • Tool Bar mode gives each frame a tool bar. It is enabled by default, but the tool bar is only displayed on graphical terminals. See Tool Bars.
  • 标签栏模式为每个框架提供一个标签栏。请参阅选项卡栏
  • Tab Bar mode gives each frame a tab bar. See Tab Bars.
  • 制表符行模式为每个窗口提供一个制表符行。请参见窗口选项卡行
  • Tab Line mode gives each window a tab line. See Window Tab Line.
  • 瞬态标记模式会突出显示该区域,并在标记处于活动状态时使许多 Emacs 命令在该区域上运行。默认情况下它是启用的。请参阅“标记”和“区域”
  • Transient Mark mode highlights the region, and makes many Emacs commands operate on the region when the mark is active. It is enabled by default. See The Mark and the Region.

24.3 选择文件模式

24.3 Choosing File Modes

当您访问文件时,Emacs 会自动选择主要模式。通常,它根据文件名进行选择,例如名称以 ' 结尾的文件。C' 通常在 C 模式下编辑,但有时它会根据文件中的特殊文本选择主要模式。此特殊文本还可用于启用缓冲区本地次要模式。

When you visit a file, Emacs chooses a major mode automatically. Normally, it makes the choice based on the file name—for example, files whose names end in ‘.c’ are normally edited in C mode—but sometimes it chooses the major mode based on special text in the file. This special text can also be used to enable buffer-local minor modes.

下面是具体的过程:

Here is the exact procedure:

首先,Emacs 检查文件是否包含文件本地模式变量。请参阅文件中的局部变量。如果存在指定主要模式的文件本地变量,则 Emacs 将使用该主要模式,忽略所有其他条件。有多种方法可以使用文件局部变量指定主要模式;最简单的方法是将模式名称放在第一个非空行中,前后加上 '-*-'。其他文本也可能出现在该行上。例如,

First, Emacs checks whether the file contains file-local mode variables. See Local Variables in Files. If there is a file-local variable that specifies a major mode, then Emacs uses that major mode, ignoring all other criteria. There are several methods to specify a major mode using a file-local variable; the simplest is to put the mode name in the first nonblank line, preceded and followed by ‘-*-’. Other text may appear on the line as well. For example,

; -*-Lisp-*-
; -*-Lisp-*-

告诉 Emacs 使用 Lisp 模式。请注意如何使用分号让 Lisp 将此行视为注释。你可以等效地写

tells Emacs to use Lisp mode. Note how the semicolon is used to make Lisp treat this line as a comment. You could equivalently write

; -*- 模式:Lisp;-*-
; -*- mode: Lisp;-*-

eval您还可以通过使用规范,使用文件局部变量来指定缓冲区局部次要模式。例如,第一个非空行将缓冲区置于 Lisp 模式并启用自动填充模式:

You can also use file-local variables to specify buffer-local minor modes, by using eval specifications. For example, this first nonblank line puts the buffer in Lisp mode and enables Auto-Fill mode:

; -*- 模式:Lisp; eval: (自动填充模式 1); -*-
; -*- mode: Lisp; eval: (auto-fill-mode 1); -*-

但请注意,以这种方式启用次要模式通常是不合适的,因为大多数次要模式代表个人用户偏好。如果您个人想要对特定文件类型使用次要模式,最好通过主要模式挂钩启用次要模式(请参阅主要模式)。

Note, however, that it is usually inappropriate to enable minor modes this way, since most minor modes represent individual user preferences. If you personally want to use a minor mode for a particular file type, it is better to enable the minor mode via a major mode hook (see Major Modes).

其次,Emacs 检查文件的扩展名是否与任何本地目录中的条目匹配auto-mode-alist。这些是使用.dir-locals.el设施(请参阅每目录局部变量)。

Second, Emacs checks whether the file’s extension matches an entry in any directory-local auto-mode-alist. These are found using the .dir-locals.el facility (see Per-Directory Local Variables).

第三,如果没有指定主模式的文件变量,Emacs 将检查文件的内容是否以 ' 开头#!'。如果是这样,则表明该文件可以用作可执行 shell 命令,该命令通过运行文件第一行上指定的解释器来工作(文件的其余部分用作解释器的输入)。因此,Emacs 尝试使用解释器名称来选择模式。例如,以 ' 开头的文件#!/usr/bin/perl' 在 Perl 模式下打开。该变量interpreter-mode-alist指定解释程序名称和主要模式之间的对应关系。

Third, if there is no file variable specifying a major mode, Emacs checks whether the file’s contents begin with ‘#!’. If so, that indicates that the file can serve as an executable shell command, which works by running an interpreter named on the file’s first line (the rest of the file is used as input to the interpreter). Therefore, Emacs tries to use the interpreter name to choose a mode. For instance, a file that begins with ‘#!/usr/bin/perl’ is opened in Perl mode. The variable interpreter-mode-alist specifies the correspondence between interpreter program names and major modes.

当第一行以 ' 开头时#!',您通常不能使用 '-*-' 在第一行,因为系统在运行解释器时会感到困惑。所以 Emacs 寻找 '-*-' 在此类文件的第二行以及第一行。对于以魔术字符串 ' 开头的手册页也是如此'\"' 指定 troff 预处理器列表。

When the first line starts with ‘#!’, you usually cannot use the ‘-*-’ feature on the first line, because the system would get confused when running the interpreter. So Emacs looks for ‘-*-’ on the second line in such files as well as on the first line. The same is true for man pages which start with the magic string ‘'\"’ to specify a list of troff preprocessors.

第四,Emacs 尝试根据变量 来查看缓冲区开头的文本来确定主要模式 magic-mode-alist。默认情况下,这个变量是nil(一个空列表),所以Emacs会跳过这一步;但是,您可以在 init 文件中对其进行自定义(请参阅Emacs 初始化文件)。该值应该是表单元素的列表

Fourth, Emacs tries to determine the major mode by looking at the text at the start of the buffer, based on the variable magic-mode-alist. By default, this variable is nil (an empty list), so Emacs skips this step; however, you can customize it in your init file (see The Emacs Initialization File). The value should be a list of elements of the form

(正则表达式.模式函数)
(regexp . mode-function)

其中regexp是正则表达式(请参阅正则表达式语法), mode-function是主要模式命令。如果文件开头的文本与regexp匹配,Emacs 将选择mode-function指定的主要模式。

where regexp is a regular expression (see Syntax of Regular Expressions), and mode-function is a major mode command. If the text at the beginning of the file matches regexp, Emacs chooses the major mode specified by mode-function.

或者, 的元素magic-mode-alist可以具有以下形式

Alternatively, an element of magic-mode-alist may have the form

(匹配函数.模式函数)
(match-function . mode-function)

其中match-function是在缓冲区开头调用的 Lisp 函数;如果函数返回 non- ,Emacs 使用mode-functionnil设置主模式。

where match-function is a Lisp function that is called at the beginning of the buffer; if the function returns non-nil, Emacs set the major mode with mode-function.

第五,如果 Emacs 仍然没有找到合适的主模式,它会查看文件的名称。文件名和主要模式之间的对应关系由变量 控制auto-mode-alist。它的值是一个列表,其中每个元素都具有以下形式,

Fifth—if Emacs still hasn’t found a suitable major mode—it looks at the file’s name. The correspondence between file names and major modes is controlled by the variable auto-mode-alist. Its value is a list in which each element has this form,

(正则表达式.模式函数)
(regexp . mode-function)

或这种形式,

or this form,

正则表达式 模式函数 标志
(regexp mode-function flag)

例如,通常在列表中找到的一个元素的形式为 ,它负责为名称结尾为 C 的文件选择 C ​​模式("\\.c\\'" . c-mode)。C。 (注意 '\\' 在 Lisp 语法中需要包含 '\' 在字符串中,必须使用它来抑制 ' 的特殊含义' 在正则表达式中。)

For example, one element normally found in the list has the form ("\\.c\\'" . c-mode), and it is responsible for selecting C mode for files whose names end in .c. (Note that ‘\\’ is needed in Lisp syntax to include a ‘\’ in the string, which must be used to suppress the special meaning of ‘.’ in regexps.)

如果元素的形式non- ,则在调用 mode-function(如果为 non- )后,Emacs 会丢弃与regexp匹配的后缀,并再次在列表中搜索另一个匹配项。这种“递归扩展名剥离”用于具有多个扩展名的文件,“外部”扩展名隐藏了实际指定正确模式的“内部”扩展名。例如,备份文件和 GPG 加密文件(regexp mode-function flag)nilnil.gpg 扩展使用此功能。

If the element has the form (regexp mode-function flag) and flag is non-nil, then after calling mode-function (if it is non-nil), Emacs discards the suffix that matched regexp and searches the list again for another match. This “recursive extension stripping” is used for files which have multiple extensions, and the “outer” extension hides the “inner” one that actually specifies the right mode. For example, backup files and GPG-encrypted files with .gpg extension use this feature.

在 GNU/Linux 和其他区分大小写文件名的系统上,Emacs 通过auto-mode-alist;执行区分大小写的搜索。如果此搜索失败,它将通过列表执行第二次不区分大小写的搜索。要禁止第二次搜索,请将变量更改 auto-mode-case-foldnil。在文件名不区分大小写的系统(例如 Microsoft Windows)上,Emacs 通过auto-mode-alist.

On GNU/Linux and other systems with case-sensitive file names, Emacs performs a case-sensitive search through auto-mode-alist; if this search fails, it performs a second case-insensitive search through the alist. To suppress the second search, change the variable auto-mode-case-fold to nil. On systems with case-insensitive file names, such as Microsoft Windows, Emacs performs a single case-insensitive search through auto-mode-alist.

最后,如果 Emacs仍然没有找到要使用的主要模式,它会将缓冲区开头的文本与变量进行比较 magic-fallback-mode-alist。该变量的工作方式与 magic-mode-alist上面描述的类似,只不过它仅在 后才 auto-mode-alist被查询。默认情况下, magic-fallback-mode-alist包含检查图像文件、HTML/XML/SGML 文件、PostScript 文件和 Unix 样式 Conf 文件的表单。

Finally, if Emacs still hasn’t found a major mode to use, it compares the text at the start of the buffer to the variable magic-fallback-mode-alist. This variable works like magic-mode-alist, described above, except that it is consulted only after auto-mode-alist. By default, magic-fallback-mode-alist contains forms that check for image files, HTML/XML/SGML files, PostScript files, and Unix style Conf files.

一旦找到主要模式,Emacs 就会进行最终检查以查看该模式是否已被 重新映射major-mode-remap-alist,在这种情况下,它会使用重新映射的模式。当同一文件类型可以使用多种不同的主要模式时,可以使用此选项,这样您就可以指定您喜欢的模式。

Once a major mode is found, Emacs does a final check to see if the mode has been remapped by major-mode-remap-alist, in which case it uses the remapped mode instead. This is used when several different major modes can be used for the same file type, so you can specify which mode you prefer.

如果您更改了缓冲区的主要模式,则可以通过输入返回到 Emacs 自动选择的主要模式 M-x normal-mode。这与find-file调用选择主要模式的函数相同 。如果缓冲区正在访问文件,则此命令还会处理文件的 '-*-' 行和文件局部变量列表(如果有)。请参阅文件中的局部变量。如果缓冲区不访问文件,则该命令仅处理 ' 中的主要模式规范(如果有)-*-' 行和文件局部变量列表中。

If you have changed the major mode of a buffer, you can return to the major mode Emacs would have chosen automatically, by typing M-x normal-mode. This is the same function that find-file calls to choose the major mode. If the buffer is visiting a file, this command also processes the file’s ‘-*-’ line and file-local variables list (if any). See Local Variables in Files. If the buffer doesn’t visit a file, the command processes only the major mode specification, if any, in the ‘-*-’ line and in the file-local variables list.

如果新文件名暗示某种模式,则命令C-x C-w将更set-visited-file-name改为新的主要模式(请参阅保存文件)。 (C-x C-s如果缓冲区没有访问文件,也会执行此操作。)但是,如果缓冲区内容指定主要模式,并且某些特殊主要模式不允许更改模式,则不会发生这种情况。您可以通过设置change-major-mode-with-file-name为 来关闭此模式更改功能 nil

The commands C-x C-w and set-visited-file-name change to a new major mode if the new file name implies a mode (see Saving Files). (C-x C-s does this too, if the buffer wasn’t visiting a file.) However, this does not happen if the buffer contents specify a major mode, and certain special major modes do not allow the mode to change. You can turn off this mode-changing feature by setting change-major-mode-with-file-name to nil.


25 缩进

25 Indentation

缩进是指在一行文本的开头插入或调整空白字符(空格和/或制表符)。本章介绍文本模式和相关模式以及编程语言模式常见的缩进命令和选项。有关编程模式中缩进的其他文档, 请参阅程序缩进。

Indentation refers to inserting or adjusting whitespace characters (space and/or tab characters) at the beginning of a line of text. This chapter documents indentation commands and options which are common to Text mode and related modes, as well as programming language modes. See Indentation for Programs, for additional documentation about indenting in programming modes.

最简单的缩进方法是TAB关键。在大多数主要模式下,这会运行命令indent-for-tab-command。 (在 C 和相关模式下,TAB运行命令 c-indent-line-or-region,其行为类似,请参阅C 缩进命令)。

The simplest way to perform indentation is the TAB key. In most major modes, this runs the command indent-for-tab-command. (In C and related modes, TAB runs the command c-indent-line-or-region, which behaves similarly, see Commands for C Indentation).

TAB
TAB

以适合模式的方式插入空格或缩进当前行 ( indent-for-tab-command)。如果该区域处于活动状态,则缩进其中的所有行。

Insert whitespace, or indent the current line, in a mode-appropriate way (indent-for-tab-command). If the region is active, indent all the lines within it.

的确切行为TAB取决于主要模式。在文本模式和相关主要模式中,TAB通常会插入空格和制表符的某种组合以前进到下一个制表位(请参阅制表位)。为此,前一行上第一个非空白字符的位置被视为附加制表位,因此您可以使用TAB将点与前一行对齐。如果该区域处于活动状态(请参阅在区域上操作), TAB则执行特殊操作:它缩进区域中的每一行,以便其第一个非空白字符与前一行对齐。

The exact behavior of TAB depends on the major mode. In Text mode and related major modes, TAB normally inserts some combination of space and tab characters to advance point to the next tab stop (see Tab Stops). For this purpose, the position of the first non-whitespace character on the preceding line is treated as an additional tab stop, so you can use TAB to align point with the preceding line. If the region is active (see Operating on the Region), TAB acts specially: it indents each line in the region so that its first non-whitespace character is aligned with the preceding line.

在编程模式中,TAB在给定前几行代码的情况下,以有意义的方式缩进当前代码行。如果该区域处于活动状态,则该区域中的所有行都将以这种方式缩进。如果 point 最初位于当前行的缩进内,则会将其重新定位到该行的第一个非空白字符。

In programming modes, TAB indents the current line of code in a way that makes sense given the code in the preceding lines. If the region is active, all the lines in the region are indented this way. If point was initially within the current line’s indentation, it is repositioned to the first non-whitespace character on the line.

如果您只想在缓冲区中插入制表符,请键入 (请参阅插入文本)。 C-q TAB

If you just want to insert a tab character in the buffer, type C-q TAB (see Inserting Text).


25.1 缩进命令

25.1 Indentation Commands

除了TAB( indent-for-tab-command) 命令之外,Emacs 还提供了多种命令以其他方式执行缩进。

Apart from the TAB (indent-for-tab-command) command, Emacs provides a variety of commands to perform indentation in other ways.

C-M-o
C-M-o

在点 ( ) 处分割当前行split-line。 point 之后的行上的文本成为新行,缩进到 point 所在的同一列。该命令首先将点向前移动到任何空格和制表符上。之后,point 被定位在插入的换行符之前。

Split the current line at point (split-line). The text on the line after point becomes a new line, indented to the same column where point is located. This command first moves point forward over any spaces and tabs. Afterward, point is positioned before the inserted newline.

M-m
M-m

移动(向前或向后)到当前行上的第一个非空白字符 ( back-to-indentation)。如果该行中没有非空白字符,则移至该行末尾。

Move (forward or back) to the first non-whitespace character on the current line (back-to-indentation). If there are no non-whitespace characters on the line, move to the end of the line.

M-i
M-i

在点处缩进空格,直到下一个制表位 ( tab-to-tab-stop)。请参阅制表位

Indent whitespace at point, up to the next tab stop (tab-to-tab-stop). See Tab Stops.

M-x indent-relative
M-x indent-relative

在 point 处插入空格,直到 point 与上一行的第一个非空格字符(实际上是最后一个非空行)对齐。如果 point 已经比该值更右, tab-to-tab-stop则改为运行 - 除非使用数字参数调用,在这种情况下不执行任何操作。

Insert whitespace at point, until point is aligned with the first non-whitespace character on the previous line (actually, the last non-blank line). If point is already farther right than that, run tab-to-tab-stop instead—unless called with a numeric argument, in which case do nothing.

M-^
M-^

合并前一行和当前行 ( delete-indentation)。通过用一个空格替换当前行前面的任何缩进以及行边界,可以干净地连接两行。

作为一种特殊情况(对 Lisp 代码有用),如果要连接的字符是连续的左括号和右括号,或者连接点后面有另一个换行符,则省略单个空格。

如果存在填充前缀,M-^则删除出现在删除的换行符之后的填充前缀。请参阅填充前缀

使用前缀参数,将当前行连接到下一行。如果该区域处于活动状态,并且没有给出前缀参数,则连接该区域中的所有行。

Merge the previous and the current line (delete-indentation). This joins the two lines cleanly, by replacing any indentation at the front of the current line, together with the line boundary, with a single space.

As a special case (useful for Lisp code), the single space is omitted if the characters to be joined are consecutive opening and closing parentheses, or if the junction follows another newline.

If there is a fill prefix, M-^ deletes the fill prefix if it appears after the newline that is deleted. See The Fill Prefix.

With a prefix argument, join the current line to the following line. If the region is active, and no prefix argument is given, join all lines in the region instead.

C-M-\
C-M-\

缩进该区域中的所有行,就像您 TAB在每行的开头键入 ( indent-region) 一样。

如果提供了数字参数,则将该区域中的每一行缩进到该列号。

Indent all the lines in the region, as though you had typed TAB at the beginning of each line (indent-region).

If a numeric argument is supplied, indent every line in the region to that column number.

C-x TAB
C-x TAB

缩进从该区域开始的所有行,将受影响的行作为刚性单位移动 ( indent-rigidly)。

如果不带参数调用,此命令将激活瞬态模式,以交互方式调整受影响行的缩进。当此瞬态模式处于活动状态时,请分别向左和向右键入LEFT或 缩进一个空格。RIGHT您还可以键入或向左或向右缩进到下一个制表位(请参阅制表位)。键入任何其他键都会禁用瞬态模式,然后按正常键操作该键。 S-LEFTS-RIGHT

如果使用前缀参数n调用,则此命令会将行向前缩进n 个空格(不启用瞬态模式)。n的负值向后缩进,因此您可以使用大的负参数从该区域中的行中删除所有缩进,如下所示:

铜-999CXTAB

Indent all lines that begin in the region, moving the affected lines as a rigid unit (indent-rigidly).

If called with no argument, this command activates a transient mode for adjusting the indentation of the affected lines interactively. While this transient mode is active, typing LEFT or RIGHT indents leftward and rightward, respectively, by one space. You can also type S-LEFT or S-RIGHT to indent leftward or rightward to the next tab stop (see Tab Stops). Typing any other key disables the transient mode, and this key is then acted upon as normally.

If called with a prefix argument n, this command indents the lines forward by n spaces (without enabling the transient mode). Negative values of n indent backward, so you can remove all indentation from the lines in the region using a large negative argument, like this:

C-u -999 C-x TAB

25.2 制表位

25.2 Tab Stops

Emacs 将某些列号定义为制表位TAB在文本模式和相关模式下插入空格时(请参阅缩进)以及类似命令M-i(请参阅缩进命令),这些将用作停止点。该变量 tab-stop-list控制这些位置。默认值为 nil,表示每 8 列一个制表位。该值还可以是从零开始的列号列表(按升序排列),用于放置制表位。 Emacs 通过重复最后一个元素和倒数第二个元素之间的差异来永远扩展列表。

Emacs defines certain column numbers to be tab stops. These are used as stopping points by TAB when inserting whitespace in Text mode and related modes (see Indentation), and by commands like M-i (see Indentation Commands). The variable tab-stop-list controls these positions. The default value is nil, which means a tab stop every 8 columns. The value can also be a list of zero-based column numbers (in increasing order) at which to place tab stops. Emacs extends the list forever by repeating the difference between the last and next-to-last elements.

tab-stop-list查看和设置制表位的便捷方法是通过命令 ,而不是直接自定义变量M-x edit-tab-stops。这会切换到包含制表位设置描述的缓冲区,如下所示:

Instead of customizing the variable tab-stop-list directly, a convenient way to view and set tab stops is via the command M-x edit-tab-stops. This switches to a buffer containing a description of the tab stop settings, which looks like this:

        :::::::
0 1 2 3 4
0123456789012345678901234567890123456789012345678
要安装更改,请键入 Cc Cc
        :       :       :       :       :       :
0         1         2         3         4
0123456789012345678901234567890123456789012345678
To install changes, type C-c C-c

第一行在每个制表位处包含一个冒号。接下来两行的数字只是为了指示冒号的位置。如果tab-stop-list的值为nil,默认情况下,最初不显示冒号。

The first line contains a colon at each tab stop. The numbers on the next two lines are present just to indicate where the colons are. If the value of tab-stop-list is nil, as it is by default, no colons are displayed initially.

您可以编辑此缓冲区,通过在所需列上放置冒号来指定不同的制表位。缓冲区使用覆盖模式(请参阅次要模式)。请记住,Emacs 将通过重复您放置的最后两个显式停止位之间的差异来永远扩展制表位列表。完成后,键入C-c C-c以使新制表位生效。通常,新的制表位设置适用于所有缓冲区。但是,如果您已将 tab-stop-list变量设置为调用的缓冲区的本地变量 M-x edit-tab-stops(请参阅本地变量),则新的制表位设置仅适用于该缓冲区。要为将来的 Emacs 会话保存制表位设置,请使用自定义界面保存 的值tab-stop-list(请参阅轻松自定义界面)。

You can edit this buffer to specify different tab stops by placing colons on the desired columns. The buffer uses Overwrite mode (see Minor Modes). Remember that Emacs will extend the list of tab stops forever by repeating the difference between the last two explicit stops that you place. When you are done, type C-c C-c to make the new tab stops take effect. Normally, the new tab stop settings apply to all buffers. However, if you have made the tab-stop-list variable local to the buffer where you called M-x edit-tab-stops (see Local Variables), then the new tab stop settings apply only to that buffer. To save the tab stop settings for future Emacs sessions, use the Customize interface to save the value of tab-stop-list (see Easy Customization Interface).

请注意,本节中讨论的制表位与制表符在缓冲区中的显示方式无关。制表符始终显示为延伸到下一个显示制表位的空格 。请参阅如何显示文本

Note that the tab stops discussed in this section have nothing to do with how tab characters are displayed in the buffer. Tab characters are always displayed as empty spaces extending to the next display tab stop. See How Text Is Displayed.


25.3 制表符与空格

25.3 Tabs vs. Spaces

通常,缩进命令插入(或删除)尽可能短的制表符和空格字符序列,以便与所需的列对齐。制表符显示为延伸至下一个显示制表位的一段空白区域。默认情况下,每列有一个显示制表位tab-width(默认值为 8)。请参阅如何显示文本

Normally, indentation commands insert (or remove) the shortest possible series of tab and space characters so as to align to the desired column. Tab characters are displayed as a stretch of empty space extending to the next display tab stop. By default, there is one display tab stop every tab-width columns (the default is 8). See How Text Is Displayed.

如果您愿意,所有缩进都可以仅由空格组成。要请求此操作,请将缓冲区局部变量设置indent-tabs-modenil。有关设置缓冲区局部变量的信息,请参阅局部变量。但请注意,无论 的值如何,始终会插入制表符。 C-q TABindent-tabs-mode

If you prefer, all indentation can be made from spaces only. To request this, set the buffer-local variable indent-tabs-mode to nil. See Local Variables, for information about setting buffer-local variables. Note, however, that C-q TAB always inserts a tab character, regardless of the value of indent-tabs-mode.

indent-tabs-mode设置为的原因之一nil是并非所有编辑器都以相同的方式显示制表符。 Emacs 用户也可能有不同的自定义值tab-width。通过仅使用空格,您可以确保您的文件始终看起来相同。如果您只关心它在 Emacs 中的外观,解决此问题的另一种方法是tab-width在文件局部变量中设置该变量(请参阅文件中的局部变量)。

One reason to set indent-tabs-mode to nil is that not all editors display tab characters in the same way. Emacs users, too, may have different customized values of tab-width. By using spaces only, you can make sure that your file always looks the same. If you only care about how it looks within Emacs, another way to tackle this problem is to set the tab-width variable in a file-local variable (see Local Variables in Files).

还有一些命令可以将制表符转换为空格,反之亦然,始终保留所有非空白文本的列。 M-x tabify扫描该区域中的空格序列,并将至少两个空格的序列转换为制表符(如果可以在不更改缩进的情况下完成)。 M-x untabify将区域中的所有选项卡更改为适当数量的空格。

There are also commands to convert tabs to spaces or vice versa, always preserving the columns of all non-whitespace text. M-x tabify scans the region for sequences of spaces, and converts sequences of at least two spaces to tabs if that can be done without changing indentation. M-x untabify changes all tabs in the region to appropriate numbers of spaces.


25.4 缩进的便利功能

25.4 Convenience Features for Indentation

该变量调整( ) 命令tab-always-indent的行为 。默认值 给出了缩进中描述的行为。如果将值更改为符号,则首先尝试缩进当前行,如果该行已经缩进,它将尝试完成点处的文本(请参阅符号名称的完成)。如果值为,则仅当点位于左边距或行缩进中时才缩进当前行;否则,它会插入一个制表符。 TABindent-for-tab-commandtcompleteTABnilTAB

The variable tab-always-indent tweaks the behavior of the TAB (indent-for-tab-command) command. The default value, t, gives the behavior described in Indentation. If you change the value to the symbol complete, then TAB first tries to indent the current line, and if the line was already indented, it tries to complete the text at point (see Completion for Symbol Names). If the value is nil, then TAB indents the current line only if point is at the left margin or in the line’s indentation; otherwise, it inserts a tab character.

如果tab-always-indentcomplete,则可以通过变量进一步定制是否扩展或缩进tab-first-completion 。例如,如果该变量是eol,则仅当点位于行尾时才完成。有关更多详细信息, 请参阅Emacs Lisp 参考手册中的模式特定缩进。

If tab-always-indent is complete, whether to expand or indent can be further customized via the tab-first-completion variable. For instance, if that variable is eol, only complete if point is at the end of a line. See Mode-Specific Indent in The Emacs Lisp Reference Manual, for further details.

电动缩进模式是一种全局次要模式,可在您每次键入后自动缩进行RET。该模式默认启用。要切换此次要模式,请键入M-x electric-indent-mode。要在单个缓冲区中切换模式,请使用M-x electric-indent-local-mode

Electric Indent mode is a global minor mode that automatically indents the line after every RET you type. This mode is enabled by default. To toggle this minor mode, type M-x electric-indent-mode. To toggle the mode in a single buffer, use M-x electric-indent-local-mode.


25.5 代码对齐

25.5 Code Alignment

对齐是调整区域中一系列行中的空白的过程,以便在所有行中某些部分从同一列开始。这通常是为了增强一段文本或代码的可读性而执行的操作。典型的例子是使用类似 C 的编程语言来对齐一系列作业:

Alignment is the process of adjusting whitespace in a sequence of lines in the region such that in all lines certain parts begin at the same column. This is usually something you do to enhance readability of a piece of text or code. The classic example is aligning a series of assignments in C-like programming languages:

整数a=1;
短 foo = 2;
双废话 = 4;
int a = 1;
short foo = 2;
double blah = 4;

通常对齐到:

is commonly aligned to:

整数a=1;
短 foo = 2;
双废话 = 4;
int    a    = 1;
short  foo  = 2;
double blah = 4;

您可以使用该命令M-x align来对齐当前区域中的线条。该命令了解许多标记和编程语言的常见对齐模式。它将这些模式编码为一组对齐规则,说明如何在不同的上下文中对齐不同类型的文本。

You can use the command M-x align to align lines in the current region. This command knows about common alignment patterns across many markup and programming languages. It encodes these patterns as a set of alignment rules, that say how to align different kinds of text in different contexts.

用户选项说明应参考align-rules-list哪些对齐规则 。M-x align该选项的值是一个包含描述对齐规则的元素的列表。每个元素都是一个 cons cell ,其中title是作为符号的对齐规则的名称,attribute是规则属性列表,用于定义何时应用规则以及如何分区和对齐行。每个规则属性都是一个 cons cell ,其中attribute是属性的名称,value是其值。唯一必需的属性是,其值是一个正则表达式,其子表达式与每行 中应扩展或收缩空格的部分相匹配(请参阅正则表达式中的反斜杠)。有关可能的对齐规则属性的完整描述,请参阅( )的文档字符串。默认情况下,此选项设置为 Emacs 支持的多种语言的一长串对齐规则。默认规则使用规则属性来指定应用它们的主要模式。主要模式也可以通过将缓冲区局部变量设置为非对齐规则列表来覆盖。当为非时, 参考它而不是。 (title . attributes)(attribute . value)regexpM-x alignalign-rules-listC-h v align-rules-list RETmodesM-x alignalign-rules-listalign-mode-rules-listnilalign-mode-rules-listnilM-x alignalign-rules-list

The user option align-rules-list says which alignment rules M-x align should consult. The value of this option is a list with elements describing alignment rules. Each element is a cons cell (title . attributes), where title is the name of the alignment rule as a symbol, and attributes is a list of rule attributes that define when the rule should apply and how it partitions and aligns lines. Each rule attribute is a cons cell (attribute . value), where attribute is the name of attribute and value is its value. The only required attribute is regexp, whose value is a regular expression with sub-expressions matching the parts of each line where M-x align should expand or contract whitespace (see Backslash in Regular Expressions). See the documentation string of align-rules-list (C-h v align-rules-list RET) for a full description of possible alignment rule attributes. By default, this option is set to a long list of alignment rules for many languages that Emacs supports. The default rules use the modes rule attribute to specify major modes in which M-x align should apply them. Major modes can also override align-rules-list by setting the buffer-local variable align-mode-rules-list to a non-nil list of alignment rules. When align-mode-rules-list is non-nil, M-x align consults it instead of align-rules-list.

除了对齐规则之外,M-x align还使用另一种规则,称为排除规则。排除规则规定该地区的哪些部分M-x align不应对齐,而是保持原样。用户选项align-exclude-rules-list指定这些排除规则。与 类似align-rules-list, 的值align-exclude-rules-list也是描述排除规则的 cons 单元格列表。默认情况下, align-exclude-rules-list包括排除 Lisp、C 和其他语言中带引号的字符串和注释中的对齐的规则。除了 中的默认排除规则之外align-exclude-rules-list,主要模式还可以通过设置 align-mode-exclude-rules-list为非nil规则列表来定义定制排除规则,这align-exclude-rules-list就像 align-mode-rules-list覆盖一样覆盖align-rules-list

Besides alignment rules, M-x align uses another kind of rules called exclusion rules. The exclusion rules say which parts in the region M-x align should not align and instead leave them intact. The user option align-exclude-rules-list specifies these exclusion rules. Similarly to align-rules-list, the value of align-exclude-rules-list is also a list of cons cells that describe the exclusion rules. By default, align-exclude-rules-list includes rules that exclude alignment in quoted strings and comments in Lisp, C and other languages. Beyond the default exclusion rules in align-exclude-rules-list, major modes can define bespoke exclusion rules by setting align-mode-exclude-rules-list to a non-nil list of rules, this overrides align-exclude-rules-list just like align-mode-rules-list overrides align-rules-list.

M-x align将区域分割成一系列的部分,通常是非空白行的序列,并根据所有匹配的对齐规则通过扩展或收缩空白区域来对齐每个部分。 M-x align一致地对齐单个部分内的所有线,但它可能以不同的方式对齐该区域中的不同部分。用户选项align-region-separate 指定如何M-x align将区域划分为部分。此选项可以是符号entiregroup或正则表达式之一。如果align-region-separateentire,Emacs 将整个区域作为一个部分对齐。如果此选项为 group,Emacs 会将区域中的每组连续非空白行作为单独的部分进行对齐。如果align-region-separate 是正则表达式,M-x align则扫描该区域以查找与该正则表达式的匹配项,并将它们视为节分隔符。默认情况下align-region-separate设置为匹配空白行和仅包含空格和单个大括号 ('{' 或者 '}')。对于正则表达式不够准确的特殊情况,您还可以设置 align-region-separate一个函数来说明如何将区域分隔到对齐部分。align-region-separate有关更多详细信息,请参阅 的文档字符串 。特定的对齐规则可以通过指定规则属性来覆盖 的值align-region-separate并定义自己的节分隔符separate

M-x align splits the region into a series of sections, usually sequences of non-blank lines, and aligns each section according to all matching alignment rule by expanding or contracting stretches of whitespace. M-x align consistently aligns all lines inside a single section, but it may align different sections in the region differently. The user option align-region-separate specifies how M-x align separates the region to sections. This option can be one of the symbols entire, group, or a regular expression. If align-region-separate is entire, Emacs aligns the entire region as a single section. If this option is group, Emacs aligns each group of consecutive non-blank lines in the region as a separate section. If align-region-separate is a regular expression, M-x align scans the region for matches to that regular expression and treats them as section separators. By default align-region-separate is set to a regular expression that matches blank lines and lines that contains only whitespace and a single curly brace (‘{’ or ‘}’). For special cases where regular expressions are not accurate enough, you can also set align-region-separate to a function that says how to separate the region to alignment sections. See the documentation string of align-region-separate for more details. Specific alignment rules can override the value of align-region-separate and define their own section separator by specifying the separate rule attribute.

如果M-x align使用前缀参数 ( C-u) 进行调用,它会启用更多对齐规则,这些规则通常很有用,但有时可能过于干扰。例如,在具有以下形式的 Lisp 缓冲区中:

If you call M-x align with a prefix argument (C-u), it enables more alignment rules that are often useful but may sometimes be too intrusive. For example, in a Lisp buffer with the following form:

(set-face-attribute 'mode-line-inactive nil
                    : 框无
                    :背景无
                    :下划线“黑色”)
(set-face-attribute 'mode-line-inactive nil
                    :box nil
                    :background nil
                    :underline "black")

键入 ( C-u M-x align) 会产生:

Typing (C-u M-x align) yields:

(set-face-attribute 'mode-line-inactive nil
                    : 框无
                    :背景无
                    :下划线“黑色”)
(set-face-attribute 'mode-line-inactive nil
                    :box                nil
                    :background         nil
                    :underline          "black")

在大多数情况下,您应该M-x align首先尝试不使用前缀参数,如果这不能产生正确的结果,您可以使用 撤消C-/并重试C-u M-x align

In most cases, you should try M-x align without a prefix argument first, and if that doesn’t produce the right result you can undo with C-/ and try again with C-u M-x align.

您可以使用该命令M-x align-highlight-rule来可视化当前区域中特定对齐或排除规则的效果。此命令会提示您输入规则的标题,并突出显示该规则影响的区域上的部分。对于对齐规则,此命令突出显示将扩展或收缩的空白,而对于排除,此命令突出显示将从对齐中排除M-x align的部分。M-x align要删除此命令创建的突出显示,请键入 M-x align-unhighlight-rule

You can use the command M-x align-highlight-rule to visualize the effect of a specific alignment or exclusion rule in the current region. This command prompts you for the title of a rule and highlights the parts on the region that this rule affects. For alignment rules, this command highlights the whitespace that M-x align would expand or contract, and for exclusion this command highlights the parts that M-x align would exclude from alignment. To remove the highlighting that this command creates, type M-x align-unhighlight-rule.

该命令M-x align-current与 类似M-x align,只不过它只对包含点的对齐部分进行操作,而与当前区域无关。该命令根据定义的节分隔符确定当前节的边界align-region-separateM-x align-entire是 的另一种变体M-x align,它忽略 align-region-separate整个区域并将其对齐为具有一致对齐的单个对齐部分。如果设置 align-region-separateentireM-x align则行为M-x align-entire与默认情况一样。为了说明将整个区域对齐为单个对齐部分的效果,请考虑以下代码:

The command M-x align-current is similar to M-x align, except that it operates only on the alignment section that contains point regardless of the current region. This command determines the boundaries of the current section according to the section separators that align-region-separate define. M-x align-entire is another variant of M-x align, that disregards align-region-separate and aligns the entire region as a single alignment section with consistent alignment. If you set align-region-separate to entire, M-x align behaves like M-x align-entire by default. To illustrate the effect of aligning the entire region as a single alignment section, consider the following code:

一 = 1;
foob​​arbaz = 2;

垃圾邮件 = 3;
emacs = 4;
one = 1;
foobarbaz = 2;

spam = 3;
emacs = 4;

当该区域覆盖所有这些行时,输入M-x align 结果:

when the region covers all of these lines, typing M-x align yields:

一 = 1;
foob​​arbaz = 2;

垃圾邮件 = 3;
emacs = 4;
one       = 1;
foobarbaz = 2;

spam  = 3;
emacs = 4;

另一方面,M-x align-entire将所有行对齐为一个部分,因此 '=' 出现在所有行的同一列中:

On the other hand, M-x align-entire aligns all of the lines as a single section, so the ‘=’ appears at the same column in all lines:

一 = 1;
foob​​arbaz = 2;

垃圾邮件 = 3;
emacs = 4;
one       = 1;
foobarbaz = 2;

spam      = 3;
emacs     = 4;

该命令M-x align-regexp允许您将当前区域与您临时定义的对齐规则对齐,而不是使用 中的预定义规则align-rules-listM-x align-regexp 提示您输入正则表达式,并使用该表达式作为 regexp该命令用于对齐当前区域的临时对齐规则的属性。默认情况下,此命令调整与您指定的正则表达式的第一个子表达式匹配的空格。如果您M-x align-regexp使用前缀参数进行调用,它还会提示您输入要使用的子表达式,并允许您指定用作填充的空白量,以及是否将规则重复应用于每个中正则表达式的所有匹配项。线。有关正则表达式及其子表达式的更多信息, 请参阅正则表达式中的反斜杠。

The command M-x align-regexp lets you align the current region with an alignment rule that you define ad-hoc, instead of using the predefined rules in align-rules-list. M-x align-regexp prompts you for a regular expression and uses that expression as the regexp attribute for an ad-hoc alignment rule that this command uses to align the current region. By default, this command adjusts the whitespace that matches the first sub-expression of the regular expression you specify. If you call M-x align-regexp with a prefix argument, it also prompts you for the sub-expression to use and lets you specify the amount of whitespace to use as padding, as well as whether to apply the rule repeatedly to all matches of the regular expression in each line. See Backslash in Regular Expressions, for more information about regular expressions and their sub-expressions.

如果用户选项align-indent-before-aligning为非nil,Emacs 会先缩进该区域,然后再将其与 对齐 M-x align。请参阅缩进。默认 align-indent-before-aligning设置为nil

If the user option align-indent-before-aligning is non-nil, Emacs indents the region before aligning it with M-x align. See Indentation. By default align-indent-before-aligning is set to nil.

用户选项align-to-tab-stop表示对齐的部分是否应从制表位开始(请参阅制表位)。如果此选项为 nilM-x align则使用足够的空白进行对齐,忽略制表位。如果这是一个非nil符号,M-x align则检查该符号的值,如果该值不是 - nil,则M-x align与制表位对齐。默认情况下,此选项设置为indent-tabs-mode,因此对齐方式遵循使用制表符缩进的缓冲区中的制表位。请参阅制表符与空格

The user option align-to-tab-stop says whether aligned parts should start at a tab stop (see Tab Stops). If this option is nil, M-x align uses just enough whitespace for alignment, disregarding tab stops. If this is a non-nil symbol, M-x align checks the value of that symbol, and if this value is non-nil, M-x align aligns to tab stops. By default, this option is set to indent-tabs-mode, so alignment respects tab stops in buffers that use tabs for indentation. See Tabs vs. Spaces.

用户选项align-default-spacing指定默认的空白量M-x align及其相关命令在对齐时用于每行不同部分之间的填充。当align-to-tab-stop为时nil, 的值为 align-default-spacing用于填充的空格数;当align-to-tab-stop为 非-时nil, 的值 align-default-spacing是要使用的制表位数量。每个对齐规则可以覆盖属性规则align-default-spacing指定的默认值 spacing

The user option align-default-spacing specifies the default amount of whitespace that M-x align and its related commands use for padding between the different parts of each line when aligning it. When align-to-tab-stop is nil, the value of align-default-spacing is the number of spaces to use for padding; when align-to-tab-stop is non-nil, the value of align-default-spacing is instead the number of tab stops to use. Each alignment rule can override the default that align-default-spacing specifies with the spacing attribute rule.


26条人类语言命令

26 Commands for Human Languages

本章描述作用于文本的 Emacs 命令,文本是指人类语言(而不是计算机编程语言)中的字符序列。这些命令的作用方式考虑了人类语言的句法和文体惯例:涉及单词、句子、段落和大写字母的惯例。还有填充命令,这意味着重新排列段落的行,使其长度大致相等。这些命令虽然主要用于编辑文本,但通常也可用于编辑程序。

This chapter describes Emacs commands that act on text, by which we mean sequences of characters in a human language (as opposed to, say, a computer programming language). These commands act in ways that take into account the syntactic and stylistic conventions of human languages: conventions involving words, sentences, paragraphs, and capital letters. There are also commands for filling, which means rearranging the lines of a paragraph to be approximately equal in length. These commands, while intended primarily for editing text, are also often useful for editing programs.

Emacs 有几种主要的人类语言文本编辑模式。如果文件包含普通文本,请使用文本模式,该模式会根据文本的语法约定以较小的方式自定义 Emacs。大纲模式提供了用于操作具有大纲结构的文本的特殊命令。请参阅轮廓模式

Emacs has several major modes for editing human-language text. If the file contains ordinary text, use Text mode, which customizes Emacs in small ways for the syntactic conventions of text. Outline mode provides special commands for operating on text with an outline structure. See Outline Mode.

Org 模式扩展了 Outline 模式,并将 Emacs 变成了一个成熟的组织者:您可以管理 TODO 列表、存储笔记并以多种格式发布它们。请参阅随 Emacs 一起分发的 Org Info 手册。

Org mode extends Outline mode and turns Emacs into a full-fledged organizer: you can manage TODO lists, store notes and publish them in many formats. See the Org Info manual, which is distributed with Emacs.

Emacs 对于包含嵌入命令的文本还有其他主要模式,例如 TeX 和 LaTeX(请参阅TeX 模式); HTML 和 SGML(请参阅SGML 和 HTML 模式); XML(参见 nXML 模式信息手册,随 Emacs 一起分发);以及 Groff 和 Nroff(参见Nroff 模式)。

Emacs has other major modes for text which contains embedded commands, such as TeX and LaTeX (see TeX Mode); HTML and SGML (see SGML and HTML Modes); XML (see the nXML mode Info manual, which is distributed with Emacs); and Groff and Nroff (see Nroff Mode).

如果您需要编辑由文本字符组成的 ASCII 艺术图片,请使用图片模式,这是编辑此类图片的特殊主要模式。请参阅编辑图片

If you need to edit ASCII art pictures made out of text characters, use Picture mode, a special major mode for editing such pictures. See Editing Pictures.


26.1 单词

26.1 Words

Emacs 定义了几个用于移动或操作单词的命令:

Emacs defines several commands for moving over or operating on words:

M-f
M-f

向前移动一个单词 ( forward-word)。

Move forward over a word (forward-word).

M-b
M-b

向后移动一个单词 ( backward-word)。

Move backward over a word (backward-word).

M-d
M-d

杀掉一个单词的结尾(kill-word)。

Kill up to the end of a word (kill-word).

M-DEL
M-DEL

杀回单词开头 ( backward-kill-word)。

Kill back to the beginning of a word (backward-kill-word).

M-@
M-@

在下一个单词的末尾设置标记 ( mark-word)。

Set mark at the end of the next word (mark-word).

M-t
M-t

调换两个单词或将一个单词拖过其他单词 ( transpose-words)。

Transpose two words or drag a word across others (transpose-words).

请注意这些键​​如何形成与基于字符的 C-fC-bC-d和平行的系列。 与 是同源的,它是 的别名。 DELC-tM-@C-@C-SPC

Notice how these keys form a series that parallels the character-based C-f, C-b, C-d, DEL and C-t. M-@ is cognate to C-@, which is an alias for C-SPC.

命令M-f( forward-word) 和M-b ( backward-word) 在单词上向前和向后移动。这些 Meta基于 的键序列类似于 在单个字符上移动的键序列C-f和。C-b这个类比扩展到了数字参数,它充当重复计数。 M-f带有否定参数的则向后移动,M-b带有否定参数的则向前移动。向前运动在单词的最后一个字母之后停止,而向后运动在第一个字母之前停止。

The commands M-f (forward-word) and M-b (backward-word) move forward and backward over words. These Meta-based key sequences are analogous to the key sequences C-f and C-b, which move over single characters. The analogy extends to numeric arguments, which serve as repeat counts. M-f with a negative argument moves backward, and M-b with a negative argument moves forward. Forward motion stops right after the last letter of the word, while backward motion stops right before the first letter.

M-d( kill-word) 删除点后的单词。准确地说,它M-f会杀死从点到移动地点的所有东西。因此,如果点位于单词的中间,M-d则仅删除点之后的部分。如果点和下一个单词之间出现一些标点符号,则它会与该单词一起被删除。 (如果您只想删除下一个单词而不是前面的标点符号,只需执行 M-f即可获得结尾,然后使用 向后删除该单词 。) 就像 一样接受参数。 M-DELM-dM-f

M-d (kill-word) kills the word after point. To be precise, it kills everything from point to the place M-f would move to. Thus, if point is in the middle of a word, M-d kills just the part after point. If some punctuation comes between point and the next word, it is killed along with the word. (If you wish to kill only the next word but not the punctuation before it, simply do M-f to get the end, and kill the word backwards with M-DEL.) M-d takes arguments just like M-f.

M-DEL( backward-kill-word) 删除点之前的单词。它杀死了从返回点到M-b移动到的位置的所有内容。例如,如果点位于 ' 中的空格之后福,酒吧' ,它会杀死'FOO, ' 。如果你想杀掉'FOO',而不是逗号和空格,请使用M-b M-d代替。 M-DEL

M-DEL (backward-kill-word) kills the word before point. It kills everything from point back to where M-b would move to. For instance, if point is after the space in ‘FOO, BAR, it kills ‘FOO, . If you wish to kill just ‘FOO’, and not the comma and the space, use M-b M-d instead of M-DEL.

M-t( transpose-words) 将点之前或包含点的单词与后面的单词交换。单词之间的分隔符不会移动。例如, '福,酒吧'转置为 '酒吧、美食'而不是 '酒吧福,'。有关转置的更多信息, 请参阅转置文本。

M-t (transpose-words) exchanges the word before or containing point with the following word. The delimiter characters between the words do not move. For example, ‘FOO, BAR transposes into ‘BAR, FOO rather than ‘BAR FOO,’. See Transposing Text, for more on transposition.

要通过作用于区域的操作来对字进行操作,请使用命令M-@( mark-word)。该命令设置要移动到的位置的标记M-f。有关此命令的更多信息, 请参阅标记文本对象的命令。

To operate on words with an operation which acts on the region, use the command M-@ (mark-word). This command sets the mark where M-f would move to. See Commands to Mark Textual Objects, for more information about this command.

单词命令对单词边界的理解是由语法表控制的。例如,任何字符都可以声明为单词分隔符。请参阅Emacs Lisp 参考手册中的语法表

The word commands’ understanding of word boundaries is controlled by the syntax table. Any character can, for example, be declared to be a word delimiter. See Syntax Tables in The Emacs Lisp Reference Manual.

此外,请参阅 ( ) 和命令的光标位置信息,它们计算并报告区域或缓冲区中的字数。 M-=count-words-regionM-x count-words

In addition, see Cursor Position Information for the M-= (count-words-region) and M-x count-words commands, which count and report the number of words in the region or buffer.


26.2 句子

26.2 Sentences

用于操作句子和段落的 Emacs 命令大多位于 Meta 键上,就像单词处理命令一样。

The Emacs commands for manipulating sentences and paragraphs are mostly on Meta keys, like the word-handling commands.

M-a
M-a

移回句子开头 ( backward-sentence)。

Move back to the beginning of the sentence (backward-sentence).

M-e
M-e

前进到句子末尾(forward-sentence)。

Move forward to the end of the sentence (forward-sentence).

M-k
M-k

杀到句子末尾(kill-sentence)。

Kill forward to the end of the sentence (kill-sentence).

C-x DEL
C-x DEL

Kill 回到句子的开头(backward-kill-sentence)。

Kill back to the beginning of the sentence (backward-kill-sentence).

命令M-a( backward-sentence) 和M-e ( forward-sentence) 分别移动到当前句子的开头和结尾。他们的装订被选择为类似于 C-aC-e,移动到行的开头和结尾。与它们不同,如​​果重复,M-aM-e移动连续的句子。

The commands M-a (backward-sentence) and M-e (forward-sentence) move to the beginning and end of the current sentence, respectively. Their bindings were chosen to resemble C-a and C-e, which move to the beginning and end of a line. Unlike them, M-a and M-e move over successive sentences if repeated.

在句子上向后移动会将点放置在句子的第一个字符之前;向前移动将点放在句子结束的标点符号后面。两个人都没有越过句子边界的空白。

Moving backward over a sentence places point just before the first character of the sentence; moving forward places point right after the punctuation that ends the sentence. Neither one moves over the whitespace at the sentence boundary.

正如C-aC-e有一个kill命令,C-k,与它们一起使用,M-a并且M-e有一个相应的kill命令:M-k( kill-sentence) 杀死从点到句子结尾的内容。使用正数值参数n,它会杀死接下来的n 个句子;使用否定参数 - n ,它会返回到前面第n个句子的开头。

Just as C-a and C-e have a kill command, C-k, to go with them, M-a and M-e have a corresponding kill command: M-k (kill-sentence) kills from point to the end of the sentence. With a positive numeric argument n, it kills the next n sentences; with a negative argument −n, it kills back to the beginning of the nth preceding sentence.

( )杀死回到句子的开头。 C-x DELbackward-kill-sentence

The C-x DEL (backward-kill-sentence) kills back to the beginning of a sentence.

句子命令假设您遵循美国打字员的惯例,在句子末尾添加两个空格。也就是说,只要有 ' ,句子就结束','' 或者 '' 后跟一行或两个空格的末尾,可以有任意数量的 '',']',''', 或者 '之间允许有 ' 字符。无论段落开始或结束,句子也开始或结束。遵循此约定很有用,因为它允许 Emacs 句子命令区分结束句子的句点和表示缩写的句点。

The sentence commands assume that you follow the American typist’s convention of putting two spaces at the end of a sentence. That is, a sentence ends wherever there is a ‘.’, ‘?’ or ‘!’ followed by the end of a line or two spaces, with any number of ‘)’, ‘]’, ‘'’, or ‘"’ characters allowed in between. A sentence also begins or ends wherever a paragraph begins or ends. It is useful to follow this convention, because it allows the Emacs sentence commands to distinguish between periods that end a sentence and periods that indicate abbreviations.

如果您只想在句子之间使用一个空格,可以将变量设置sentence-end-double-spacenil以使句子命令在出现单个空格时停止。然而,这有一个缺点:无法区分句子结尾的句号和表示缩写的句号。因此,为了方便可靠的编辑,我们建议您遵循两空格约定。该变量sentence-end-double-space还会影响填充(请参阅显式填充命令)。

If you want to use just one space between sentences, you can set the variable sentence-end-double-space to nil to make the sentence commands stop for single spaces. However, this has a drawback: there is no way to distinguish between periods that end sentences and those that indicate abbreviations. For convenient and reliable editing, we therefore recommend you follow the two-space convention. The variable sentence-end-double-space also affects filling (see Explicit Fill Commands).

该变量sentence-end控制如何识别句子的结尾。如果为非nil,则其值应该是正则表达式,用于匹配句子的最后几个字符以及句子后面的空格(请参阅正则表达式语法)。如果值为nil,默认值,则 Emacs 会根据各种标准(例如 的值)计算句子结尾sentence-end-double-space

The variable sentence-end controls how to recognize the end of a sentence. If non-nil, its value should be a regular expression, which is used to match the last few characters of a sentence, together with the whitespace following the sentence (see Syntax of Regular Expressions). If the value is nil, the default, then Emacs computes sentence ends according to various criteria such as the value of sentence-end-double-space.

某些语言(例如泰语)不使用句号来表示句子的结尾。在这种情况下 将变量设置sentence-end-without-period为 。t

Some languages, such as Thai, do not use periods to indicate the end of a sentence. Set the variable sentence-end-without-period to t in such cases.


26.3 段落

26.3 Paragraphs

用于操作段落的 Emacs 命令也在 Meta 键上。

The Emacs commands for manipulating paragraphs are also on Meta keys.

M-{
M-{

移回到上一段以 ( backward-paragraph) 开头的位置。

Move back to previous paragraph beginning (backward-paragraph).

M-}
M-}

前进到下一段末尾 ( forward-paragraph)。

Move forward to next paragraph end (forward-paragraph).

M-h
M-h

在本段或下一段周围标出点和标记 ( mark-paragraph)。

Put point and mark around this or next paragraph (mark-paragraph).

M-{( backward-paragraph) 移动到当前或上一个段落的开头,具体取决于调用命令时的位置(请参阅下面的段落定义)。 M-}( forward-paragraph) 同样移动到当前或下一段的末尾。如果段落前有空行,则M-{移动到空行。

M-{ (backward-paragraph) moves to the beginning of the current or previous paragraph, depending on where point is when the command is invoked (see below for the definition of a paragraph). M-} (forward-paragraph) similarly moves to the end of the current or next paragraph. If there is a blank line before the paragraph, M-{ moves to the blank line.

当您想要对段落进行操作时,请键入M-h ( mark-paragraph) 以设置其周围的区域。例如, M-h C-w删除点周围或之后的段落。 M-h 将点放在段落点所在段落的开头并在末尾进行标记。如果点位于段落之间(在一系列空行中或在边界处),则M-h设置下一个点周围段落的区域。如果段落第一行之前有空行,则这些空行之一将包含在该区域中。如果该区域已处于活动状态,则该命令会在不更改点的情况下设置标记,并且每个后续操作都会使M-h标记进一步前进一个段落。

When you wish to operate on a paragraph, type M-h (mark-paragraph) to set the region around it. For example, M-h C-w kills the paragraph around or after point. M-h puts point at the beginning and mark at the end of the paragraph point was in. If point is between paragraphs (in a run of blank lines, or at a boundary), M-h sets the region around the paragraph following point. If there are blank lines preceding the first line of the paragraph, one of these blank lines is included in the region. If the region is already active, the command sets the mark without changing point, and each subsequent M-h further advances the mark by one paragraph.

段落的定义取决于主要模式。在基本模式以及文本模式和相关模式中,一个段落与相邻段落之间由一个或多个 空行分隔开,这些空行要么是空的,要么仅由空格、制表符和/或换页字符组成。在编程语言模式中,段落通常以类似的方式定义,因此即使程序中没有段落,您也可以使用段落命令。

The definition of a paragraph depends on the major mode. In Fundamental mode, as well as Text mode and related modes, a paragraph is separated from neighboring paragraphs by one or more blank lines—lines that are either empty, or consist solely of space, tab and/or formfeed characters. In programming language modes, paragraphs are usually defined in a similar way, so that you can use the paragraph commands even though there are no paragraphs as such in a program.

请注意,在文本模式下,缩进行本身并不是段落分隔符。如果您希望缩进行来分隔段落,请改用段落缩进文本模式。请参阅文本模式

Note that an indented line is not itself a paragraph break in Text mode. If you want indented lines to separate paragraphs, use Paragraph-Indent Text mode instead. See Text Mode.

如果您设置填充前缀,则段落将由所有不以填充前缀开头的行分隔。请参阅填充文本

If you set a fill prefix, then paragraphs are delimited by all lines which don’t start with the fill prefix. See Filling Text.

段落边界的精确定义由变量paragraph-separate和控制paragraph-start。的值paragraph-start是一个正则表达式,应该匹配开始或分隔段落的行(请参阅正则表达式的语法)。的值paragraph-separate是另一个正则表达式,它应该匹配分隔段落但不属于任何段落的行(例如,空行)。开始新段落并包含在其中的行必须仅匹配 paragraph-start,而不是paragraph-separate。例如,在基本模式下,paragraph-startis"\f\\|[ \t]*$"paragraph-separateis "[ \t\f]*$"

The precise definition of a paragraph boundary is controlled by the variables paragraph-separate and paragraph-start. The value of paragraph-start is a regular expression that should match lines that either start or separate paragraphs (see Syntax of Regular Expressions). The value of paragraph-separate is another regular expression that should match lines that separate paragraphs without being part of any paragraph (for example, blank lines). Lines that start a new paragraph and are contained in it must match only paragraph-start, not paragraph-separate. For example, in Fundamental mode, paragraph-start is "\f\\|[ \t]*$", and paragraph-separate is "[ \t\f]*$".

请注意,paragraph-startparagraph-separate与左边距的文本匹配,这不一定是行的开头,因此这些正则表达式不应使用 '^' 作为锚点,以确保段落功能在由边距设置缩进的文本区域内同样有效。

Note that paragraph-start and paragraph-separate are matched against the text at the left margin, which is not necessarily the beginning of the line, so these regexps should not use ‘^’ as an anchor, to ensure that the paragraph functions will work equally within a region of text indented by a margin setting.


26.4 页面

26.4 Pages

在某些文本文件中,文本分为由换页符分隔的页面ASCII代码 12,也表示为 '控制-L'),在 Emacs 中显示为转义序列 '^L'(请参阅文本如何显示)。传统上,当将此类文本文件打印为硬拷贝时,每个换页符都会强制进行分页。大多数 Emacs 命令将其视为任何其他字符,因此您可以使用 插入它C-q C-l,使用 删除它 DEL,等等。此外,Emacs 还提供了在页面上移动和对其进行操作的命令。

Within some text files, text is divided into pages delimited by the formfeed character (ASCII code 12, also denoted as ‘control-L’), which is displayed in Emacs as the escape sequence ‘^L’ (see How Text Is Displayed). Traditionally, when such text files are printed to hardcopy, each formfeed character forces a page break. Most Emacs commands treat it just like any other character, so you can insert it with C-q C-l, delete it with DEL, etc. In addition, Emacs provides commands to move over pages and operate on them.

M-x what-page
M-x what-page

显示点的页码以及该页内的行号。

Display the page number of point, and the line number within that page.

C-x [
C-x [

将点移至上一页边界 ( backward-page)。

Move point to previous page boundary (backward-page).

C-x ]
C-x ]

将点移至下一页边界 ( forward-page)。

Move point to next page boundary (forward-page).

C-x C-p
C-x C-p

在本页(或另一页)周围放置点和标记 ( mark-page)。

Put point and mark around this page (or another page) (mark-page).

C-x l
C-x l

计算该页中的行数 ( count-lines-page)。

Count the lines in this page (count-lines-page).

M-x what-page从文件开头开始计算页数,并计算页面内的行数,并在回显区域中显示这两个数字。

M-x what-page counts pages from the beginning of the file, and counts lines within the page, showing both numbers in the echo area.

C-x [( )命令backward-page将点移动到紧邻上一页分隔符之后。如果 point 已经位于页面分隔符之后,则会跳过该分隔符并停在上一个分隔符处。数字参数用作重复计数。C-x ]( )命令forward-page向前移动超过下一页分隔符。

The C-x [ (backward-page) command moves point to immediately after the previous page delimiter. If point is already right after a page delimiter, it skips that one and stops at the previous one. A numeric argument serves as a repeat count. The C-x ] (forward-page) command moves forward past the next page delimiter.

命令C-x C-p( mark-page) 将点放在当前页的开头(在前面的页分隔符之后),将标记放在页的末尾(在最后的页分隔符之后)。

The C-x C-p command (mark-page) puts point at the beginning of the current page (after that page delimiter at the front), and the mark at the end of the page (after the page delimiter at the end).

C-x C-p C-w是终止页面并将其移动到其他地方的便捷方法。如果您使用C-x [和 移动到另一个页面分隔符C-x ],然后拉出被杀死的页面,所有页面将再次被正确分隔。确保其按预期工作是因为C-x C-p该区域中仅包含以下页面分隔符。

C-x C-p C-w is a handy way to kill a page to move it elsewhere. If you move to another page delimiter with C-x [ and C-x ], then yank the killed page, all the pages will be properly delimited once again. Making sure this works as expected is the reason C-x C-p includes only the following page delimiter in the region.

数字参数指定C-x C-p相对于当前页面要转到哪一页。 0 表示当前页,1 表示下一页,-1 表示上一页。

A numeric argument to C-x C-p specifies which page to go to, relative to the current one. Zero means the current page, one means the next page, and −1 means the previous one.

命令C-x l( count-lines-page) 适合决定在何处将页面分成两部分。它在回显区域中显示当前页的总行数,然后将其分为当前行之前的行和之后的行,如下所示

The C-x l command (count-lines-page) is good for deciding where to break a page in two. It displays in the echo area the total number of lines in the current page, and then divides it up into those preceding the current line and those following, as in

页面有 96 (72+25) 行
Page has 96 (72+25) lines

请注意,总和减少了 1;如果点不在行的开头,这是正确的。

Notice that the sum is off by one; this is correct if point is not at the beginning of a line.

该变量page-delimiter控制页面开始的位置。它的值是一个正则表达式,与分隔页面的行的开头相匹配(请参阅正则表达式的语法)。该变量的正常值为"^\f",它匹配行开头的换页符。

The variable page-delimiter controls where pages begin. Its value is a regular expression that matches the beginning of a line that separates pages (see Syntax of Regular Expressions). The normal value of this variable is "^\f", which matches a formfeed character at the beginning of a line.


26.5 引号

26.5 Quotation Marks

一种常见的引用方式是打字机约定,即使用直撇号进行引用 ''像这样'' 或双引号 '“像这样”'。另一种常见的方式是弯曲引用约定,它使用左右单引号或双引号‘like this’“like this”12。在文本文件中,打字机引用简单且便携;弯曲的引号不太含糊,通常看起来更好。

One common way to quote is the typewriter convention, which quotes using straight apostrophes ‘'like this'’ or double-quotes ‘"like this"’. Another common way is the curved quote convention, which uses left and right single or double quotation marks ‘like this’ or “like this”12. In text files, typewriter quotes are simple and portable; curved quotes are less ambiguous and typically look nicer.

电子报价模式可以更轻松地输入曲线报价。当您键入字符时,它可以选择将其转换`'to ``to''to 。可以通过自定义变量 来更改上面列出的默认引号,这是 electric-quote-chars一个由四个字符组成的列表,其中的项分别对应于左单引号、右单引号、左双引号和右双引号,其默认值值为'(?‘ ?’ ?“ ?”)

Electric Quote mode makes it easier to type curved quotes. As you type characters it optionally converts ` to , ' to , `` to , and '' to . It’s possible to change the default quotes listed above, by customizing the variable electric-quote-chars, a list of four characters, where the items correspond to the left single quote, the right single quote, the left double quote and the right double quote, respectively, whose default value is '(?‘ ?’ ?“ ?”).

您可以通过自定义控制其活动位置的变量来自定义电子报价模式的行为。如果electric-quote-paragraph为非,则在文本段落中处于活动状态;如果为非,则nil在编程语言注释中处于活动状态;如果为非- ,则在编程语言字符串中处于 活动状态。默认值适用 于和其他变量。 electric-quote-commentnilelectric-quote-stringnilnilelectric-quote-stringt

You can customize the behavior of Electric Quote mode by customizing variables that control where it is active. It is active in text paragraphs if electric-quote-paragraph is non-nil, in programming-language comments if electric-quote-comment is non-nil, and in programming-language strings if electric-quote-string is non-nil. The default is nil for electric-quote-string and t for the other variables.

您还可以将该选项设置electric-quote-replace-double为非值nil。然后,键入"会根据上下文插入适当的弯曲双引号:在缓冲区的开头或在换行符、空格、左括号或引号字符之后等

You can also set the option electric-quote-replace-double to a non-nil value. Then, typing " inserts an appropriate curved double quote depending on context: at the beginning of the buffer or after a line break, whitespace, opening parenthesis, or quote character, and otherwise.

默认情况下,电子报价模式处于禁用状态。要在单个缓冲区中切换它,请使用M-x electric-quote-local-mode.要全局切换它,请输入 M-x electric-quote-mode。要禁止它一次性使用,请键入C-q `orC-q '来代替`or '。即使在电子报价已禁用或处于非活动状态时,要插入弯曲报价,您可以键入C-x 8 [for C-x 8 ]for C-x 8 {forC-x 8 }for 。请参阅插入文本。请注意, 的值 electric-quote-chars不会影响这些键绑定,它们不是 的键绑定,electric-quote-mode而是绑定在 中 global-map

Electric Quote mode is disabled by default. To toggle it in a single buffer, use M-x electric-quote-local-mode. To toggle it globally, type M-x electric-quote-mode. To suppress it for a single use, type C-q ` or C-q ' instead of ` or '. To insert a curved quote even when Electric Quote is disabled or inactive, you can type C-x 8 [ for , C-x 8 ] for , C-x 8 { for , and C-x 8 } for . See Inserting Text. Note that the value of electric-quote-chars does not affect these key bindings, they are not key bindings of electric-quote-mode but bound in global-map.


26.6 填充文本

26.6 Filling Text

填充文本意味着将其分成适合指定宽度的行。 Emacs 通过两种方式进行填充。在自动填充模式下,插入带有自动插入字符的文本也会自动填充它。编辑文本时还可以使用显式填充命令。

Filling text means breaking it up into lines that fit a specified width. Emacs does filling in two ways. In Auto Fill mode, inserting text with self-inserting characters also automatically fills it. There are also explicit fill commands that you can use when editing text.


26.6.1 自动填充模式

26.6.1 Auto Fill Mode

自动填充模式是一种缓冲区本地次要模式(请参阅次要模式),其中当行变得太宽并且您键入SPC或 时,行会自动断行RET

Auto Fill mode is a buffer-local minor mode (see Minor Modes) in which lines are broken automatically when the line becomes too wide and you type SPC or RET.

M-x auto-fill-mode
M-x auto-fill-mode

启用或禁用自动填充模式。

Enable or disable Auto Fill mode.

SPC
SPC
RET
RET

在自动填充模式下,适当时换行。

In Auto Fill mode, break lines when appropriate.

模式命令M-x auto-fill-mode切换当前缓冲区中的自动填充模式。与任何其他次要模式一样,使用正数字参数,它会启用自动填充模式,使用负参数则禁用它。要在某些主要模式下自动启用自动填充模式,请添加auto-fill-mode到模式挂钩(请参阅主要模式)。当自动填充模式启用时,模式指示器 '充满' 出现在模式行中(请参阅模式行)。

The mode command M-x auto-fill-mode toggles Auto Fill mode in the current buffer. Like any other minor mode, with a positive numeric argument, it enables Auto Fill mode, and with a negative argument it disables it. To enable Auto Fill mode automatically in certain major modes, add auto-fill-mode to the mode hooks (see Major Modes). When Auto Fill mode is enabled, the mode indicator ‘Fill’ appears in the mode line (see The Mode Line).

当线条长于所需宽度时,自动填充模式会在适当的位置自动换行。仅当您键入SPC或 时才会发生此换行RET。如果您希望插入空格或换行符但不允许换行,请分别键入或。另外, 插入换行符而不换行。 C-q SPCC-q C-jC-o

Auto Fill mode breaks lines automatically at the appropriate places whenever lines get longer than the desired width. This line breaking occurs only when you type SPC or RET. If you wish to insert a space or newline without permitting line-breaking, type C-q SPC or C-q C-j respectively. Also, C-o inserts a newline without line breaking.

自动填充换行的位置取决于该行的字符。对于来自ASCII、拉丁语和大多数其他脚本的字符,Emacs 在空格字符上断行,以保持单词完整。但对于 CJK 脚本,任意两个字符之间可以换行。 (如果您加载避头库中,Emacs 将避免在某些 CJK 字符对之间断行,而特殊规则禁止这样做。)

The place where Auto Fill breaks a line depends on the line’s characters. For characters from ASCII, Latin, and most other scripts Emacs breaks a line on space characters, to keep the words intact. But for CJK scripts, a line can be broken between any two characters. (If you load the kinsoku library, Emacs will avoid breaking a line between certain pairs of CJK characters, where special rules prohibit that.)

当自动填充模式断行时,它会尝试遵循 自适应填充前缀:如果可以从当前段落的第一行和/或第二行推导出填充前缀,则会将其插入到新行中(请参阅自适应填充)。否则,新行将缩进,就像您TAB在其上键入一样(请参阅缩进)。在编程语言模式下,如果注释中间断行,则通过适当插入新的注释定界符来分割注释。

When Auto Fill mode breaks a line, it tries to obey the adaptive fill prefix: if a fill prefix can be deduced from the first and/or second line of the current paragraph, it is inserted into the new line (see Adaptive Filling). Otherwise the new line is indented, as though you had typed TAB on it (see Indentation). In a programming language mode, if a line is broken in the middle of a comment, the comment is split by inserting new comment delimiters as appropriate.

自动填充模式不会重新填充整个段落;它会断行但不会合并行。因此,在段落中间进行编辑可能会导致段落填充不正确。要填充它,请调用显式填充命令(请参阅显式填充命令)。

Auto Fill mode does not refill entire paragraphs; it breaks lines but does not merge lines. Therefore, editing in the middle of a paragraph can result in a paragraph that is not correctly filled. To fill it, call the explicit fill commands (see Explicit Fill Commands).

在显示时自动换行的类似功能是视觉线模式(请参阅视觉线模式)。

A similar feature that wraps long lines automatically at display time is Visual Line Mode (see Visual Line Mode).


26.6.2 显式填充命令

26.6.2 Explicit Fill Commands

M-q
M-q

填写当前段落(fill-paragraph)。

Fill current paragraph (fill-paragraph).

C-x f
C-x f

设置填充列 ( set-fill-column)。

Set the fill column (set-fill-column).

M-x fill-region
M-x fill-region

将各段落填入 ( ) 区域fill-region

Fill each paragraph in the region (fill-region).

M-x fill-region-as-paragraph
M-x fill-region-as-paragraph

填充该区域,将其视为一个段落。

Fill the region, considering it as one paragraph.

M-x center-line
M-x center-line

居中一条线。

Center a line.

命令M-q( fill-paragraph)填充当前段落。它重新分配段落内的换行符,并删除段落内出现的任何多余空格和制表符,从而使行最终适合某个最大宽度。与自动填充模式一样,此填充命令和其他填充命令通常在空格字符处换行,但对于 CJK 字符,这些命令可以在几乎任意两个字符之间换行,并且它们还可以遵守避头尾规则。请参阅自动填充模式

The command M-q (fill-paragraph) fills the current paragraph. It redistributes the line breaks within the paragraph, and deletes any excess space and tab characters occurring within the paragraph, in such a way that the lines end up fitting within a certain maximum width. Like Auto Fill mode, this and other filling commands usually break lines at space characters, but for CJK characters these commands can break a line between almost any two characters, and they can also obey the kinsoku rules. See Auto Fill Mode.

通常,M-q作用于point所在的段落,但如果point位于段落之间,则作用于point之后的段落。如果该区域处于活动状态,它将作用于该区域中的文本。还可以调用M-x fill-region专门填充该区域的文字。

Normally, M-q acts on the paragraph where point is, but if point is between paragraphs, it acts on the paragraph after point. If the region is active, it acts instead on the text in the region. You can also call M-x fill-region to specifically fill the text in the region.

M-qfill-region使用常用的 Emacs 标准来查找段落边界(请参阅段落)。为了获得更多控制,您可以使用M-x fill-region-as-paragraph,它将点和标记之间的所有内容重新填充为单个段落。此命令会删除该区域内的所有空白行,因此单独的文本块最终会合并为一个块。

M-q and fill-region use the usual Emacs criteria for finding paragraph boundaries (see Paragraphs). For more control, you can use M-x fill-region-as-paragraph, which refills everything between point and mark as a single paragraph. This command deletes any blank lines within the region, so separate blocks of text end up combined into one block.

一个数字参数M-q告诉它对齐文本并填充它。这意味着插入额外的空格以使右边距与填充列精确对齐。要删除多余的空格,请M-q不带参数使用。 (对于 也同样 fill-region。)

A numeric argument to M-q tells it to justify the text as well as filling it. This means that extra spaces are inserted to make the right margin line up exactly at the fill column. To remove the extra spaces, use M-q with no argument. (Likewise for fill-region.)

填充的最大线宽由缓冲区局部变量指定fill-column。默认值(参见局部变量)是 70。在当前缓冲区中设置的最简单方法fill-column是使用命令C-x f( set-fill-column)。对于数字参数,它使用它作为新的填充列。正如 C-u参数一样,它设置fill-column为点的当前水平位置。请注意,就其本质而言, fill-column是以列为单位进行测量的;该列在图形显示上的实际位置取决于所使用的字体。特别是,使用可变间距字体会导致 fill-column不同行在显示时占据不同的水平位置。

The maximum line width for filling is specified by the buffer-local variable fill-column. The default value (see Local Variables) is 70. The easiest way to set fill-column in the current buffer is to use the command C-x f (set-fill-column). With a numeric argument, it uses that as the new fill column. With just C-u as argument, it sets fill-column to the current horizontal position of point. Note that, by its very nature, fill-column is measured in column units; the actual position of that column on a graphical display depends on the font being used. In particular, using variable-pitch fonts will cause the fill-column occupy different horizontal positions on display in different lines.

该命令M-x center-line使当前行在当前填充列中居中。使用参数n,它 分别将n行居中并移过它们。此绑定由文本模式进行,并且仅在该模式和相关模式下可用(请参阅文本模式)。

The command M-x center-line centers the current line within the current fill column. With an argument n, it centers n lines individually and moves past them. This binding is made by Text mode and is available only in that and related modes (see Text Mode).

默认情况下,Emacs 将句点后跟两个空格或换行符视为句子的结尾;句点后跟一个空格表示缩写,而不是句子的结尾。因此,填充命令不会在句点后跟一个空格之后断行。如果将该变量设置 sentence-end-double-spacenil,填充命令将在句点后跟一个空格后换行,并在每个句点后仅放置一个空格。有关其他效果和可能的缺点, 请参阅句子。

By default, Emacs considers a period followed by two spaces or by a newline as the end of a sentence; a period followed by just one space indicates an abbreviation, not the end of a sentence. Accordingly, the fill commands will not break a line after a period followed by just one space. If you set the variable sentence-end-double-space to nil, the fill commands will break a line after a period followed by one space, and put just one space after each period. See Sentences, for other effects and possible drawbacks of this.

如果变量colon-double-space是非- nil,填充命令会在冒号后放置两个空格。

If the variable colon-double-space is non-nil, the fill commands put two spaces after a colon.

要指定不允许换行的其他条件,请自定义异常钩子变量fill-nobreak-predicate (请参阅Hooks)。此钩子中的每个函数都在不带参数的情况下调用,点位于 Emacs 考虑换行的位置。如果函数返回非值nil,Emacs 不会在那里断行。您可以在那里使用的功能包括:( fill-single-word-nobreak-p不要在句子的第一个单词之后或最后一个单词之前中断);fill-single-char-nobreak-p (不要在前面有空格字符的单字母单词后中断);fill-french-nobreak-p(不要在 ' 之后中断'或之前'',':' 或者 ''); and fill-polish-nobreak-p(不要在一个字母单词后中断,即使前面有一个非空白字符)。

To specify additional conditions where line-breaking is not allowed, customize the abnormal hook variable fill-nobreak-predicate (see Hooks). Each function in this hook is called with no arguments, with point positioned where Emacs is considering breaking a line. If a function returns a non-nil value, Emacs will not break the line there. Functions you can use there include: fill-single-word-nobreak-p (don’t break after the first word of a sentence or before the last); fill-single-char-nobreak-p (don’t break after a one-letter word preceded by a whitespace character); fill-french-nobreak-p (don’t break after ‘(’ or before ‘)’, ‘:’ or ‘?’); and fill-polish-nobreak-p (don’t break after a one letter word, even if preceded by a non-whitespace character).

fill-columnEmacs 可以使用显示填充列指示器模式在该位置显示指示器(请参阅display-fill-column-indicator)。

Emacs can display an indicator in the fill-column position using the Display fill column indicator mode (see display-fill-column-indicator).


26.6.3 填充前缀

26.6.3 The Fill Prefix

填充前缀功能允许填充段落,以便每行以特殊字符串开头(例如空格序列,给出缩进的段落)。您可以显式指定填充前缀;否则,Emacs 会尝试自动推导(请参阅自适应填充)。

The fill prefix feature allows paragraphs to be filled so that each line starts with a special string of characters (such as a sequence of spaces, giving an indented paragraph). You can specify a fill prefix explicitly; otherwise, Emacs tries to deduce one automatically (see Adaptive Filling).

C-x .
C-x .

设置填充前缀 ( set-fill-prefix)。

Set the fill prefix (set-fill-prefix).

M-q
M-q

fill-paragraph使用当前填充前缀 ( ) 填充段落。

Fill a paragraph using current fill prefix (fill-paragraph).

M-x fill-individual-paragraphs
M-x fill-individual-paragraphs

填充该区域,将每次缩进更改视为开始一个新段落。

Fill the region, considering each change of indentation as starting a new paragraph.

M-x fill-nonuniform-paragraphs
M-x fill-nonuniform-paragraphs

填充该区域,仅将段落分隔线视为开始新段落。

Fill the region, considering only paragraph-separator lines as starting a new paragraph.

要为当前缓冲区指定填充前缀,请移至以所需前缀开头的行,将点放在前缀末尾,然后键入C-x .( set-fill-prefix)。 (这是 . 之后的句点C-x。)要关闭填充前缀,请指定一个空前缀:C-x .在行首键入点。

To specify a fill prefix for the current buffer, move to a line that starts with the desired prefix, put point at the end of the prefix, and type C-x . (set-fill-prefix). (That’s a period after the C-x.) To turn off the fill prefix, specify an empty prefix: type C-x . with point at the beginning of a line.

当填充前缀生效时,填充命令在填充之前从段落的每一行中删除填充前缀,并在填充后将其插入到每一行中。 (段落第一行的开头保持不变,因为通常是故意不同的。)自动填充模式还会在创建新行时自动插入填充前缀(请参阅自动填充模式)。C-o当您在行的开头使用填充前缀时,该命令会在它创建的新行上插入填充前缀(请参阅空白行)。相反,该命令M-^删除它删除的换行符后面的前缀(如果出现)(请参阅缩进)。

When a fill prefix is in effect, the fill commands remove the fill prefix from each line of the paragraph before filling, and insert it on each line after filling. (The beginning of the first line of the paragraph is left unchanged, since often that is intentionally different.) Auto Fill mode also inserts the fill prefix automatically when it makes a new line (see Auto Fill Mode). The C-o command inserts the fill prefix on new lines it creates, when you use it at the beginning of a line (see Blank Lines). Conversely, the command M-^ deletes the prefix (if it occurs) after the newline that it deletes (see Indentation).

例如,如果fill-column是 40 并且您将填充前缀设置为 ';;',然后M-q在下面的文本中

For example, if fill-column is 40 and you set the fill prefix to ‘;; ’, then M-q in the following text

;;这是一
;;段落示例
;;在 Lisp 风格的注释中。
;; This is an
;; example of a paragraph
;; inside a Lisp-style comment.

产生这个:

produces this:

;;这是一个段落的例子
;;在 Lisp 风格的注释中。
;; This is an example of a paragraph
;; inside a Lisp-style comment.

不以 fill 前缀开头的行被认为是段落的开始,无论是 inM-q还是 paragraph 命令;这对于带有悬挂缩进的段落(除了第一行之外的每一行都缩进)给出了良好的结果。删除前缀后,空白或缩进的行也会分隔或开始段落;如果您要编写每行都带有注释分隔符的多段落注释,这就是您想要的。

Lines that do not start with the fill prefix are considered to start paragraphs, both in M-q and the paragraph commands; this gives good results for paragraphs with hanging indentation (every line indented except the first one). Lines which are blank or indented once the prefix is removed also separate or start paragraphs; this is what you want if you are writing multi-paragraph comments with a comment delimiter on each line.

您可以使用M-x fill-individual-paragraphs自动设置每个段落的填充前缀。此命令将区域划分为段落,将缩进量的每次变化视为新段落的开始,并填充每个段落。因此,一个段落中的所有行都具有相同的缩进量。该缩进用作该段落的填充前缀。

You can use M-x fill-individual-paragraphs to set the fill prefix for each paragraph automatically. This command divides the region into paragraphs, treating every change in the amount of indentation as the start of a new paragraph, and fills each of these paragraphs. Thus, all the lines in one paragraph have the same amount of indentation. That indentation serves as the fill prefix for that paragraph.

M-x fill-nonuniform-paragraphs是一个类似的命令,以不同的方式将区域划分为段落。它仅将段落分隔行(由 定义paragraph-separate)视为开始新段落。由于这意味着一个段落的行可能具有不同的缩进量,因此所使用的填充前缀是该段落的任何行的最小缩进量。对于将段落的第一行或多或少地缩进段落其余部分的样式,这会产生良好的结果。

M-x fill-nonuniform-paragraphs is a similar command that divides the region into paragraphs in a different way. It considers only paragraph-separating lines (as defined by paragraph-separate) as starting a new paragraph. Since this means that the lines of one paragraph may have different amounts of indentation, the fill prefix used is the smallest amount of indentation of any of the lines of the paragraph. This gives good results with styles that indent a paragraph’s first line more or less that the rest of the paragraph.

填充前缀存储在变量 中fill-prefix。它的值是一个字符串,或者nil当没有填充前缀时。这是每个缓冲区的变量;更改变量仅影响当前缓冲区,但您也可以更改默认值。请参阅局部变量

The fill prefix is stored in the variable fill-prefix. Its value is a string, or nil when there is no fill prefix. This is a per-buffer variable; altering the variable affects only the current buffer, but there is a default value which you can change as well. See Local Variables.

textindentation属性提供了另一种方法来控制段落接收的缩进量。请参阅丰富文本中的缩进

The indentation text property provides another way to control the amount of indentation paragraphs receive. See Indentation in Enriched Text.


26.6.4 自适应填充

26.6.4 Adaptive Filling

在某些情况下,填充命令可以自动推断出段落的正确填充前缀:行开头的空格或某些标点符号会传播到段落的所有行。

The fill commands can deduce the proper fill prefix for a paragraph automatically in certain cases: either whitespace or certain punctuation characters at the beginning of a line are propagated to all lines of the paragraph.

如果段落有两行或更多行,则填充前缀取自段落的第二行,但前提是它也出现在第一行上。

If the paragraph has two or more lines, the fill prefix is taken from the paragraph’s second line, but only if it appears on the first line as well.

如果段落只有一行,填充命令可能会采用该行的前缀。这个决定很复杂,因为在这种情况下需要做三件合理的事情:

If a paragraph has just one line, fill commands may take a prefix from that line. The decision is complicated because there are three reasonable things to do in such a case:

  • 在段落的所有行上使用第一行的前缀。
  • Use the first line’s prefix on all the lines of the paragraph.
  • 使用空格缩进后续行,以便它们在第一行前缀后面的文本下方对齐,但实际上并不复制第一行的前缀。
  • Indent subsequent lines with whitespace, so that they line up under the text that follows the prefix on the first line, but don’t actually copy the prefix from the first line.
  • 不要对第二行和以下行做任何特殊的事情。
  • Don’t do anything special with the second and following lines.

所有这三种格式都是常用的。因此,填充命令会尝试根据出现的前缀和主要模式来确定您想要的内容。方法如下。

All three of these styles of formatting are commonly used. So the fill commands try to determine what you would like, based on the prefix that appears and on the major mode. Here is how.

如果在第一行找到的前缀匹配 adaptive-fill-first-line-regexp,或者它看起来是注释开始序列(这取决于主要模式),则找到的前缀将用于填充段落,前提是它不充当段落开头在后续行中。

If the prefix found on the first line matches adaptive-fill-first-line-regexp, or if it appears to be a comment-starting sequence (this depends on the major mode), then the prefix found is used for filling the paragraph, provided it would not act as a paragraph starter on subsequent lines.

否则,找到的前缀将转换为等效数量的空格,并且这些空格将用作其余行的填充前缀,前提是它们不会充当后续行的段落开头。

Otherwise, the prefix found is converted to an equivalent number of spaces, and those spaces are used as the fill prefix for the rest of the lines, provided they would not act as a paragraph starter on subsequent lines.

在文本模式以及仅用空行和页面分隔符分隔段落的其他模式下,自适应填充选择的前缀永远不会充当段落开头,因此它始终可以用于填充。

In Text mode, and other modes where only blank lines and page delimiters separate paragraphs, the prefix chosen by adaptive filling never acts as a paragraph starter, so it can always be used for filling.

该变量adaptive-fill-regexp确定什么类型的行开头可以用作填充前缀:使用与此正则表达式匹配的行开头的任何字符。如果将该变量设置adaptive-fill-modenil,则永远不会自动选择填充前缀。

The variable adaptive-fill-regexp determines what kinds of line beginnings can serve as a fill prefix: any characters at the start of the line that match this regular expression are used. If you set the variable adaptive-fill-mode to nil, the fill prefix is never chosen automatically.

您可以通过将变量设置adaptive-fill-function为函数来指定自动选择填充前缀的更复杂的方法。该函数在行的左边距之后用点调用,它应该根据该行返回适当的填充前缀。如果返回niladaptive-fill-regexp则有机会找到前缀。

You can specify more complex ways of choosing a fill prefix automatically by setting the variable adaptive-fill-function to a function. This function is called with point after the left margin of a line, and it should return the appropriate fill prefix based on that line. If it returns nil, adaptive-fill-regexp gets a chance to find a prefix.


26.7 大小写转换命令

26.7 Case Conversion Commands

Emacs 具有用于将单个单词或任意范围的文本转换为大写或小写的命令。

Emacs has commands for converting either a single word or any arbitrary range of text to upper case or to lower case.

M-l
M-l

将以下单词转换为小写 ( downcase-word)。

Convert following word to lower case (downcase-word).

M-u
M-u

将以下单词转换为大写 ( upcase-word)。

Convert following word to upper case (upcase-word).

M-c
M-c

将下面的单词(capitalize-word)大写。

Capitalize the following word (capitalize-word).

C-x C-l
C-x C-l

将区域转换为小写 ( downcase-region)。

Convert region to lower case (downcase-region).

C-x C-u
C-x C-u

将区域转换为大写 ( upcase-region)。

Convert region to upper case (upcase-region).

M-l( downcase-word) 将点之后的单词转换为小写,并移过它。因此,重复M-l会转换连续的单词。 M-u( upcase-word) 改为全部大写,而M-c( capitalize-word) 将单词的第一个字母转换为大写,其余字母转换为小写。如果给定参数,所有这些命令都会一次转换多个单词。它们对于将大量文本从全部大写转换为混合大小写特别方便,因为您可以使用M-l,M-uM-c酌情在每个单词上移动文本,偶尔使用M-f来跳过单词。

M-l (downcase-word) converts the word after point to lower case, moving past it. Thus, repeating M-l converts successive words. M-u (upcase-word) converts to all capitals instead, while M-c (capitalize-word) puts the first letter of the word into upper case and the rest into lower case. All these commands convert several words at once if given an argument. They are especially convenient for converting a large amount of text from all upper case to mixed case, because you can move through the text using M-l, M-u or M-c on each word as appropriate, occasionally using M-f instead to skip a word.

当给出负参数时,单词大小写转换命令适用于 point 之前适当数量的单词,但不移动 point。当您刚刚以错误的大小写输入单词时,这很方便:您可以给出大小写转换命令并继续输入。

When given a negative argument, the word case conversion commands apply to the appropriate number of words before point, but do not move point. This is convenient when you have just typed a word in the wrong case: you can give the case conversion command and continue typing.

如果在单词中间给出单词大小写转换命令,则它仅适用于单词中 point 之后的部分。 (这与M-d( ) 的作用相当kill-word。)对于负参数,大小写转换仅适用于 point 之前的单词部分。

If a word case conversion command is given in the middle of a word, it applies only to the part of the word which follows point. (This is comparable to what M-d (kill-word) does.) With a negative argument, case conversion applies only to the part of the word before point.

其他大小写转换命令是C-x C-u ( upcase-region) 和C-x C-l( downcase-region),它们将 point 和 mark 之间的所有内容转换为指定的大小写。点和标记不动。

The other case conversion commands are C-x C-u (upcase-region) and C-x C-l (downcase-region), which convert everything between point and mark to the specified case. Point and mark do not move.

区域大小写转换命令upcase-regiondowncase-region通常被禁用。这意味着如果您尝试使用它们,它们会要求您确认。当您确认后,您可以启用该命令,这意味着它不会再次要求确认。请参阅禁用命令

The region case conversion commands upcase-region and downcase-region are normally disabled. This means that they ask for confirmation if you try to use them. When you confirm, you may enable the command, which means it will not ask for confirmation again. See Disabling Commands.


26.8 文本模式

26.8 Text Mode

文本模式是用人类语言编辑文本文件的主要模式。名称以扩展名结尾的文件。TXT 通常以文本模式打开(请参阅选择文件模式)。要显式切换到文本模式,请键入M-x text-mode

Text mode is a major mode for editing files of text in a human language. Files which have names ending in the extension .txt are usually opened in Text mode (see Choosing File Modes). To explicitly switch to Text mode, type M-x text-mode.

在文本模式下,只有空行和页面分隔符分隔段落。因此,段落可以缩进,自适应填充决定填充段落时使用什么缩进。请参阅自适应填充

In Text mode, only blank lines and page delimiters separate paragraphs. As a result, paragraphs can be indented, and adaptive filling determines what indentation to use when filling a paragraph. See Adaptive Filling.

在文本模式下,TAB( indent-for-tab-command) 命令通常会在下一个制表位之前插入空格,而不是缩进当前行。有关详细信息, 请参阅缩进。

In Text mode, the TAB (indent-for-tab-command) command usually inserts whitespace up to the next tab stop, instead of indenting the current line. See Indentation, for details.

文本模式会关闭与注释相关的功能,除非您显式调用它们。它更改了语法表,以便撇号被视为单词的一部分(例如,'' 被视为一个词)。但是,如果单词以撇号开头,则出于大写目的,它将被视为前缀(例如,M-c转换 ''你好'' 进入 ''你好'”,正如预期的那样)。

Text mode turns off the features concerned with comments except when you explicitly invoke them. It changes the syntax table so that apostrophes are considered part of words (e.g., ‘don't’ is considered one word). However, if a word starts with an apostrophe, it is treated as a prefix for the purposes of capitalization (e.g., M-c converts ‘'hello'’ into ‘'Hello'’, as expected).

如果缩进段落的第一行,则应使用段落缩进文本模式 ( M-x paragraph-indent-text-mode) 而不是文本模式。在这种模式下,段落之间不需要有空行,因为首行缩进足以开始一个段落;但是,不支持每行都缩进的段落。用于M-x paragraph-indent-minor-mode在不应更改主要模式的情况下启用等效的次要模式(例如,在邮件撰写中)。

If you indent the first lines of paragraphs, then you should use Paragraph-Indent Text mode (M-x paragraph-indent-text-mode) rather than Text mode. In that mode, you do not need to have blank lines between paragraphs, because the first-line indentation is sufficient to start a paragraph; however paragraphs in which every line is indented are not supported. Use M-x paragraph-indent-minor-mode to enable an equivalent minor mode for situations where you shouldn’t change the major mode—in mail composition, for instance.

文本模式绑定到.该命令使用拼写词典作为可能单词的空间,完成点之前缓冲区中的部分单词。请参阅检查和更正拼写。如果您的窗口管理器定义 要切换窗口,您可以键入或来代替。 M-TABispell-complete-wordM-TABESC TABC-M-i

Text mode binds M-TAB to ispell-complete-word. This command performs completion of the partial word in the buffer before point, using the spelling dictionary as the space of possible words. See Checking and Correcting Spelling. If your window manager defines M-TAB to switch windows, you can type ESC TAB or C-M-i instead.

输入文本模式会运行模式挂钩text-mode-hook (请参阅主要模式)。

Entering Text mode runs the mode hook text-mode-hook (see Major Modes).

以下部分描述了 从文本模式派生的几种主要模式。这些衍生产品共享上述文本模式的大部分功能。特别是,文本模式的衍生物text-mode-hook在运行它们自己的模式挂钩之前运行。

The following sections describe several major modes that are derived from Text mode. These derivatives share most of the features of Text mode described above. In particular, derivatives of Text mode run text-mode-hook prior to running their own mode hooks.


26.9 轮廓模式

26.9 Outline Mode

轮廓模式是从文本模式派生出来的一个主要模式,专门用于编辑轮廓。它提供了在大纲结构中的条目之间导航的命令,以及使缓冲区的某些部分暂时不可见的命令,以便更容易查看大纲结构。键入M-x outline-mode以切换到大纲模式。进入 Outline 模式 text-mode-hook后会运行钩子outline-mode-hook (请参阅Hooks)。

Outline mode is a major mode derived from Text mode, which is specialized for editing outlines. It provides commands to navigate between entries in the outline structure, and commands to make parts of a buffer temporarily invisible, so that the outline structure may be more easily viewed. Type M-x outline-mode to switch to Outline mode. Entering Outline mode runs the hook text-mode-hook followed by the hook outline-mode-hook (see Hooks).

当您使用轮廓模式命令使线条不可见时(请参阅轮廓可见性命令),该线条将从屏幕上消失。省略号(连续三个句点)显示在上一个可见行的末尾,以指示隐藏文本。多条连续的不可见线仅产生一个省略号。

When you use an Outline mode command to make a line invisible (see Outline Visibility Commands), the line disappears from the screen. An ellipsis (three periods in a row) is displayed at the end of the previous visible line, to indicate the hidden text. Multiple consecutive invisible lines produce just one ellipsis.

对行进行操作的编辑命令(例如C-nC-p)会将不可见行的文本视为前一个可见行的一部分。删除可见行末尾的省略号实际上会删除所有以下与省略号相关的不可见文本。

Editing commands that operate on lines, such as C-n and C-p, treat the text of the invisible line as part of the previous visible line. Killing the ellipsis at the end of a visible line really kills all the following invisible text associated with the ellipsis.


26.9.1 大纲次要模式

26.9.1 Outline Minor Mode

大纲次要模式是缓冲区本地次要模式,它提供与主要模式(大纲模式)相同的命令,但可以与其他主要模式结合使用。您可以键入M-x outline-minor-mode以在当前缓冲区中切换大纲次要模式,或使用文件本地变量设置在特定文件中启用它(请参阅文件中的本地变量)。

Outline minor mode is a buffer-local minor mode which provides the same commands as the major mode, Outline mode, but can be used in conjunction with other major modes. You can type M-x outline-minor-mode to toggle Outline minor mode in the current buffer, or use a file-local variable setting to enable it in a specific file (see Local Variables in Files).

主要模式,大纲模式,在 C-c前缀上提供特殊的键绑定。 Outline Minor 模式提供类似的绑定,以 C-c @为前缀;这是为了减少与主要模式的特殊命令的冲突。 (该变量 outline-minor-mode-prefix控制使用的前缀。)

The major mode, Outline mode, provides special key bindings on the C-c prefix. Outline minor mode provides similar bindings with C-c @ as the prefix; this is to reduce the conflicts with the major mode’s special commands. (The variable outline-minor-mode-prefix controls the prefix used.)

如果outline-minor-mode-use-buttons为非nil,则大纲次要模式将使用标题行开头的按钮以及省略号来显示隐藏的部分。单击按钮上的鼠标可切换该部分的显示。如果此变量的值为insert,则按钮将直接插入到缓冲区文本中,因此RET按钮上也会切换该部分的显示,就像单击鼠标一样。insert 不建议在可编辑缓冲区中使用该值,因为它会修改它们。如果值为in-margins,轮廓次要模式将使用窗口边距来指示隐藏的部分。这些按钮可自定义为图标(请参阅图标)。

If outline-minor-mode-use-buttons is non-nil, Outline minor mode will use buttons at the beginning of the heading lines, in addition to ellipsis, to show that a section is hidden. Clicking the mouse on the button toggles display of the section. If the value of this variable is insert, the buttons are inserted directly into the buffer text, so RET on the button will also toggle display of the section, like a mouse click does. Using the value insert is not recommended in editable buffers because it modifies them. If the value is in-margins, Outline minor mode will use the window margins to indicate that a section is hidden. The buttons are customizable as icons (see Icons).

如果outline-minor-mode-cycle用户选项为 non- nil,则在大纲标题行上启用循环可见性的TAB和键(请参阅outline-cycle)。 循环隐藏、显示副标题以及显示当前部分的所有内容。 对整个缓冲区执行相同的操作。 S-TABTABS-TAB

If the outline-minor-mode-cycle user option is non-nil, the TAB and S-TAB keys that cycle the visibility are enabled on the outline heading lines (see outline-cycle). TAB cycles hiding, showing the sub-heading, and showing all for the current section. S-TAB does the same for the entire buffer.


26.9.2 大纲格式

26.9.2 Format of Outlines

大纲模式假定缓冲区中的行有两种类型: 标题行正文行。标题行代表大纲中的主题。标题行以一个或多个星号('*') 人物;星号的数量决定大纲结构中标题的深度。因此,标题行带有一个 '*' 是一个主要话题;所有标题行都带有两个 '*就在它和下一个之间——”*' 标题是其子主题;等等。任何不是标题行的行都是正文行。正文线属于前面的标题线。这是一个例子:

Outline mode assumes that the lines in the buffer are of two types: heading lines and body lines. A heading line represents a topic in the outline. Heading lines start with one or more asterisk (‘*’) characters; the number of asterisks determines the depth of the heading in the outline structure. Thus, a heading line with one ‘*’ is a major topic; all the heading lines with two ‘*’s between it and the next one-‘*’ heading are its subtopics; and so on. Any line that is not a heading line is a body line. Body lines belong with the preceding heading line. Here is an example:

* 食物
这就是身体,
其中谈到了有关食物的话题。

** 美味的食物
这是第二级标头的主体。

** 令人厌恶的食物
这可能有
也有一个身体,与
几行。

*** 宿舍食物

* 庇护所
另一个带有标题行的一级主题。
* Food
This is the body,
which says something about the topic of food.

** Delicious Food
This is the body of the second-level header.

** Distasteful Food
This could have
a body too, with
several lines.

*** Dormitory Food

* Shelter
Another first-level topic with its header line.

标题行和所有随后的正文行统称为条目。标题行与所有后续更深的标题行及其主体行一起称为子树

A heading line together with all following body lines is called collectively an entry. A heading line together with all following deeper heading lines and their body lines is called a subtree.

您可以通过设置变量来自定义区分标题行的标准outline-regexp。 (推荐的方法是在主模式函数中或使用文件局部变量。)开头与此正则表达式匹配的任何行都被视为标题行。在一行内(不是左边距)开始的匹配不计算在内。

You can customize the criterion for distinguishing heading lines by setting the variable outline-regexp. (The recommended ways to do this are in a major mode function or with a file local variable.) Any line whose beginning has a match for this regexp is considered a heading line. Matches that start within a line (not at the left margin) do not count.

匹配文本的长度决定了标题的级别;较长的匹配会产生更深的嵌套级别。因此,例如,如果文本格式化程序具有命令 '@章节','@部分' 和 '@小节' 要将文档分为章节和部分,您可以通过设置 outline-regexp为 '将这些行计为标题行“@chap\\|@\\(sub\\)*节”'。注意技巧:两个词'章节' 和 '部分' 同样长,但通过定义正则表达式仅匹配 '小伙子' 我们确保章节标题上匹配的文本长度较短,以便大纲模式将知道章节包含在章节中。只要没有其他命令以 ' 开头,此操作就有效@chap'。

The length of the matching text determines the level of the heading; longer matches make a more deeply nested level. Thus, for example, if a text formatter has commands ‘@chapter’, ‘@section’ and ‘@subsection’ to divide the document into chapters and sections, you could make those lines count as heading lines by setting outline-regexp to ‘"@chap\\|@\\(sub\\)*section"’. Note the trick: the two words ‘chapter’ and ‘section’ are equally long, but by defining the regexp to match only ‘chap’ we ensure that the length of the text matched on a chapter heading is shorter, so that Outline mode will know that sections are contained in chapters. This works as long as no other command starts with ‘@chap’.

您可以通过设置变量 来显式指定计算标题行级别的规则outline-level。的值outline-level应该是一个不带参数并返回当前标题级别的函数。设置此变量的推荐方法是在主模式命令中或使用文件局部变量。

You can explicitly specify a rule for calculating the level of a heading line by setting the variable outline-level. The value of outline-level should be a function that takes no arguments and returns the level of the current heading. The recommended ways to set this variable are in a major mode command or with a file local variable.


26.9.3 概述运动命令

26.9.3 Outline Motion Commands

轮廓模式提供了特殊的运动命令,可以向后和向前移动到标题线。

Outline mode provides special motion commands that move backward and forward to heading lines.

C-c C-n
C-c C-n

将点移动到下一个可见标题线 ( outline-next-visible-heading)。

Move point to the next visible heading line (outline-next-visible-heading).

C-c C-p
C-c C-p

将点移动到上一个可见标题线 ( outline-previous-visible-heading)。

Move point to the previous visible heading line (outline-previous-visible-heading).

C-c C-f
C-c C-f

将点移动到与 ( ) 上的一个点处于同一级别的下一条可见标题线outline-forward-same-level

Move point to the next visible heading line at the same level as the one point is on (outline-forward-same-level).

C-c C-b
C-c C-b

将点移动到同一级别的上一个可见标题线 ( outline-backward-same-level)。

Move point to the previous visible heading line at the same level (outline-backward-same-level).

C-c C-u
C-c C-u

将点向上移动到较低级别(更具包容性)的可见标题线 ( outline-up-heading)。

Move point up to a lower-level (more inclusive) visible heading line (outline-up-heading).

上述所有命令都接受数字参数作为重复计数。例如C-c C-f,当给定参数时,将在同一级别上向前移动许多可见标题行,而C-c C-u当给定参数时,将移出许多嵌套级别。

All of the above commands accept numeric arguments as repeat counts. For example, C-c C-f, when given an argument, moves forward that many visible heading lines on the same level, and C-c C-u with an argument moves out of that many nested levels.


26.9.4 轮廓可见性命令

26.9.4 Outline Visibility Commands

大纲模式提供了几个命令,用于根据大纲结构临时隐藏或显示缓冲区的某些部分。这些命令不可撤消;它们的效果根本不会被撤消机制记录,因此您可以直接撤消它们(请参阅撤消)。

Outline mode provides several commands for temporarily hiding or revealing parts of the buffer, based on the outline structure. These commands are not undoable; their effects are simply not recorded by the undo mechanism, so you can undo right past them (see Undo).

其中许多命令作用于当前标题行。如果点位于标题线上,则该点是当前标题线;如果点位于正文行上,则当前标题行是最近的前面的标题行。

Many of these commands act on the current heading line. If point is on a heading line, that is the current heading line; if point is on a body line, the current heading line is the nearest preceding header line.

C-c C-c
C-c C-c

使当前标题行的主体不可见 ( outline-hide-entry)。

Make the current heading line’s body invisible (outline-hide-entry).

C-c C-e
C-c C-e

使当前标题行的主体可见 ( outline-show-entry)。

Make the current heading line’s body visible (outline-show-entry).

C-c C-d
C-c C-d

使当前标题下的所有内容不可见,不包括标题本身 ( outline-hide-subtree)。

Make everything under the current heading invisible, not including the heading itself (outline-hide-subtree).

C-c C-s
C-c C-s

使当前标题下的所有内容可见,包括正文、副标题及其正文 ( outline-show-subtree)。

Make everything under the current heading visible, including body, subheadings, and their bodies (outline-show-subtree).

C-c C-l
C-c C-l

使当前标题行及其所有副标题的正文不可见 ( outline-hide-leaves)。

Make the body of the current heading line, and of all its subheadings, invisible (outline-hide-leaves).

C-c C-k
C-c C-k

使当前标题行的所有级别的所有副标题都可见 ( outline-show-branches)。

Make all subheadings of the current heading line, at all levels, visible (outline-show-branches).

C-c C-i
C-c C-i

使当前标题行的直接副标题(下一级)可见 ( outline-show-children)。

Make immediate subheadings (one level down) of the current heading line visible (outline-show-children).

C-c C-t
C-c C-t

使缓冲区中的所有正文线不可见 ( outline-hide-body)。

Make all body lines in the buffer invisible (outline-hide-body).

C-c C-a
C-c C-a

使缓冲区中的所有行都可见 ( outline-show-all)。

Make all lines in the buffer visible (outline-show-all).

C-c C-q
C-c C-q

隐藏除前n层标题行 ( outline-hide-sublevels) 之外的所有内容。

Hide everything except the top n levels of heading lines (outline-hide-sublevels).

C-c C-o
C-c C-o

隐藏除该点所在的标题或正文之外的所有内容,以及从那里到大纲顶层的标题 ( outline-hide-other)。

Hide everything except for the heading or body that point is in, plus the headings leading up from there to the top level of the outline (outline-hide-other).

这些命令中最简单的是C-c C-c ( outline-hide-entry),它隐藏紧随当前标题行的正文行,以及C-c C-e ( outline-show-entry),它显示它们。副标题及其正文不受影响。

The simplest of these commands are C-c C-c (outline-hide-entry), which hides the body lines directly following the current heading line, and C-c C-e (outline-show-entry), which reveals them. Subheadings and their bodies are not affected.

命令C-c C-d( outline-hide-subtree) 和 C-c C-s( outline-show-subtree) 功能更强大。它们适用于当前标题行的子树:其正文、所有子标题(直接和间接)及其所有正文。

The commands C-c C-d (outline-hide-subtree) and C-c C-s (outline-show-subtree) are more powerful. They apply to the current heading line’s subtree: its body, all of its subheadings, both direct and indirect, and all of their bodies.

C-c C-l( )命令outline-hide-leaves隐藏当前标题行的正文及其子树中的所有正文;副标题本身是可见的。命令 C-c C-k( outline-show-branches) 显示副标题,如果它们之前被隐藏(例如,通过C-c C-d)。命令C-c C-i( outline-show-children) 是此命令的较弱版本;它只显示直接的副标题,即下一级的副标题。

The command C-c C-l (outline-hide-leaves) hides the body of the current heading line as well as all the bodies in its subtree; the subheadings themselves are left visible. The command C-c C-k (outline-show-branches) reveals the subheadings, if they had previously been hidden (e.g., by C-c C-d). The command C-c C-i (outline-show-children) is a weaker version of this; it reveals just the direct subheadings, i.e., those one level down.

命令C-c C-o( outline-hide-other) 隐藏除该点所在的条目及其父级(从该条目到大纲中的顶级标题)和顶级标题之外的所有内容。它还显示缓冲区中第一个标题之前的正文行。

The command C-c C-o (outline-hide-other) hides everything except the entry that point is in, plus its parents (the headers leading up from there to top level in the outline) and the top level headings. It also reveals body lines preceding the first heading in the buffer.

其余命令影响整个缓冲区。 C-c C-t ( outline-hide-body) 使所有正文行不可见,以便您只看到大纲结构(作为一个特殊例外,它不会隐藏文件顶部第一个标题行之前的行,即使这些行在技术上是正文行)。 C-c C-a ( outline-show-all) 使所有线条可见。 C-c C-q ( outline-hide-sublevels) 隐藏除当前标题行级别及以上的顶级标题之外的所有标题(如果点不在标题上,则默认为 1);使用数字参数n,它会隐藏除前n层标题行之外的所有内容。请注意,它完全显示了第一个标题之前的所有n 个顶层和正文行。

The remaining commands affect the whole buffer. C-c C-t (outline-hide-body) makes all body lines invisible, so that you see just the outline structure (as a special exception, it will not hide lines at the top of the file, preceding the first header line, even though these are technically body lines). C-c C-a (outline-show-all) makes all lines visible. C-c C-q (outline-hide-sublevels) hides all but the top level headings at and above the level of the current heading line (defaulting to 1 if point is not on a heading); with a numeric argument n, it hides everything except the top n levels of heading lines. Note that it completely reveals all the n top levels and the body lines before the first heading.

Outline 还提供了两个方便的命令来循环每个部分和整个缓冲区的可见性。在标题上键入 TAB( ) 可在“隐藏全部”、“副标题”和“显示全部”状态之间循环当前部分。outline-cycle键入( ) 会在“仅顶级标题”、“所有标题和副标题”和“显示全部”状态之间循环整个缓冲区。 S-TABoutline-cycle-buffer

Outline also provides two convenience commands to cycle the visibility of each section and the whole buffer. Typing TAB (outline-cycle) on a heading cycles the current section between “hide all”, “subheadings”, and “show all” states. Typing S-TAB (outline-cycle-buffer) cycles the whole buffer between “only top-level headings”, “all headings and subheadings”, and “show all” states.

当增量搜索找到大纲模式隐藏的文本时,它会使缓冲区的该部分可见。如果您在该位置退出搜索,文本仍然可见。要切换活动增量搜索是否可以匹配隐藏文本,请键入M-s i。要更改将来搜索的默认值,请自定义选项 search-invisible。 (此选项还会影响query-replace 相关函数处理隐藏文本的方式,请参阅查询替换M-x reveal-mode。)您还可以使用“显示”模式 ( )(一种缓冲区本地次要模式) 在文本中导航时自动使文本可见。

When incremental search finds text that is hidden by Outline mode, it makes that part of the buffer visible. If you exit the search at that position, the text remains visible. To toggle whether or not an active incremental search can match hidden text, type M-s i. To change the default for future searches, customize the option search-invisible. (This option also affects how query-replace and related functions treat hidden text, see Query Replace.) You can also automatically make text visible as you navigate in it by using Reveal mode (M-x reveal-mode), a buffer-local minor mode.

outline-default-state变量控制打开大纲模式后哪些标题可见。如果不是nil,则最初会概述一些标题。如果等于数字,则仅显示直至并包括相应级别的标题。如果等于 outline-show-all,则显示缓冲区的所有文本。如果等于 outline-show-only-headings,则仅显示标题,无论其级别如何。如果等于 lambda 函数或函数名称,则该函数预计会切换标题可见性,并且在启用该模式后将在不带参数的情况下调用。

The outline-default-state variable controls what headings will be visible after Outline mode is turned on. If non-nil, some headings are initially outlined. If equal to a number, show only headings up to and including the corresponding level. If equal to outline-show-all, all text of buffer is shown. If equal to outline-show-only-headings, show only headings, whatever their level is. If equal to a lambda function or function name, this function is expected to toggle headings visibility, and will be called without arguments after the mode is enabled.


26.9.5 在多个视图中查看一个轮廓

26.9.5 Viewing One Outline in Multiple Views

您可以在不同的窗口中同时显示单个轮廓的两个视图。为此,您必须使用创建间接缓冲区 M-x make-indirect-buffer。该命令的第一个参数是现有的大纲缓冲区名称,第二个参数是用于新间接缓冲区的名称。请参阅间接缓冲区

You can display two views of a single outline at the same time, in different windows. To do this, you must create an indirect buffer using M-x make-indirect-buffer. The first argument of this command is the existing outline buffer name, and its second argument is the name to use for the new indirect buffer. See Indirect Buffers.

C-x 4 b一旦存在间接缓冲区,您就可以使用或其他 Emacs 命令以正常方式将其显示在窗口中。显示和隐藏部分文本的大纲模式命令独立地作用于每个缓冲区;因此,每个缓冲区都可以有自己的视图。如果您希望同一轮廓上有两个以上的视图,请创建额外的间接缓冲区。

Once the indirect buffer exists, you can display it in a window in the normal fashion, with C-x 4 b or other Emacs commands. The Outline mode commands to show and hide parts of the text operate on each buffer independently; as a result, each buffer can have its own view. If you want more than two views on the same outline, create additional indirect buffers.


26.9.6 折叠编辑

26.9.6 Folding Editing

Foldout 包通过折叠命令扩展了轮廓模式和轮廓次要模式。折叠的想法是放大轮廓的嵌套部分,同时在更高级别隐藏其相关部分。

The Foldout package extends Outline mode and Outline minor mode with folding commands. The idea of folding is that you zoom in on a nested portion of the outline, while hiding its relatives at higher levels.

考虑一个大纲模式缓冲区,其中隐藏了 1 级标题下的所有文本和副标题。要查看隐藏在这些标题之一下的内容,您可以使用C-c C-e( M-x outline-show-entry) 来显示正文,或C-c C-i显示子(2 级)标题。

Consider an Outline mode buffer with all the text and subheadings under level-1 headings hidden. To look at what is hidden under one of these headings, you could use C-c C-e (M-x outline-show-entry) to expose the body, or C-c C-i to expose the child (level-2) headings.

对于折叠,您可以使用C-c C-z( M-x foldout-zoom-subtree)。这会公开正文和子副标题,并缩小缓冲区,以便只有1 级标题、正文和 2 级标题可见。现在要查看二级标题之一,请将光标置于其上并C-c C-z再次使用。这会暴露 2 级正文及其 3 级子标题,并再次缩小缓冲区范围。您可以根据需要放大连续的副标题。模式行中的字符串显示您已经走了多深。

With Foldout, you use C-c C-z (M-x foldout-zoom-subtree). This exposes the body and child subheadings, and narrows the buffer so that only the level-1 heading, the body and the level-2 headings are visible. Now to look under one of the level-2 headings, position the cursor on it and use C-c C-z again. This exposes the level-2 body and its level-3 child subheadings and narrows the buffer again. Zooming in on successive subheadings can be done as much as you like. A string in the mode line shows how deep you’ve gone.

放大标题时,要仅查看子副标题,请指定数字参数:C-u C-c C-z。子标题的级别数也可以指定(比较M-x outline-show-children),例如, 公开两个级别的子标题。或者,可以使用负参数指定主体: 。与( ) 类似,可以通过指定零参数来扩展整个子树 : 。 M-2 C-c C-zM-- C-c C-zC-c C-sM-x outline-show-subtreeM-0 C-c C-z

When zooming in on a heading, to see only the child subheadings specify a numeric argument: C-u C-c C-z. The number of levels of children can be specified too (compare M-x outline-show-children), e.g., M-2 C-c C-z exposes two levels of child subheadings. Alternatively, the body can be specified with a negative argument: M-- C-c C-z. The whole subtree can be expanded, similarly to C-c C-s (M-x outline-show-subtree), by specifying a zero argument: M-0 C-c C-z.

放大时,您仍然可以使用轮廓模式的曝光和隐藏功能,而不会干扰折叠。此外,由于缓冲区变窄,全局编辑操作将仅影响放大标题下的文本。这对于限制对文档的特定章节或部分的更改很有用。

While you’re zoomed in, you can still use Outline mode’s exposure and hiding functions without disturbing Foldout. Also, since the buffer is narrowed, global editing actions will only affect text under the zoomed-in heading. This is useful for restricting changes to a particular chapter or section of your document.

要取消缩放(退出)折叠,请使用C-c C-x( M-x foldout-exit-fold)。这将隐藏顶级标题下的所有文本和副标题,并使您返回到缓冲区的上一个视图。指定数字参数会退出许多级别的折叠。指定零参数将退出所有折叠。

To unzoom (exit) a fold, use C-c C-x (M-x foldout-exit-fold). This hides all the text and subheadings under the top-level heading and returns you to the previous view of the buffer. Specifying a numeric argument exits that many levels of folds. Specifying a zero argument exits all folds.

要取消折叠缩小而不隐藏文本和副标题,请指定负参数。例如,退出两个折叠并保留文本和副标题。 M--2 C-c C-x

To cancel the narrowing of a fold without hiding the text and subheadings, specify a negative argument. For example, M--2 C-c C-x exits two folds and leaves the text and subheadings exposed.

折叠模式还提供用于进入和退出折叠以及显示和隐藏文本的鼠标命令:

Foldout mode also provides mouse commands for entering and exiting folds, and for showing and hiding text:

C-M-mouse-1放大点击的标题
C-M-mouse-1 zooms in on the heading clicked on
  • 单击:暴露身体。
  • 双击:显示副标题。
  • 三击:显示正文和副标题。
  • 四次单击:暴露整个子树。
  • single click: expose body.
  • double click: expose subheadings.
  • triple click: expose body and subheadings.
  • quad click: expose entire subtree.
C-M-mouse-2显示单击的标题下的文本
C-M-mouse-2 exposes text under the heading clicked on
  • 单击:暴露身体。
  • 双击:显示副标题。
  • 三击:显示正文和副标题。
  • 四次单击:暴露整个子树。
  • single click: expose body.
  • double click: expose subheadings.
  • triple click: expose body and subheadings.
  • quad click: expose entire subtree.
C-M-mouse-3隐藏单击的标题下的文本或退出折叠
C-M-mouse-3 hides text under the heading clicked on or exits fold
  • 单击:隐藏子树。
  • 双击:退出折叠并隐藏文本。
  • 三击:退出折叠而不隐藏文本。
  • 四次单击:退出所有折叠并隐藏文本。
  • single click: hide subtree.
  • double click: exit fold and hide text.
  • triple click: exit fold without hiding text.
  • quad click: exit all folds and hide text.

您可以通过设置;来指定不同的修饰键(而不是 )但如果你已经加载了Ctrl-Meta-foldout-mouse-modifiers折页.el库,您必须重新加载它才能生效。

You can specify different modifier keys (instead of Ctrl-Meta-) by setting foldout-mouse-modifiers; but if you have already loaded the foldout.el library, you must reload it in order for this to take effect.

要使用 Foldout 包,您可以键入;或者您可以通过将以下内容放入您的初始化文件中来安排自动执行此操作: M-x load-library RET foldout RET

To use the Foldout package, you can type M-x load-library RET foldout RET; or you can arrange for to do that automatically by putting the following in your init file:

(with-eval-after-load“大纲”
  (需要“折叠)”
(with-eval-after-load "outline"
  (require 'foldout))

26.10 组织模式

26.10 Org Mode

Org 模式是 Outline 模式的变体,用于使用 Emacs 作为组织者和/或创作系统。名称以扩展名结尾的文件.org在组织模式下打开(请参阅选择文件模式)。要显式切换到组织模式,请键入M-x org-mode

Org mode is a variant of Outline mode for using Emacs as an organizer and/or authoring system. Files with names ending in the extension .org are opened in Org mode (see Choosing File Modes). To explicitly switch to Org mode, type M-x org-mode.

在组织模式下,与大纲模式一样,每个条目都有一个以一个或多个 ' 开头的标题行*' 人物。请参阅大纲格式。此外,任何以 ' 开头的行#' 字符被视为注释。

In Org mode, as in Outline mode, each entry has a heading line that starts with one or more ‘*’ characters. See Format of Outlines. In addition, any line that begins with the ‘#’ character is treated as a comment.

组织模式提供了用于轻松查看和操作大纲结构的命令。这些命令中最简单的是TAB ( org-cycle)。如果在标题行上调用,它将循环显示子树的不同可见性状态:(i) 仅显示该标题行,(ii) 仅显示标题行及其直接子项的标题行(如果有),以及 (iii) )显示整个子树。如果在正文行中调用,则TAB执行全局绑定。

Org mode provides commands for easily viewing and manipulating the outline structure. The simplest of these commands is TAB (org-cycle). If invoked on a heading line, it cycles through the different visibility states of the subtree: (i) showing only that heading line, (ii) showing only the heading line and the heading lines of its direct children, if any, and (iii) showing the entire subtree. If invoked in a body line, the global binding for TAB is executed.

在 Org 模式缓冲区中的任意位置键入( ) 会循环整个大纲结构的可见性,在 (i) 仅显示顶级标题行,(ii) 显示所有标题行但不显示正文行,以及 (iii) 显示所有内容之间。 S-TABorg-shifttab

Typing S-TAB (org-shifttab) anywhere in an Org mode buffer cycles the visibility of the entire outline structure, between (i) showing only top-level heading lines, (ii) showing all heading lines but no body lines, and (iii) showing everything.

您可以通过在标题行上键入 ( ) 或( ) ,在缓冲区中向上或向下移动整个条目,包括其正文行和子树(如果有) 。同样,您可以使用( ) 和 ( )提升或降低标题行。如果在正文行调用这些命令,则执行其全局绑定。 M-UPorg-metaupM-DOWNorg-metadownM-LEFTorg-metaleftM-RIGHTorg-metaright

You can move an entire entry up or down in the buffer, including its body lines and subtree (if any), by typing M-UP (org-metaup) or M-DOWN (org-metadown) on the heading line. Similarly, you can promote or demote a heading line with M-LEFT (org-metaleft) and M-RIGHT (org-metaright). These commands execute their global bindings if invoked on a body line.

以下小节提供了使用 Org 模式作为组织者和创作系统的基本说明。详细信息请参见《组织手册》中的简介

The following subsections give basic instructions for using Org mode as an organizer and as an authoring system. For details, see Introduction in The Org Manual.


26.10.1 Org 作为组织者

26.10.1 Org as an organizer

您可以通过在条目中的任意位置键入( )将组织条目标记为TODO项目。这会添加关键字 'C-c C-torg-todo去做' 到标题行。再次输入C-c C-t会将关键字切换为 '完毕';另一种则C-c C-t完全删除关键字,依此类推。您可以C-c C-t通过变量自定义使用的关键字 org-todo-keywords

You can tag an Org entry as a TODO item by typing C-c C-t (org-todo) anywhere in the entry. This adds the keyword ‘TODO’ to the heading line. Typing C-c C-t again switches the keyword to ‘DONE’; another C-c C-t removes the keyword entirely, and so forth. You can customize the keywords used by C-c C-t via the variable org-todo-keywords.

除了将条目标记为 TODO 之外,您还可以通过在条目中键入C-c C-s( ) 为其附加日期。org-schedule这会通过弹出 Emacs 日历(请参阅日历和日记)来提示输入日期,然后添加标签 '预定',以及选定的日期,位于标题行下方。命令C-c C-d ( org-deadline) 具有相同的效果,只不过它使用标签 DEADLINE

Apart from marking an entry as TODO, you can attach a date to it, by typing C-c C-s (org-schedule) in the entry. This prompts for a date by popping up the Emacs Calendar (see The Calendar and the Diary), and then adds the tag ‘SCHEDULED’, together with the selected date, beneath the heading line. The command C-c C-d (org-deadline) has the same effect, except that it uses the tag DEADLINE.

在 Org 文件中计划了一些 TODO 项目后,您可以通过键入 ( )将该文件添加到议程文件列表中。组织模式旨在让您轻松维护多个议程文件,例如,用于组织生活的不同方面。议程文件列表存储在变量 中。 C-c [org-agenda-file-to-frontorg-agenda-files

Once you have some TODO items planned in an Org file, you can add that file to the list of agenda files by typing C-c [ (org-agenda-file-to-front). Org mode is designed to let you easily maintain multiple agenda files, e.g., for organizing different aspects of your life. The list of agenda files is stored in the variable org-agenda-files.

要查看来自议程文件的项目,请键入M-x org-agenda。此命令会提示您想要查看的内容:本周要做的事情列表、具有特定关键字的 TODO 项目列表等。有关详细信息,请参阅组织手册中的议程视图

To view items coming from your agenda files, type M-x org-agenda. This command prompts for what you want to see: a list of things to do this week, a list of TODO items with specific keywords, etc. See Agenda Views in The Org Manual, for details.


26.10.2 Org 作为创作系统

26.10.2 Org as an authoring system

您可能想要很好地格式化您的组织笔记并为导出和发布做好准备。要导出当前缓冲区,请在 Org 缓冲区中的任意位置键入C-c C-e( )。org-export-dispatch该命令提示输入导出格式;目前支持的格式包括 HTML、LaTeX、Texinfo、OpenDocument(.odt)、iCalendar、Markdown、手册页和 PDF。某些格式(例如 PDF)需要安装某些系统工具。

You may want to format your Org notes nicely and to prepare them for export and publication. To export the current buffer, type C-c C-e (org-export-dispatch) anywhere in an Org buffer. This command prompts for an export format; currently supported formats include HTML, LaTeX, Texinfo, OpenDocument (.odt), iCalendar, Markdown, man-page, and PDF. Some formats, such as PDF, require certain system tools to be installed.

要将多个文件一次导出到本地或通过网络的特定目录,您必须通过变量 定义项目列表org-publish-project-alist。有关详细信息,请参阅其文档。

To export several files at once to a specific directory, either locally or over the network, you must define a list of projects through the variable org-publish-project-alist. See its documentation for details.

Org 支持简单的标记方案,用于将文本格式应用于导出的文档:

Org supports a simple markup scheme for applying text formatting to exported documents:

- 这段文字是/强调/
- 此文本*为粗体*
- 此文本带有_下划线_
- 此文本使用=电传打字机字体=

#+开始引用
“这是一句引言。”
#+结束引用

#+开始示例
这是一个例子。
#+结束示例
- This text is /emphasized/
- This text is *in bold*
- This text is _underlined_
- This text uses =a teletype font=

#+begin_quote
``This is a quote.''
#+end_quote

#+begin_example
This is an example.
#+end_example

有关更多详细信息,请参阅组织手册中的导出组织手册中的发布

For further details, Exporting in The Org Manual, and Publishing in The Org Manual.


26.11 TeX模式

26.11 TeX Mode

TeX 是一个强大的文本格式化程序,由 Donald Knuth 编写;与 GNU Emacs 一样,它是免费软件。 TeX 格式有多种变体,包括 LaTeX,TeX 的简化输入格式; DocTeX,一种特殊的文件格式,用于编写 LaTeX 源代码,将源代码与文档相结合;和 SliTeX,LaTeX 13的一种过时的特殊形式。

TeX is a powerful text formatter written by Donald Knuth; like GNU Emacs, it is free software. The TeX format has several variants, including LaTeX, a simplified input format for TeX; DocTeX, a special file format in which the LaTeX sources are written, combining sources with documentation; and SliTeX, an obsolete special form of LaTeX13.

Emacs 为每个变体提供了 TeX 主要模式:Plain TeX 模式、LaTeX 模式、DocTeX 模式和 SliTeX 模式。 Emacs 通过查看缓冲区的内容来选择适当的模式。 (这是通过调用命令来完成的tex-mode,该命令通常在您访问类似 TeX 的文件时自动调用。请参阅选择文件模式。)如果内容不足以确定这一点,Emacs 将选择由变量指定的模式 tex-default-mode;它的默认值为latex-mode。如果 Emacs 没有猜对,您可以使用命令plain-tex-modelatex-modeslitex-mode或 来选择 TeX 模式的正确变体doctex-mode

Emacs provides a TeX major mode for each of these variants: Plain TeX mode, LaTeX mode, DocTeX mode, and SliTeX mode. Emacs selects the appropriate mode by looking at the contents of the buffer. (This is done by invoking the tex-mode command, which is normally called automatically when you visit a TeX-like file. See Choosing File Modes.) If the contents are insufficient to determine this, Emacs chooses the mode specified by the variable tex-default-mode; its default value is latex-mode. If Emacs does not guess right, you can select the correct variant of TeX mode using the commands plain-tex-mode, latex-mode, slitex-mode, or doctex-mode.

以下部分记录了 TeX 模式及其变体的功能。还有其他几个与 TeX 相关的 Emacs 软件包,本手册中未记录这些软件包:

The following sections document the features of TeX mode and its variants. There are several other TeX-related Emacs packages, which are not documented in this manual:

  • BibTeX 模式是 BibTeX 文件的主要模式,通常用于保存 LaTeX 文档的参考书目。有关更多信息,请参阅命令的文档字符串 bibtex-mode
  • BibTeX mode is a major mode for BibTeX files, which are commonly used for keeping bibliographic references for LaTeX documents. For more information, see the documentation string for the command bibtex-mode.
  • RefTeX 包提供了一个次要模式,可以与 LaTeX 模式一起使用来管理书目参考。有关详细信息,请参阅随 Emacs 一起分发的 RefTeX Info 手册。
  • The RefTeX package provides a minor mode which can be used with LaTeX mode to manage bibliographic references. For more information, see the RefTeX Info manual, which is distributed with Emacs.
  • AUCTeX 包提供了用于编辑 TeX 及其相关格式的更高级功能,包括在 Emacs 缓冲区中预览 TeX 方程的能力。与 BibTeX 模式和 RefTeX 包不同,AUCTeX 默认情况下不随 Emacs 一起分发。可以通过 Package 菜单下载它(请参阅Emacs Lisp Packages);安装后,请参阅软件包中包含的 AUCTeX 手册。
  • The AUCTeX package provides more advanced features for editing TeX and its related formats, including the ability to preview TeX equations within Emacs buffers. Unlike BibTeX mode and the RefTeX package, AUCTeX is not distributed with Emacs by default. It can be downloaded via the Package Menu (see Emacs Lisp Packages); once installed, see the AUCTeX manual, which is included with the package.

26.11.1 TeX 编辑命令

26.11.1 TeX Editing Commands

"
"

根据上下文插入 '``' 或者 '' 或者 ''(tex-insert-quote)。

Insert, according to context, either ‘``’ or ‘"’ or ‘''’ (tex-insert-quote).

C-j
C-j

插入段落分隔符(两个换行符)并检查前一段是否有不平衡的大括号或美元符号 ( tex-terminate-paragraph)。

Insert a paragraph break (two newlines) and check the previous paragraph for unbalanced braces or dollar signs (tex-terminate-paragraph).

M-x tex-validate-region
M-x tex-validate-region

检查该区域中的每个段落是否有不平衡的大括号或美元符号。

Check each paragraph in the region for unbalanced braces or dollar signs.

C-c {
C-c {

插入 '{}' 以及它们之间的位置点 ( tex-insert-braces)。

Insert ‘{}’ and position point between them (tex-insert-braces).

C-c }
C-c }

向前移动到下一个不匹配的右大括号 ( up-list)。

Move forward past the next unmatched close brace (up-list).

在 TeX 中,字符 '' 通常不使用;相反,引号以 ' 开头``' 并以 ' 结尾'。因此,TeX 模式将"密钥与tex-insert-quote 命令绑定。这插入 '``' 在空格或左大括号之后,'' 在反斜杠之后,并且 '' 在任何其他字符之后。

In TeX, the character ‘"’ is not normally used; instead, quotations begin with ‘``’ and end with ‘''’. TeX mode therefore binds the " key to the tex-insert-quote command. This inserts ‘``’ after whitespace or an open brace, ‘"’ after a backslash, and ‘''’ after any other character.

作为一个特殊的例外,如果您"在 point 之前的文本是 '``' 或者 '',Emacs 将前面的文本替换为单个 '' 特点。因此,您可以键入 ""插入 '',如果您需要这样做的话。 (您也可以使用C-q "插入此字符。)

As a special exception, if you type " when the text before point is either ‘``’ or ‘''’, Emacs replaces that preceding text with a single ‘"’ character. You can therefore type "" to insert ‘"’, should you ever need to do so. (You can also use C-q " to insert this character.)

在 TeX 模式下,'$' 有一个特殊的语法代码,试图理解 TeX 数学模式分隔符的匹配方式。当你插入一个 '$'表示退出数学模式,匹配的位置'$' 进入数学模式会显示一秒钟。此功能与显示与插入的右大括号相匹配的左大括号相同。然而,没有办法判断是否“$' 进入或离开数学模式;所以当你插入一个 '$' 进入数学模式,上一个 '$' 位置显示为好像是匹配的,即使它们实际上不相关。

In TeX mode, ‘$’ has a special syntax code which attempts to understand the way TeX math mode delimiters match. When you insert a ‘$’ that is meant to exit math mode, the position of the matching ‘$’ that entered math mode is displayed for a second. This is the same feature that displays the open brace that matches a close brace that is inserted. However, there is no way to tell whether a ‘$’ enters math mode or leaves it; so when you insert a ‘$’ that enters math mode, the previous ‘$’ position is shown as if it were a match, even though they are actually unrelated.

TeX 使用大括号作为必须匹配的分隔符。一些使用者更喜欢始终保持牙套平衡,而不是单独插入它们。使用C-c {( tex-insert-braces) 插入一对大括号。它在两个大括号之间留下点,以便您可以插入属于内部的文本。然后,使用命令C-c } ( up-list) 向前移动到右大括号之外。您还可以C-c {在标记一些文本后调用:然后该命令将标记的文本括在大括号中。

TeX uses braces as delimiters that must match. Some users prefer to keep braces balanced at all times, rather than inserting them singly. Use C-c { (tex-insert-braces) to insert a pair of braces. It leaves point between the two braces so you can insert the text that belongs inside. Afterward, use the command C-c } (up-list) to move forward past the close brace. You can also invoke C-c { after marking some text: then the command encloses the marked text in braces.

有两个命令用于检查大括号的匹配。 C-j( tex-terminate-paragraph) 检查 point 之前的段落,并插入两个换行符以开始一个新段落。如果发现任何不匹配,它会在回显区域输出一条消息。 M-x tex-validate-region逐段检查一个区域。错误列在*发生*缓冲;您可以在该缓冲区中使用常用的发生模式命令(例如C-c C-c)来访问特定的不匹配(请参阅其他搜索和循环命令)。

There are two commands for checking the matching of braces. C-j (tex-terminate-paragraph) checks the paragraph before point, and inserts two newlines to start a new paragraph. It outputs a message in the echo area if any mismatch is found. M-x tex-validate-region checks a region, paragraph by paragraph. The errors are listed in an *Occur* buffer; you can use the usual Occur mode commands in that buffer, such as C-c C-c, to visit a particular mismatch (see Other Search-and-Loop Commands).

请注意,Emacs 命令在 TeX 模式下计算方括号和括号,而不仅仅是大括号。出于检查 TeX 语法的目的,这并不严格正确。然而,圆括号和方括号很可能在文本中用作匹配分隔符,并且对于各种运动命令和自动匹配显示来说,使用它们非常有用。

Note that Emacs commands count square brackets and parentheses in TeX mode, not just braces. This is not strictly correct for the purpose of checking TeX syntax. However, parentheses and square brackets are likely to be used in text as matching delimiters, and it is useful for the various motion commands and automatic match display to work with them.


26.11.2 LaTeX 编辑命令

26.11.2 LaTeX Editing Commands

LaTeX 模式提供了一些不适用于纯 TeX 的额外功能:

LaTeX mode provides a few extra features not applicable to plain TeX:

C-c C-o
C-c C-o

插入 '\开始' 和 '\结尾' 对于 LaTeX 块并在它们之间的线上定位点 ( latex-insert-block)。

Insert ‘\begin’ and ‘\end’ for LaTeX block and position point on a line between them (latex-insert-block).

C-c C-e
C-c C-e

关闭尚未关闭的最里面的 LaTeX 块 ( latex-close-block)。

Close the innermost LaTeX block not yet closed (latex-close-block).

在 LaTeX 输入中,'\开始' 和 '\结尾' 标签用于对文本块进行分组。要插入块,请键入C-c C-o ( latex-insert-block)。这会提示输入块类型,并插入适当的匹配'\开始' 和 '\结尾' 标签,在两者之间留下一个空行并在那里移动点。

In LaTeX input, ‘\begin’ and ‘\end’ tags are used to group blocks of text. To insert a block, type C-c C-o (latex-insert-block). This prompts for a block type, and inserts the appropriate matching ‘\begin’ and ‘\end’ tags, leaving a blank line between the two and moving point there.

当输入块类型参数时C-c C-o,您可以使用常用的完成命令(请参阅完成)。默认完成列表包含标准 LaTeX 块类型。如果您需要其他块类型来完成,请自定义列表变量latex-block-names

When entering the block type argument to C-c C-o, you can use the usual completion commands (see Completion). The default completion list contains the standard LaTeX block types. If you want additional block types for completion, customize the list variable latex-block-names.

在 LaTeX 输入中,'\开始' 和 '\结尾' 标签必须平衡。您可以使用C-c C-e( latex-close-block) 插入 '\结尾' 与最后一个不匹配的标签相匹配 '\开始'。它还缩进了 '\结尾'来匹配相应的'\开始',并在 ' 之后插入换行符\结尾' 如果点位于行的开头,则标记。次要模式latex-electric-env-pair-mode 会自动插入一个 '\结尾' 或者 '\开始' 当您键入相应的标签时,就会为您添加标签。

In LaTeX input, ‘\begin’ and ‘\end’ tags must balance. You can use C-c C-e (latex-close-block) to insert an ‘\end’ tag which matches the last unmatched ‘\begin’. It also indents the ‘\end’ to match the corresponding ‘\begin’, and inserts a newline after the ‘\end’ tag if point is at the beginning of a line. The minor mode latex-electric-env-pair-mode automatically inserts an ‘\end’ or ‘\begin’ tag for you when you type the corresponding one.


26.11.3 TeX 打印命令

26.11.3 TeX Printing Commands

您可以将 TeX 作为 Emacs 的子进程来调用,提供缓冲区的全部内容或仅提供其中的一部分(例如,较大文档的一章)。

You can invoke TeX as a subprocess of Emacs, supplying either the entire contents of the buffer or just part of it (e.g., one chapter of a larger document).

C-c C-b
C-c C-b

对整个当前缓冲区调用 TeX ( tex-buffer)。

Invoke TeX on the entire current buffer (tex-buffer).

C-c C-r
C-c C-r

在当前区域以及缓冲区的标头 ( tex-region) 上调用 TeX。

Invoke TeX on the current region, together with the buffer’s header (tex-region).

C-c C-f
C-c C-f

对当前文件调用 TeX ( tex-file)。

Invoke TeX on the current file (tex-file).

C-c C-v
C-c C-v

C-c C-b预览最后一个、C-c C-rC-c C-f命令 ( )的输出tex-view

Preview the output from the last C-c C-b, C-c C-r, or C-c C-f command (tex-view).

C-c C-p
C-c C-p

C-c C-b打印最后一个、C-c C-rC-c C-f命令 ( )的输出tex-print

Print the output from the last C-c C-b, C-c C-r, or C-c C-f command (tex-print).

C-c TAB
C-c TAB

对当前文件调用 BibTeX ( tex-bibtex-file)。

Invoke BibTeX on the current file (tex-bibtex-file).

C-c C-l
C-c C-l

将显示 TeX 输出的窗口居中,以便可以看到最后一行 ( tex-recenter-output-buffer)。

Recenter the window showing output from TeX so that the last line can be seen (tex-recenter-output-buffer).

C-c C-k
C-c C-k

终止 TeX 子进程 ( tex-kill-job)。

Kill the TeX subprocess (tex-kill-job).

C-c C-c
C-c C-c

对整个当前缓冲区调用其他编译命令 ( tex-compile)。

Invoke some other compilation command on the entire current buffer (tex-compile).

要通过 TeX 传递当前缓冲区,请键入C-c C-b ( tex-buffer)。格式化的输出放入临时文件中,通常是.dvi文件。然后,您可以键入C-c C-v ( tex-view) 启动外部程序(例如 xdvi)来查看此输出文件。您还可以键入C-c C-p( tex-print) 以打印输出文件的硬拷贝。

To pass the current buffer through TeX, type C-c C-b (tex-buffer). The formatted output goes in a temporary file, normally a .dvi file. Afterwards, you can type C-c C-v (tex-view) to launch an external program, such as xdvi, to view this output file. You can also type C-c C-p (tex-print) to print a hardcopy of the output file.

默认情况下,C-c C-b在当前目录中运行 TeX。 TeX 的输出也在此目录中创建。要在不同的目录中运行 TeX,请将变量更改tex-directory为所需的目录。如果您的环境变量TEXINPUTS 包含相对名称,或者您的文件包含 '\输入' 具有相对文件名的命令,则 tex-directory 必须如此".",否则您将得到错误的结果。否则,指定其他目录是安全的,例如"/tmp".

By default, C-c C-b runs TeX in the current directory. The output of TeX is also created in this directory. To run TeX in a different directory, change the variable tex-directory to the desired directory. If your environment variable TEXINPUTS contains relative names, or if your files contain ‘\input’ commands with relative file names, then tex-directory must be "." or you will get the wrong results. Otherwise, it is safe to specify some other directory, such as "/tmp".

缓冲区的 TeX 变体决定了C-c C-b实际运行的 shell 命令。在 Plain TeX 模式下,它由变量 指定tex-run-command,默认为"tex"。在 LaTeX 模式下,由 指定latex-run-command,默认为"latex"C-c C-v运行查看的shell 命令.dvi输出由变量 决定 tex-dvi-view-command,与 TeX 变体无关。运行以打印输出的 shell 命令C-c C-p由变量 确定tex-dvi-print-command。可以将该变量 tex-print-file-extension设置为查看和打印 TeX 编译文件所需的文件扩展名。例如,您可以将其设置为.pdf,并相应地更新 tex-dvi-view-commandtex-dvi-print-command ,以及latex-run-commandtex-run-command

The buffer’s TeX variant determines what shell command C-c C-b actually runs. In Plain TeX mode, it is specified by the variable tex-run-command, which defaults to "tex". In LaTeX mode, it is specified by latex-run-command, which defaults to "latex". The shell command that C-c C-v runs to view the .dvi output is determined by the variable tex-dvi-view-command, regardless of the TeX variant. The shell command that C-c C-p runs to print the output is determined by the variable tex-dvi-print-command. The variable tex-print-file-extension can be set to the required file extension for viewing and printing TeX-compiled files. For example, you can set it to .pdf, and update tex-dvi-view-command and tex-dvi-print-command accordingly, as well as latex-run-command or tex-run-command.

通常,Emacs 会自动将输出文件名附加到上一段中描述的 shell 命令字符串中。例如,如果tex-dvi-view-command"xdvi"C-c C-v则运行。然而,在某些情况下,文件名需要嵌入到命令中,例如,如果您需要将文件名作为参数提供给一个命令,而该命令的输出通过管道传输到另一个命令。您可以使用 ' 指定文件名的放置位置xdvi output-file-name*' 在命令字符串中。例如,

Normally, Emacs automatically appends the output file name to the shell command strings described in the preceding paragraph. For example, if tex-dvi-view-command is "xdvi", C-c C-v runs xdvi output-file-name. In some cases, however, the file name needs to be embedded in the command, e.g., if you need to provide the file name as an argument to one command whose output is piped to another. You can specify where to put the file name with ‘*’ in the command string. For example,

(setq tex-dvi-print-command "dvips -f * | lpr")
(setq tex-dvi-print-command "dvips -f * | lpr")

TeX 的终端输出(包括所有错误消息)出现在名为*tex-shell*。如果 TeX 出现错误,您可以切换到此缓冲区并向其提供输入(这与 Shell 模式下的工作方式相同;请参阅Interactive Subshel​​l)。无需切换到此缓冲区,您可以通过键入滚动它,以便其最后一行可见 C-c C-l

The terminal output from TeX, including any error messages, appears in a buffer called *tex-shell*. If TeX gets an error, you can switch to this buffer and feed it input (this works as in Shell mode; see Interactive Subshell). Without switching to this buffer you can scroll it so that its last line is visible by typing C-c C-l.

如果您发现 TeX 进程的输出不再有用,请键入C-c C-k( ) 来终止该进程。tex-kill-job使用C-c C-bC-c C-r同时终止任何仍在运行的 TeX 进程。

Type C-c C-k (tex-kill-job) to kill the TeX process if you see that its output is no longer useful. Using C-c C-b or C-c C-r also kills any TeX process still running.

C-c C-r您还可以通过键入( tex-region)通过 TeX 传递任意区域 。然而,这很棘手,因为大多数 TeX 输入文件在开头都包含设置参数和定义宏的命令,如果没有这些命令,文件的后续部分将无法正确格式化。为了解决这个问题,C-c C-r允许您指定文件的一部分包含必要的命令;它作为 TeX 输入的一部分包含在指定区域之前。文件的指定部分称为文件

You can also pass an arbitrary region through TeX by typing C-c C-r (tex-region). This is tricky, however, because most files of TeX input contain commands at the beginning to set parameters and define macros, without which no later part of the file will format correctly. To solve this problem, C-c C-r allows you to designate a part of the file as containing essential commands; it is included before the specified region as part of the input to TeX. The designated part of the file is called the header.

要在 Plain TeX 模式下指示标头的边界,请在文件中插入两个特殊字符串。插入 '%**标题开始' 在标题之前,并且 '%**标题结束’之后。每个字符串必须完全出现在一行上,但该行之前或之后可能有其他文本。包含两个字符串的行包含在标题中。如果 '%**标题开始' 没有出现在缓冲区的前 100 行内,C-c C-r​​假设没有标题。

To indicate the bounds of the header in Plain TeX mode, you insert two special strings in the file. Insert ‘%**start of header’ before the header, and ‘%**end of header’ after it. Each string must appear entirely on one line, but there may be other text on the line before or after. The lines containing the two strings are included in the header. If ‘%**start of header’ does not appear within the first 100 lines of the buffer, C-c C-r assumes that there is no header.

在 LaTeX 模式下,标题以 ' 开头\文档类' 或者 '\文档样式' 并以 ' 结尾\开始{文档}'。这些是 LaTeX 要求您在任何情况下都使用的命令,因此不需要执行任何特殊操作来识别标头。

In LaTeX mode, the header begins with ‘\documentclass’ or ‘\documentstyle’ and ends with ‘\begin{document}’. These are commands that LaTeX requires you to use in any case, so nothing special needs to be done to identify the header.

命令 ( tex-buffer) 和 ( tex-region) 在临时目录中完成所有工作,并且没有 TeX 交叉引用所需的任何可用辅助文件;这些命令通常不适合运行最终副本,其中所有交叉引用都需要正确。

The commands (tex-buffer) and (tex-region) do all of their work in a temporary directory, and do not have available any of the auxiliary files needed by TeX for cross-references; these commands are generally not suitable for running the final copy in which all of the cross-references need to be correct.

当您需要辅助文件进行交叉引用时,请使用C-c C-f( tex-file),它会在当前缓冲区的文件(位于该文件的目录中)上运行 TeX。在运行 TeX 之前,它会保存所有修改过的缓冲区。通常,您需要使用 ( tex-file) 两次才能获得正确的交叉引用。

When you want the auxiliary files for cross references, use C-c C-f (tex-file) which runs TeX on the current buffer’s file, in that file’s directory. Before running TeX, it offers to save any modified buffers. Generally, you need to use (tex-file) twice to get the cross-references right.

变量的值tex-start-options指定 TeX 运行的选项。

The value of the variable tex-start-options specifies options for the TeX run.

该变量的值tex-start-commands指定用于启动 TeX 的 TeX 命令。默认值使 TeX 以不间断模式运行。要以交互方式运行 TeX,请将变量设置为 ""

The value of the variable tex-start-commands specifies TeX commands for starting TeX. The default value causes TeX to run in nonstop mode. To run TeX interactively, set the variable to "".

大型 TeX 文档通常分为多个文件 — 一个主文件,加上子文件。在子文件上运行 TeX 通常不起作用;你必须在主文件上运行它。为了 tex-file在编辑子文件时有用,您可以将该变量设置tex-main-file为主文件的名称。然后 tex-file在该文件上运行 TeX。

Large TeX documents are often split into several files—one main file, plus subfiles. Running TeX on a subfile typically does not work; you have to run it on the main file. In order to make tex-file useful when you are editing a subfile, you can set the variable tex-main-file to the name of the main file. Then tex-file runs TeX on that file.

最方便的使用方法tex-main-file是在每个子文件的局部变量列表中指定它。请参阅文件中的局部变量

The most convenient way to use tex-main-file is to specify it in a local variable list in each of the subfiles. See Local Variables in Files.

对于 LaTeX 文件,您可以使用 BibTeX 来处理当前缓冲区文件的辅助文件。 BibTeX 在数据库中查找参考书目引文,并为参考书目部分准备引用的参考文献。命令 ( ) 运行 shell 命令 ( ) 来生成 'C-c TABtex-bibtex-filetex-bibtex-command.bbl' 当前缓冲区文件的文件。一般来说,您需要执行一次C-c C-f ( tex-file) 来生成 '.aux' 文件,然后执行 ( ),然后再重复 ( ) 两次以获得正确的交叉引用。 C-c TABtex-bibtex-fileC-c C-ftex-file

For LaTeX files, you can use BibTeX to process the auxiliary file for the current buffer’s file. BibTeX looks up bibliographic citations in a data base and prepares the cited references for the bibliography section. The command C-c TAB (tex-bibtex-file) runs the shell command (tex-bibtex-command) to produce a ‘.bbl’ file for the current buffer’s file. Generally, you need to do C-c C-f (tex-file) once to generate the ‘.aux’ file, then do C-c TAB (tex-bibtex-file), and then repeat C-c C-f (tex-file) twice more to get the cross-references correct.

要在当前 TeX 缓冲区上调用其他编译程序,请键入C-c C-c( tex-compile)。该命令知道如何将参数传递给许多常见程序,包括 pdf乳胶,雅普,xdvi, 和维普斯。您可以使用标准完成键选择所需的编译程序(请参阅完成)。

To invoke some other compilation program on the current TeX buffer, type C-c C-c (tex-compile). This command knows how to pass arguments to many common programs, including pdflatex, yap, xdvi, and dvips. You can select your desired compilation program using the standard completion keys (see Completion).


26.11.4 TeX 模式杂项

26.11.4 TeX Mode Miscellany

输入 TeX 模式的任何变体都会运行 hooks text-mode-hooktex-mode-hook.然后它运行 plain-tex-mode-hookdoctex-mode-hooklatex-mode-hookslitex-mode-hook,以合适的为准。启动 TeX shell 运行钩子 tex-shell-hook。请参阅钩子

Entering any variant of TeX mode runs the hooks text-mode-hook and tex-mode-hook. Then it runs either plain-tex-mode-hook, doctex-mode-hook, latex-mode-hook, or slitex-mode-hook, whichever is appropriate. Starting the TeX shell runs the hook tex-shell-hook. See Hooks.

命令M-x iso-iso2texM-x iso-tex2isoM-x iso-iso2gtexM-x iso-gtex2iso用于在 Latin-1 编码文件和 TeX 编码等效文件之间进行转换。

The commands M-x iso-iso2tex, M-x iso-tex2iso, M-x iso-iso2gtex and M-x iso-gtex2iso can be used to convert between Latin-1 encoded files and TeX-encoded equivalents.


26.12 SGML和HTML模式

26.12 SGML and HTML Modes

SGML 和 HTML 的主要模式提供缩进支持和用于操作标签的命令。

The major modes for SGML and HTML provide indentation support and commands for operating on tags.

HTML 由两种模式组成,一种是基本模式,称为 html-modeSGML 模式的稍微定制的变体。另一个默认用于 HTML 文件,称为 mhtml-mode,并尝试正确处理<script>元素中包含的 Javascript 和元素中嵌入的 CSS <style>

HTML consists of two modes—one, a basic mode called html-mode is a slightly customized variant of SGML mode. The other, which is used by default for HTML files, is called mhtml-mode, and attempts to properly handle Javascript enclosed in a <script> element and CSS embedded in a <style> element.

C-c C-n
C-c C-n

交互式指定特殊字符并插入 SGML '&'-该字符的命令 ( sgml-name-char)。

Interactively specify a special character and insert the SGML ‘&’-command for that character (sgml-name-char).

C-c C-t
C-c C-t

以交互方式指定标签及其属性 ( sgml-tag)。此命令要求您提供标签名称和属性值,然后插入开始标签和结束标签,并在它们之间留下点。

使用前缀参数n,该命令将标记放置 在点后缓冲区中已存在的n个单词周围。每当一个区域处于活动状态时,它就会在该区域周围放置标签(当瞬态标记模式关闭时,它会在提供 -1 的数字参数时执行此操作。)

Interactively specify a tag and its attributes (sgml-tag). This command asks you for a tag name and for the attribute values, then inserts both the opening tag and the closing tag, leaving point between them.

With a prefix argument n, the command puts the tag around the n words already present in the buffer after point. Whenever a region is active, it puts the tag around the region (when Transient Mark mode is off, it does this when a numeric argument of −1 is supplied.)

C-c C-a
C-c C-a

以交互方式插入当前标签的属性值 ( sgml-attributes)。

Interactively insert attribute values for the current tag (sgml-attributes).

C-c C-f
C-c C-f

跳过平衡标签组(从开始标签延伸到其相应的结束标签)( sgml-skip-tag-forward)。数字参数充当重复计数。

Skip across a balanced tag group (which extends from an opening tag through its corresponding closing tag) (sgml-skip-tag-forward). A numeric argument acts as a repeat count.

C-c C-b
C-c C-b

向后跳过平衡标签组(从开始标签延伸到其相应的结束标签)( sgml-skip-tag-backward)。数字参数充当重复计数。

Skip backward across a balanced tag group (which extends from an opening tag through its corresponding closing tag) (sgml-skip-tag-backward). A numeric argument acts as a repeat count.

C-c C-d
C-c C-d

删除该点或之后的标记,并删除匹配的标记(sgml-delete-tag)。如果该点或该点之后的标签是开始标签,则也删除结束标签;如果它是结束标记,则也删除开始标记。

Delete the tag at or after point, and delete the matching tag too (sgml-delete-tag). If the tag at or after point is an opening tag, delete the closing tag too; if it is a closing tag, delete the opening tag too.

C-c ? tag RET
C-c ? tag RET

显示标签tag ( )的含义的描述sgml-tag-help。如果参数标签为空,则描述该点的标签。

Display a description of the meaning of tag tag (sgml-tag-help). If the argument tag is empty, describe the tag at point.

C-c /
C-c /

为最里面的未终止标记插入结束标记 ( sgml-close-tag)。如果在标签或注释中调用,请将其关闭而不是插入关闭标签。

Insert a close tag for the innermost unterminated tag (sgml-close-tag). If called within a tag or a comment, close it instead of inserting a close tag.

C-c 8
C-c 8

切换次要模式,在该模式中 Latin-1 字符插入代表它们的相应 SGML 命令,而不是字符本身 ( sgml-name-8bit-mode)。

Toggle a minor mode in which Latin-1 characters insert the corresponding SGML commands that stand for them, instead of the characters themselves (sgml-name-8bit-mode).

C-c C-v
C-c C-v

运行 shell 命令(必须指定)以将当前缓冲区验证为 SGML ( sgml-validate)。 (在 HTML 模式下,此按键序列运行不同的命令。)

Run a shell command (which you must specify) to validate the current buffer as SGML (sgml-validate). (In HTML mode this key sequence runs a different command.)

C-c TAB
C-c TAB

切换缓冲区中现有标签的可见性。这可以用作廉价预览 ( sgml-tags-invisible)。

Toggle the visibility of existing tags in the buffer. This can be used as a cheap preview (sgml-tags-invisible).

编辑 XML 文档的主要模式称为 nXML 模式。这是一个强大的主要模式,可以识别许多现有的 XML 模式,并使用它们通过 提供 XML 元素的补全 ,以及带有错误突出显示的动态 XML 验证。要在现有缓冲区中启用 nXML 模式,请键入或等效的。 Emacs 对具有扩展名的文件使用 nXML 模式 M-TABM-x nxml-modeM-x xml-mode.xml。对于 XHTML 文件,其扩展名为.xhtml,Emacs默认使用HTML模式;您可以通过自定义变量使其使用 nXML 模式auto-mode-alist(请参阅选择文件模式)。 nXML 模式在随 Emacs 一起发布的 Info 手册中进行了描述。

The major mode for editing XML documents is called nXML mode. This is a powerful major mode that can recognize many existing XML schemas and use them to provide completion of XML elements via M-TAB, as well as on-the-fly XML validation with error highlighting. To enable nXML mode in an existing buffer, type M-x nxml-mode, or, equivalently, M-x xml-mode. Emacs uses nXML mode for files which have the extension .xml. For XHTML files, which have the extension .xhtml, Emacs uses HTML mode by default; you can make it use nXML mode by customizing the variable auto-mode-alist (see Choosing File Modes). nXML mode is described in an Info manual, which is distributed with Emacs.

您可以选择使用功能较弱的 SGML 模式来编辑 XML,因为 XML 是 SGML 的严格子集。要在现有缓冲区中启用 SGML 模式,请键入M-x sgml-mode。在启用 SGML 模式时,Emacs 检查缓冲区以确定它是否是 XML;如果是,它将变量设置sgml-xml-mode为非值nil。这会导致 SGML 模式的标签插入命令(如上所述)始终插入显式结束标签。

You may choose to use the less powerful SGML mode for editing XML, since XML is a strict subset of SGML. To enable SGML mode in an existing buffer, type M-x sgml-mode. On enabling SGML mode, Emacs examines the buffer to determine whether it is XML; if so, it sets the variable sgml-xml-mode to a non-nil value. This causes SGML mode’s tag insertion commands, described above, to always insert explicit closing tags as well.


26.13 Nroff模式

26.13 Nroff Mode

Nroff 模式是从文本模式派生的一种主要模式,专门用于编辑nroff 文件(例如Unix 手册页)。键入 M-x nroff-mode以进入此模式。进入 Nroff 模式运行 hook text-mode-hook,然后nroff-mode-hook (参见Hooks)。

Nroff mode, a major mode derived from Text mode, is specialized for editing nroff files (e.g., Unix man pages). Type M-x nroff-mode to enter this mode. Entering Nroff mode runs the hook text-mode-hook, then nroff-mode-hook (see Hooks).

在 Nroff 模式下,nroff 命令行被视为段落分隔符,页面由 ' 分隔.bp' 命令和注释以反斜杠双引号开头。它还定义了这些命令:

In Nroff mode, nroff command lines are treated as paragraph separators, pages are separated by ‘.bp’ commands, and comments start with backslash-doublequote. It also defines these commands:

M-n
M-n

移至不是 nroff 命令的下一行的开头 ( nroff-forward-text-line)。参数是重复计数。

Move to the beginning of the next line that isn’t an nroff command (nroff-forward-text-line). An argument is a repeat count.

M-p
M-p

喜欢M-n但向上移动 ( nroff-backward-text-line)。

Like M-n but move up (nroff-backward-text-line).

M-?
M-?

在回显区域中显示区域 ( ) 中的文本行数(不是 nroff 命令的行)nroff-count-text-lines

Displays in the echo area the number of text lines (lines that are not nroff commands) in the region (nroff-count-text-lines).

Electric Nroff 模式是一种缓冲区本地次要模式,可与 Nroff 模式一起使用。要切换此次要模式,请键入M-x nroff-electric-mode(请参阅次要模式)。当该模式打开时,每次键入RET结束包含打开某种分组的 nroff 命令的行时,用于关闭该分组的 nroff 命令会自动插入到下一行。

Electric Nroff mode is a buffer-local minor mode that can be used with Nroff mode. To toggle this minor mode, type M-x nroff-electric-mode (see Minor Modes). When the mode is on, each time you type RET to end a line containing an nroff command that opens a kind of grouping, the nroff command to close that grouping is automatically inserted on the following line.

如果您将大纲次要模式与 Nroff 模式一起使用(请参阅大纲模式),则标题行的形式为 '。H' 后跟一个数字(标题级别)。

If you use Outline minor mode with Nroff mode (see Outline Mode), heading lines are lines of the form ‘.H’ followed by a number (the header level).


26.14 丰富文本

26.14 Enriched Text

丰富模式是一种以 WYSIWYG(所见即所得)方式编辑格式化文本文件的次要模式。启用丰富模式后,您可以将各种格式化属性应用于缓冲区中的文本,例如字体和颜色;保存缓冲区后,这些属性将使用 MIME ' 与文本一起保存文本/丰富' 文件格式。

Enriched mode is a minor mode for editing formatted text files in a WYSIWYG (What You See Is What You Get) fashion. When Enriched mode is enabled, you can apply various formatting properties to the text in the buffer, such as fonts and colors; upon saving the buffer, those properties are saved together with the text, using the MIME ‘text/enriched’ file format.

丰富模式通常与文本模式一起使用(请参阅文本模式)。它与字体锁定模式兼容,许多主要模式(包括大多数编程语言模式)都使用字体锁定模式来进行语法突出显示(请参阅字体锁定模式)。与丰富模式不同,字体锁定模式根据当前缓冲区内容自动分配文本属性;这些属性不会保存到磁盘。

Enriched mode is typically used with Text mode (see Text Mode). It is not compatible with Font Lock mode, which is used by many major modes, including most programming language modes, for syntax highlighting (see Font Lock mode). Unlike Enriched mode, Font Lock mode assigns text properties automatically, based on the current buffer contents; those properties are not saved to disk.

文件丰富.txtEmacs 中的data-directory 示例是丰富模式的功能的示例。

The file enriched.txt in Emacs’s data-directory serves as an example of the features of Enriched mode.


26.14.1 丰富模式

26.14.1 Enriched Mode

丰富模式是缓冲区本地次要模式(请参阅次要模式)。当您访问已保存在“文本/丰富' 格式时,Emacs 会自动启用丰富模式,并将文件中的格式信息应用到缓冲区文本。当您在启用丰富模式的情况下保存缓冲区时,将使用 '文本/丰富' 格式,包括格式信息。

Enriched mode is a buffer-local minor mode (see Minor Modes). When you visit a file that has been saved in the ‘text/enriched’ format, Emacs automatically enables Enriched mode, and applies the formatting information in the file to the buffer text. When you save a buffer with Enriched mode enabled, it is saved using the ‘text/enriched’ format, including the formatting information.

要创建新的格式化文本文件,请访问不存在的文件并输入M-x enriched-mode.该命令实际上切换丰富模式。使用前缀参数时,如果参数为正,则启用丰富模式,否则禁用丰富模式。如果禁用丰富模式,Emacs 不再使用 '文本/丰富' 格式;已添加到缓冲区的任何格式化属性仍保留在缓冲区中,但不会保存到磁盘。

To create a new file of formatted text, visit the nonexistent file and type M-x enriched-mode. This command actually toggles Enriched mode. With a prefix argument, it enables Enriched mode if the argument is positive, and disables Enriched mode otherwise. If you disable Enriched mode, Emacs no longer saves the buffer using the ‘text/enriched’ format; any formatting properties that have been added to the buffer remain in the buffer, but they are not saved to disk.

丰富模式不保存所有 Emacs 文本属性,仅保存变量中指定的属性enriched-translations。其中包括字体、颜色、缩进和对齐方式的属性。

Enriched mode does not save all Emacs text properties, only those specified in the variable enriched-translations. These include properties for fonts, colors, indentation, and justification.

如果您访问一个文件并且 Emacs 无法识别它位于 '文本/丰富' 格式,类型M-x format-decode-buffer.此命令提示输入文件格式,并以该格式重新读取文件。指定 '文本/丰富' 格式自动启用丰富模式。

If you visit a file and Emacs fails to recognize that it is in the ‘text/enriched’ format, type M-x format-decode-buffer. This command prompts for a file format, and re-reads the file in that format. Specifying the ‘text/enriched’ format automatically enables Enriched mode.

要查看 '文本/丰富' 原始形式的文件(作为带有标记标签的纯文本而不是格式化文本),使用M-x find-file-literally(请参阅访问文件)。

To view a ‘text/enriched’ file in raw form (as plain text with markup tags rather than formatted text), use M-x find-file-literally (see Visiting Files).

有关Emacs如何识别和转换文件格式(如'文本/丰富'。有关文本属性的更多信息, 请参阅Emacs Lisp 参考手册中的文本属性。

See Format Conversion in the Emacs Lisp Reference Manual, for details of how Emacs recognizes and converts file formats like ‘text/enriched’. See Text Properties in the Emacs Lisp Reference Manual, for more information about text properties.


26.14.2 硬换行符和软换行符

26.14.2 Hard and Soft Newlines

在丰富模式下,Emacs 区分两种不同类型的换行符:换行符和换行符。您还可以通过键入 来在其他缓冲区中启用或禁用此功能M-x use-hard-newlines

In Enriched mode, Emacs distinguishes between two different kinds of newlines, hard newlines and soft newlines. You can also enable or disable this feature in other buffers, by typing M-x use-hard-newlines.

硬换行符用于分隔段落,或任何需要换行的地方,无论文本如何填充;使用软换行符进行填充。 ( RET)newlineC-o( open-line) 命令插入硬换行符。填充命令,包括自动填充(请参阅自动填充模式),仅插入软换行符并仅删除软换行符,而保留硬换行符。

Hard newlines are used to separate paragraphs, or anywhere there needs to be a line break regardless of how the text is filled; soft newlines are used for filling. The RET (newline) and C-o (open-line) commands insert hard newlines. The fill commands, including Auto Fill (see Auto Fill Mode), insert only soft newlines and delete only soft newlines, leaving hard newlines alone.

因此,在使用丰富模式进行编辑时,不应在已填充段落的中间使用RET 或换行。C-o请改用自动填充模式或显式填充命令(请参阅显式填充命令)。在应始终保留换行符的位置(例如在表格和列表中)使用RET或。C-o对于此类行,您可能还需要将对齐方式设置为unfilled (请参阅丰富文本中的对齐方式)。

Thus, when editing with Enriched mode, you should not use RET or C-o to break lines in the middle of filled paragraphs. Use Auto Fill mode or explicit fill commands (see Explicit Fill Commands) instead. Use RET or C-o where line breaks should always remain, such as in tables and lists. For such lines, you may also want to set the justification style to unfilled (see Justification in Enriched Text).


26.14.3 编辑格式信息

26.14.3 Editing Format Information

更改属性的最简单方法是使用 '文本属性' 菜单。您可以从“编辑' 菜单栏中的菜单(请参阅菜单栏),或使用C-mouse-2 (请参阅鼠标单击菜单)。 ' 中的一些命令文本属性下面列出了菜单(您也可以使用 来调用它们 M-x):

The easiest way to alter properties is with the ‘Text Properties’ menu. You can get to this menu from the ‘Edit’ menu in the menu bar (see The Menu Bar), or with C-mouse-2 (see Mouse Clicks for Menus). Some of the commands in the ‘Text Properties’ menu are listed below (you can also invoke them with M-x):

Remove Face Properties
Remove Face Properties

从区域 ( facemenu-remove-face-props) 中删除面属性。

Remove face properties from the region (facemenu-remove-face-props).

Remove Text Properties
Remove Text Properties

从区域中删除所有文本属性,包括面属性 ( facemenu-remove-all)。

Remove all text properties from the region, including face properties (facemenu-remove-all).

Describe Properties
Describe Properties

列出点 ( ) 后面字符的所有文本属性和其他信息describe-text-properties

List all text properties and other information about the character following point (describe-text-properties).

Display Faces
Display Faces

显示已定义面的列表 ( list-faces-display)。请参阅文本面孔

Display a list of defined faces (list-faces-display). See Text Faces.

Display Colors
Display Colors

显示已定义颜色的列表 ( list-colors-display)。请参阅面部颜色

Display a list of defined colors (list-colors-display). See Colors for Faces.

其他菜单项将在以下部分中描述。

The other menu entries are described in the following sections.


26.14.4 丰富文本中的面孔

26.14.4 Faces in Enriched Text

以下命令可用于添加或删除面(请参阅文本面)。如果标记处于活动状态,则每个字符都适用于该区域中的文本;如果标记处于非活动状态,则每个字符都适用于下一个自插入字符。使用前缀参数,每个命令都适用于下一个自插入字符,即使该区域处于活动状态也是如此。

The following commands can be used to add or remove faces (see Text Faces). Each applies to the text in the region if the mark is active, and to the next self-inserting character if the mark is inactive. With a prefix argument, each command applies to the next self-inserting character even if the region is active.

M-o d
M-o d

删除所有face属性 ( facemenu-set-default)。

Remove all face properties (facemenu-set-default).

M-o b
M-o b

敷在bold脸上(facemenu-set-bold)。

Apply the bold face (facemenu-set-bold).

M-o i
M-o i

敷在italic脸上(facemenu-set-italic)。

Apply the italic face (facemenu-set-italic).

M-o l
M-o l

敷在bold-italic脸上(facemenu-set-bold-italic)。

Apply the bold-italic face (facemenu-set-bold-italic).

M-o u
M-o u

敷在underline脸上(facemenu-set-underline)。

Apply the underline face (facemenu-set-underline).

M-o o face RET
M-o o face RET

敷脸facemenu-set-face

Apply the face face (facemenu-set-face).

M-x facemenu-set-foreground
M-x facemenu-set-foreground

提示输入颜色(请参阅面的颜色),并将其应用为前景色。

Prompt for a color (see Colors for Faces), and apply it as a foreground color.

M-x facemenu-set-background
M-x facemenu-set-background

提示输入颜色,并将其应用为背景颜色。

Prompt for a color, and apply it as a background color.

这些命令也可以通过“文本属性”菜单使用。

These commands are also available via the Text Properties menu.

自插入字符通常继承缓冲区中前一个字符的面部属性(以及大多数其他文本属性)。如果使用上述命令之一指定下一个自插入字符的面部,该字符将不会继承前一个字符的面部属性,但仍会继承其他文本属性。

A self-inserting character normally inherits the face properties (and most other text properties) from the preceding character in the buffer. If you use one of the above commands to specify the face for the next self-inserting character, that character will not inherit the faces properties from the preceding character, but it will still inherit other text properties.

丰富模式定义了两个附加面:excerptfixed。这些对应于文本/丰富文件格式中使用的代码。该excerpt面用于引用;默认情况下,它看起来与 相同italic。面fixed指定固定宽度的文本;默认情况下,它看起来与 相同 bold

Enriched mode defines two additional faces: excerpt and fixed. These correspond to codes used in the text/enriched file format. The excerpt face is intended for quotations; by default, it appears the same as italic. The fixed face specifies fixed-width text; by default, it appears the same as bold.


26.14.5 丰富文本中的缩进

26.14.5 Indentation in Enriched Text

在丰富模式下,您可以为段落或段落的一部分的右边距或左边距指定不同的缩进量。这些边距还会影响填充命令,例如M-q (请参阅填充文本)。

In Enriched mode, you can specify different amounts of indentation for the right or left margin of a paragraph or a part of a paragraph. These margins also affect fill commands such as M-q (see Filling Text).

文本属性的缩进子菜单提供了用于指定缩进的命令:

The Indentation submenu of Text Properties offers commands for specifying indentation:

Indent More
Indent More

将区域缩进 4 列 ( increase-left-margin)。在丰富模式下,此命令也可用于;如果您提供一个数字参数,则表示要添加到边距的列数(负参数会减少列数)。 C-x TAB

Indent the region by 4 columns (increase-left-margin). In Enriched mode, this command is also available on C-x TAB; if you supply a numeric argument, that says how many columns to add to the margin (a negative argument reduces the number of columns).

Indent Less
Indent Less

从该区域删除 4 列缩进。

Remove 4 columns of indentation from the region.

Indent Right More
Indent Right More

通过在右侧边距缩进 4 列来使文本变窄。

Make the text narrower by indenting 4 columns at the right margin.

Indent Right Less
Indent Right Less

从右边距删除 4 列缩进。

Remove 4 columns of indentation from the right margin.

该变量standard-indent指定这些命令应在缩进中添加或减去多少列。默认值为 4。fill-column像往常一样,丰富模式的默认右边距由变量 控制。

The variable standard-indent specifies how many columns these commands should add to or subtract from the indentation. The default value is 4. The default right margin for Enriched mode is controlled by the variable fill-column, as usual.

您还可以键入C-c [( set-left-margin) 和C-c ]( set-right-margin) 来设置左边距和右边距。您可以使用数字参数指定边距宽度;否则,这些命令会通过迷你缓冲区提示输入值。

You can also type C-c [ (set-left-margin) and C-c ] (set-right-margin) to set the left and right margins. You can specify the margin width with a numeric argument; otherwise these commands prompt for a value via the minibuffer.

填充前缀(如果有)除了指定的段落缩进之外也起作用:C-x .填充前缀的新值中不包括指定缩进的空格,并且填充命令在每行的缩进之后查找填充前缀。请参阅填充前缀

The fill prefix, if any, works in addition to the specified paragraph indentation: C-x . does not include the specified indentation’s whitespace in the new value for the fill prefix, and the fill commands look for the fill prefix after the indentation on each line. See The Fill Prefix.


26.14.6 丰富文本中的理由

26.14.6 Justification in Enriched Text

在丰富模式下,您可以使用以下命令指定填充的各种对齐方式。这些命令适用于包含点的段落,或者,如果该区域处于活动状态,则适用于与该区域重叠的所有段落。

In Enriched mode, you can use the following commands to specify various justification styles for filling. These commands apply to the paragraph containing point, or, if the region is active, to all paragraphs overlapping the region.

M-j l
M-j l

将线条与左边距对齐 ( set-justification-left)。

Align lines to the left margin (set-justification-left).

M-j r
M-j r

将线条与右边距对齐 ( set-justification-right)。

Align lines to the right margin (set-justification-right).

M-j b
M-j b

将线条与两侧边距对齐,并在线条中间插入空格以实现此目的 ( set-justification-full)。

Align lines to both margins, inserting spaces in the middle of the line to achieve this (set-justification-full).

M-j c
M-j c
M-S
M-S

边距之间的中心线 ( set-justification-center)。

Center lines between the margins (set-justification-center).

M-j u
M-j u

完全关闭填充 ( set-justification-none)。填充命令对具有此设置的文本不执行任何操作。但是,您仍然可以缩进左边距。

Turn off filling entirely (set-justification-none). The fill commands do nothing on text with this setting. You can, however, still indent the left margin.

您还可以使用“文本属性”菜单中的“对齐方式”子菜单指定对齐方式。默认对齐方式由 per-buffer 变量指定default-justification。它的值应该是符号leftrightfullcenter、 或之一none;它们的含义与上面的命令相对应。

You can also specify justification styles using the Justification submenu in the Text Properties menu. The default justification style is specified by the per-buffer variable default-justification. Its value should be one of the symbols left, right, full, center, or none; their meanings correspond to the commands above.


26.14.7 设置其他文本属性

26.14.7 Setting Other Text Properties

文本属性的特殊属性子菜单包含用于添加或删除其他四个文本属性的条目:read-only、(不允许更改文本)、invisible(隐藏文本)、intangible(不允许在文本内移动点)和charset(对于选择合适的字体来显示字符)。这 '删除特殊' 菜单项从该区域的文本中删除所有这些特殊属性。

The Special Properties submenu of Text Properties has entries for adding or removing four other text properties: read-only, (which disallows alteration of the text), invisible (which hides text), intangible (which disallows moving point within the text), and charset (which is important for selecting a proper font to display a character). The ‘Remove Special’ menu item removes all of these special properties from the text in the region.

invisible和属性intangible不会保存。

The invisible and intangible properties are not saved.

丰富模式还支持保存和恢复display 属性(请参阅Emacs Lisp 参考手册中的显示属性),这会影响文本在屏幕上的显示方式,并且还允许显示来自缓冲区文本以外的源的图像和字符串。这些属性还支持执行任意 Lisp 形式,作为处理显示属性的一部分,从而提供了一种根据某些只能在显示时得知的条件动态定制显示的方法。由于任意 Lisp 的执行都会使 Emacs 面临潜在的攻击,特别是当丰富文本的来源位于 Emacs 之外甚至在您的系统之外时(例如,如果它是在电子邮件中收到的),默认情况下,在丰富模式下会禁用此类执行。您可以通过将变量自定义 为非值来启用它。 displayenriched-allow-eval-in-display-propsnil

Enriched mode also supports saving and restoring display properties (see Display Property in the Emacs Lisp Reference Manual), which affect how text is displayed on the screen, and also allow displaying images and strings that come from sources other than buffer text. The display properties also support execution of arbitrary Lisp forms as part of processing the property for display, thus providing a means to dynamically tailor the display to some conditions that can only be known at display time. Since execution of arbitrary Lisp opens Emacs to potential attacks, especially when the source of enriched text is outside of Emacs or even outside of your system (e.g., if it was received in an email message), such execution is by default disabled in Enriched mode. You can enable it by customizing the variable enriched-allow-eval-in-display-props to a non-nil value.


26.15 编辑基于文本的表格

26.15 Editing Text-based Tables

table软件包提供了可轻松编辑基于文本的表格的命令。以下是此类表的示例:

The table package provides commands to easily edit text-based tables. Here is an example of what such a table looks like:

+----------------+-------------------------------------------- -+------------------+
|命令 |描述 |按键绑定|
+----------------+-------------------------------------------- -+------------------+
| forward-char |将点向右移动 N 个字符 |比照|
| |(如果 N 为负则向左)。 | |
| | | |
+----------------+-------------------------------------------- -+------------------+
| back-char |将点向左移动 N 个字符 | CB |
| |(如果 N 为负则正确)。 | |
| | | |
+----------------+-------------------------------------------- -+------------------+
+-----------------+--------------------------------+-----------------+
|     Command     |          Description           |   Key Binding   |
+-----------------+--------------------------------+-----------------+
|  forward-char   |Move point right N characters   |       C-f       |
|                 |(left if N is negative).        |                 |
|                 |                                |                 |
+-----------------+--------------------------------+-----------------+
|  backward-char  |Move point left N characters    |       C-b       |
|                 |(right if N is negative).       |                 |
|                 |                                |                 |
+-----------------+--------------------------------+-----------------+

当 Emacs 将这样一段文本识别为表格时(请参阅表格识别),每当内容变得太大而无法容纳单元格时,编辑每个表格单元格的内容将自动调整表格的大小。您可以使用以下部分中定义的命令来导航和编辑表布局。

When Emacs recognizes such a stretch of text as a table (see Table Recognition), editing the contents of each table cell will automatically resize the table, whenever the contents become too large to fit in the cell. You can use the commands defined in the following sections for navigating and editing the table layout.

键入M-x table-fixed-width-mode以切换自动调整表格大小功能。

Type M-x table-fixed-width-mode to toggle the automatic table resizing feature.


26.15.1 什么是基于文本的表格?

26.15.1 What is a Text-based Table?

表格由一个分为多个单元格的矩形文本区域组成。每个单元格必须至少为 1 个字符宽和 1 个字符高(不包括其边界线)。一个单元格可以细分为更多单元格,但它们不能重叠。

A table consists of a rectangular text area which is divided into cells. Each cell must be at least one character wide and one character high, not counting its border lines. A cell can be subdivided into more cells, but they cannot overlap.

单元格边框线用三个特殊字符绘制,由以下变量指定:

Cell border lines are drawn with three special characters, specified by the following variables:

table-cell-vertical-char
table-cell-vertical-char

用于垂直线的字符。默认为 '|'。

The character used for vertical lines. The default is ‘|’.

table-cell-horizontal-chars
table-cell-horizontal-chars

用于水平线的字符。默认为 '“-=”'。

The characters used for horizontal lines. The default is ‘"-="’.

table-cell-intersection-char
table-cell-intersection-char

用于水平线和垂直线相交的字符。默认为 '+'。

The character used for the intersection of horizontal and vertical lines. The default is ‘+’.

以下是无效表的示例:

The following are examples of invalid tables:

   +-----+ +--+ +-++--+
   | | | | | || |
   | | | | | || |
   +--+ | +--+--+ +-++--+
   | | | | | | +-++--+
   | | | | | | | || |
   +--+--+ +--+--+ +-++--+
      ABC
   +-----+       +--+    +-++--+
   |     |       |  |    | ||  |
   |     |       |  |    | ||  |
   +--+  |    +--+--+    +-++--+
   |  |  |    |  |  |    +-++--+
   |  |  |    |  |  |    | ||  |
   +--+--+    +--+--+    +-++--+
      a          b          c

从左到右:

From left to right:

  1. 不允许出现重叠的单元格或非矩形单元格。
  2. Overlapped cells or non-rectangular cells are not allowed.
  3. 边框必须是矩形。
  4. The border must be rectangular.
  5. 单元格的最小宽度/高度必须为一个字符。
  6. Cells must have a minimum width/height of one character.

26.15.2 创建表

26.15.2 Creating a Table

要从头开始创建基于文本的表格,请键入M-x table-insert。此命令提示输入表格列数、表格行数、单元格宽度和单元格高度。单元格宽度和单元格高度不包括单元格边框;每个都可以指定为单个整数(这意味着每个单元格都具有相同的宽度/高度),或者指定为由空格或逗号分隔的整数序列(指定单个表格列/行的宽度/高度,从表列从左到右,表行从上到下)。然后将指定的表插入到该点。

To create a text-based table from scratch, type M-x table-insert. This command prompts for the number of table columns, the number of table rows, cell width and cell height. The cell width and cell height do not include the cell borders; each can be specified as a single integer (which means each cell is given the same width/height), or as a sequence of integers separated by spaces or commas (which specify the width/height of the individual table columns/rows, counting from left to right for table columns and from top to bottom for table rows). The specified table is then inserted at point.

插入的表M-x table-insert包含特殊的文本属性,这些属性告诉 Emacs 将其特殊地视为基于文本的表。如果将缓冲区保存到文件并稍后再次访问它,这些属性就会丢失,并且该表在 Emacs 中显示为普通文本。请参阅下一节,了解如何将其转换回表格。

The table inserted by M-x table-insert contains special text properties, which tell Emacs to treat it specially as a text-based table. If you save the buffer to a file and visit it again later, those properties are lost, and the table appears to Emacs as an ordinary piece of text. See the next section, for how to convert it back into a table.


26.15.3 表识别

26.15.3 Table Recognition

缓冲区中现有的基于文本的表缺少 所应用的特殊文本属性M-x table-insert,因此不会被特殊视为表。要应用这些文本属性,请键入M-x table-recognize。此命令扫描当前缓冲区, 识别有效的表格单元格,并应用相关的文本属性。相反,键入M-x table-unrecognize无法识别当前缓冲区中的所有表格,删除特殊文本属性并将表格转换回纯文本。

Existing text-based tables in a buffer, which lack the special text properties applied by M-x table-insert, are not treated specially as tables. To apply those text properties, type M-x table-recognize. This command scans the current buffer, recognizes valid table cells, and applies the relevant text properties. Conversely, type M-x table-unrecognize to unrecognize all tables in the current buffer, removing the special text properties and converting tables back to plain text.

您还可以使用以下命令有选择地识别或不识别表:

You can also use the following commands to selectively recognize or unrecognize tables:

M-x table-recognize-region
M-x table-recognize-region

识别当前区域内的表。

Recognize tables within the current region.

M-x table-unrecognize-region
M-x table-unrecognize-region

无法识别当前区域内的表。

Unrecognize tables within the current region.

M-x table-recognize-table
M-x table-recognize-table

识别该表并激活它。

Recognize the table at point and activate it.

M-x table-unrecognize-table
M-x table-unrecognize-table

在该点停用该表。

Deactivate the table at point.

M-x table-recognize-cell
M-x table-recognize-cell

识别该点的细胞并激活它。

Recognize the cell at point and activate it.

M-x table-unrecognize-cell
M-x table-unrecognize-cell

在该点停用单元。

Deactivate the cell at point.

有关识别表格的另一种方法, 请参阅在纯文本和表格之间进行转换。

See Converting Between Plain Text and Tables, for another way to recognize a table.


26.15.4 表格单元格命令

26.15.4 Commands for Table Cells

命令M-x table-forward-cellM-x table-backward-cell移动点从当前单元格到相邻单元格。该顺序是循环的:当点位于表格的最后一个单元格中时, M-x table-forward-cell移动到第一个单元格。同样,当点位于第一个单元格上时,M-x table-backward-cell移动到最后一个单元格。

The commands M-x table-forward-cell and M-x table-backward-cell move point from the current cell to an adjacent cell. The order is cyclic: when point is in the last cell of a table, M-x table-forward-cell moves to the first cell. Likewise, when point is on the first cell, M-x table-backward-cell moves to the last cell.

M-x table-span-cell提示输入方向(向右、向左、向上或向下),并将当前单元格与该方向上的相邻单元格合并。如果合并会导致非法的单元布局,则此命令会发出错误信号。

M-x table-span-cell prompts for a direction—right, left, above, or below—and merges the current cell with the adjacent cell in that direction. This command signals an error if the merge would result in an illegitimate cell layout.

M-x table-split-cell垂直或水平分割当前单元格,提示迷你缓冲区的方向。要沿特定方向分割,请使用M-x table-split-cell-verticallyM-x table-split-cell-horizontally。垂直拆分时,旧单元格内容会自动在两个新单元格之间拆分。水平分割时,如果单元格非空,系统会提示您如何分割单元格内容;选项是 '分裂'(在点处划分内容),'左边'(将所有内容放入左侧单元格中),并且'正确的'(将所有内容放入右侧单元格中)。

M-x table-split-cell splits the current cell vertically or horizontally, prompting for the direction with the minibuffer. To split in a specific direction, use M-x table-split-cell-vertically and M-x table-split-cell-horizontally. When splitting vertically, the old cell contents are automatically split between the two new cells. When splitting horizontally, you are prompted for how to divide the cell contents, if the cell is non-empty; the options are ‘split’ (divide the contents at point), ‘left’ (put all the contents in the left cell), and ‘right’ (put all the contents in the right cell).

以下命令放大或缩小单元格。默认情况下,它们按一行或一列调整大小;如果提供数字参数,则指定要调整大小的行数或列数。

The following commands enlarge or shrink a cell. By default, they resize by one row or column; if a numeric argument is supplied, that specifies the number of rows or columns to resize by.

M-x table-heighten-cell
M-x table-heighten-cell

垂直放大当前单元格。

Enlarge the current cell vertically.

M-x table-shorten-cell
M-x table-shorten-cell

垂直缩小当前单元格。

Shrink the current cell vertically.

M-x table-widen-cell
M-x table-widen-cell

水平放大当前单元格。

Enlarge the current cell horizontally.

M-x table-narrow-cell
M-x table-narrow-cell

水平缩小当前单元格。

Shrink the current cell horizontally.


26.15.5 单元格调整

26.15.5 Cell Justification

该命令对基于文本的表格中的一个或多个单元M-x table-justify格施加对齐方式。对齐确定单元格中的文本相对于单元格边缘的对齐方式。表格中的每个单元格都可以单独对齐。

The command M-x table-justify imposes justification on one or more cells in a text-based table. Justification determines how the text in the cell is aligned, relative to the edges of the cell. Each cell in a table can be separately justified.

M-x table-justify首先提示要证明什么;选项是 '细胞'(仅当前单元格),'柱子' (当前表格列中的所有单元格)和 ''(当前表格行中的所有单元格)。然后该命令会提示输入对齐方式;选项为leftcenterrighttop、 、middlebottomnone(表示无垂直对齐)。

M-x table-justify first prompts for what to justify; the options are ‘cell’ (just the current cell), ‘column’ (all cells in the current table column) and ‘row’ (all cells in the current table row). The command then prompts for the justification style; the options are left, center, right, top, middle, bottom, or none (meaning no vertical justification).

水平和垂直对齐方式独立指定,两种方式可以同时生效;例如,您可以调用M-x table-justify两次,一次指定 right对齐方式,一次指定bottom 对齐方式,将单元格的内容与右下角对齐。

Horizontal and vertical justification styles are specified independently, and both types can be in effect simultaneously; for instance, you can call M-x table-justify twice, once to specify right justification and once to specify bottom justification, to align the contents of a cell to the bottom right.

对齐样式作为文本属性存储在缓冲区中,并且当您终止缓冲区或退出 Emacs 时会丢失。但是,表格识别命令M-x table-recognize (请参阅表格识别)尝试通过检查其内容来确定并重新应用每个单元格的对齐方式。要禁用此功能,请将变量更改table-detect-cell-alignmentnil

The justification style is stored in the buffer as a text property, and is lost when you kill the buffer or exit Emacs. However, the table recognition commands, such as M-x table-recognize (see Table Recognition), attempt to determine and re-apply each cell’s justification style, by examining its contents. To disable this feature, change the variable table-detect-cell-alignment to nil.


26.15.6 表格行和列

26.15.6 Table Rows and Columns

M-x table-insert-row在当前表格行之前插入一行单元格。当前行与点一起被下推到新行之上。要在表格底部的最后一行之后插入一行,请使用表格下方、底部边缘下方的点调用此命令。您可以使用数字前缀参数一次插入多行。

M-x table-insert-row inserts a row of cells before the current table row. The current row, together with point, is pushed down past the new row. To insert a row after the last row at the bottom of a table, invoke this command with point below the table, just below the bottom edge. You can insert more than one row at a time by using a numeric prefix argument.

同样,M-x table-insert-column将一列单元格插入到当前表列的左侧。要将列插入到最右列的右侧,请通过指向表外部最右列的右侧来调用此命令。数字前缀参数指定要插入的列数。

Similarly, M-x table-insert-column inserts a column of cells to the left of the current table column. To insert a column to the right side of the rightmost column, invoke this command with point to the right of the rightmost column, outside the table. A numeric prefix argument specifies the number of columns to insert.

M-x table-delete-column删除此时的单元格列。同样,M-x table-delete-row删除当前所在的单元格行。任一命令的数字前缀参数指定要删除的列数或行数。

M-x table-delete-column deletes the column of cells at point. Similarly, M-x table-delete-row deletes the row of cells at point. A numeric prefix argument to either command specifies the number of columns or rows to delete.


26.15.7 纯文本和表格之间的转换

26.15.7 Converting Between Plain Text and Tables

该命令M-x table-capture捕获区域中的纯文本并将其转换为表格。与M-x table-recognize (参见表格识别)不同的是,原始文本不需要有表格外观;它只需要具有类似逻辑表的结构。

The command M-x table-capture captures plain text in a region and turns it into a table. Unlike M-x table-recognize (see Table Recognition), the original text does not need to have a table appearance; it only needs to have a logical table-like structure.

例如,假设我们有以下数字,它们分为三行并用逗号水平分隔:

For example, suppose we have the following numbers, which are divided into three lines and separated horizontally by commas:

1, 2, 3, 4
5、6、7、8
, 9, 10
1, 2, 3, 4
5, 6, 7, 8
, 9, 10

调用M-x table-capture该文本会生成此表:

Invoking M-x table-capture on that text produces this table:

+-----+-----+-----+-----+
|1 |2 |3 |4 |
+-----+-----+-----+-----+
|5 |6 |7 |8 |
+-----+-----+-----+-----+
| |9 |10 | |
+-----+-----+-----+-----+
+-----+-----+-----+-----+
|1    |2    |3    |4    |
+-----+-----+-----+-----+
|5    |6    |7    |8    |
+-----+-----+-----+-----+
|     |9    |10   |     |
+-----+-----+-----+-----+

M-x table-release执行相反的操作:它将表格转换回纯文本,并删除其单元格边框。

M-x table-release does the opposite: it converts a table back to plain text, removing its cell borders.

这对命令的一个应用是编辑布局中的文本。请看下面三段:

One application of this pair of commands is to edit a text in layout. Look at the following three paragraphs:

table-capture 是一个强大的命令。
以下是它可以做的一些事情:

使用行和列分隔符正则表达式解析单元格项目,
                   它解析指定的文本区域并
                   将单元格项目提取到表中。
table-capture is a powerful command.
Here are some things it can do:

Parse Cell Items   Using row and column delimiter regexps,
                   it parses the specified text area and
                   extracts cell items into a table.

应用于table-capture包含上述文本的区域,并使用列和行分隔符正则表达式的空字符串,创建一个包含单个单元格的表格,如下所示。

Applying table-capture to a region containing the above text, with empty strings for the column and row delimiter regexps, creates a table with a single cell like the following one.

+------------------------------------------------ ---------+
|table-capture 是一个强大的命令。 |
|它可以执行以下操作:|
| |
|使用行和列分隔符正则表达式解析单元格项目,|
|它解析指定的文本区域并 |
|将单元格项目提取到表中。 |
+------------------------------------------------ ---------+
+----------------------------------------------------------+
|table-capture is a powerful command.                      |
|Here are some things it can do:                           |
|                                                          |
|Parse Cell Items   Using row and column delimiter regexps,|
|                   it parses the specified text area and  |
|                   extracts cell items into a table.      |
+----------------------------------------------------------+

然后,我们可以使用单元格分割命令(请参阅表格单元格命令)来细分表格,以便每个段落占据一个单元格:

We can then use the cell splitting commands (see Commands for Table Cells) to subdivide the table so that each paragraph occupies a cell:

+------------------------------------------------ ---------+
|table-capture 是一个强大的命令。 |
|它可以执行以下操作:|
+----------------+-------------------------------------------- ---------+
|解析单元格项目|使用行和列分隔符正则表达式,|
| |它解析指定的文本区域并 |
| |将单元格项目提取到表中。 |
+----------------+-------------------------------------------- ---------+
+----------------------------------------------------------+
|table-capture is a powerful command.                      |
|Here are some things it can do:                           |
+-----------------+----------------------------------------+
|Parse Cell Items | Using row and column delimiter regexps,|
|                 | it parses the specified text area and  |
|                 | extracts cell items into a table.      |
+-----------------+----------------------------------------+

现在可以独立编辑每个单元格,而不会影响其他单元格的布局。完成后,我们可以调用M-x table-release 将表格转换回纯文本。

Each cell can now be edited independently without affecting the layout of other cells. When finished, we can invoke M-x table-release to convert the table back to plain text.


26.15.8 表格杂项

26.15.8 Table Miscellany

该命令table-query-dimension报告此时表格和表格单元格的布局。这是其输出的示例:

The command table-query-dimension reports the layout of the table and table cell at point. Here is an example of its output:

细胞:(21w,6h),桌子:(67w,16h),暗淡:(2c,3r),细胞总数:5
Cell: (21w, 6h), Table: (67w, 16h), Dim: (2c, 3r), Total Cells: 5

这表示当前单元格宽 21 个字符,高 6 行,表格宽 67 个字符,高 16 行,2 列 3 行,总共 5 个单元格。

This indicates that the current cell is 21 characters wide and 6 lines high, the table is 67 characters wide and 16 lines high with 2 columns and 3 rows, and a total of 5 cells.

M-x table-insert-sequence遍历表格的单元格,将一系列文本字符串插入到每个单元格中。它要求序列的基本字符串,然后通过数字(如果基本字符串以数字字符结尾)或按ASCII顺序“递增”基本字符串来生成序列 。除了基本字符串之外,该命令还提示输入序列中的元素数量、增量、单元格间隔以及每个单元格中文本的对齐方式。

M-x table-insert-sequence traverses the cells of a table inserting a sequence of text strings into each cell as it goes. It asks for the base string of the sequence, and then produces the sequence by “incrementing” the base string, either numerically (if the base string ends in numerical characters) or in the ASCII order. In addition to the base string, the command prompts for the number of elements in the sequence, the increment, the cell interval, and the justification of the text in each cell.

M-x table-generate-source生成针对特定标记语言格式化的表。它要求一种语言(必须是htmllatexcalswiki之一 mediawiki)、用于放置结果的目标缓冲区以及表标题,然后将生成的表插入到指定的缓冲区中。默认目标缓冲区为 ,其中lang是您指定的语言。 table.lang

M-x table-generate-source generates a table formatted for a specific markup language. It asks for a language (which must be one of html, latex, cals, wiki or mediawiki), a destination buffer in which to put the result, and a table caption, and then inserts the generated table into the specified buffer. The default destination buffer is table.lang, where lang is the language you specified.


26.16 两栏编辑

26.16 Two-Column Editing

两列模式可让您方便地编辑两列并排的文本。它使用两个并排的窗口,每个窗口显示自己的缓冲区。进入两列模式有以下三种方式:

Two-column mode lets you conveniently edit two side-by-side columns of text. It uses two side-by-side windows, each showing its own buffer. There are three ways to enter two-column mode:

F2 2或者C-x 6 2
F2 2 or C-x 6 2

进入两列模式,左侧是当前缓冲区,右侧是名称基于当前缓冲区名称 ( 2C-two-columns) 的缓冲区。如果右侧缓冲区尚不存在,则它一开始为空;当前缓冲区的内容没有改变。

当当前缓冲区为空或仅包含一列而您想要添加另一列时,此命令适用。

Enter two-column mode with the current buffer on the left, and on the right, a buffer whose name is based on the current buffer’s name (2C-two-columns). If the right-hand buffer doesn’t already exist, it starts out empty; the current buffer’s contents are not changed.

This command is appropriate when the current buffer is empty or contains just one column and you want to add another column.

F2 s或者C-x 6 s
F2 s or C-x 6 s

将包含两列文本的当前缓冲区拆分为两个缓冲区,并并排显示它们 ( 2C-split)。当前缓冲区将成为左侧缓冲区,但右侧列中的文本将移至右侧缓冲区。当前列指定分割点。分割从当前行开始,一直持续到缓冲区的末尾。

当您的缓冲区已包含两列文本并且您希望暂时分隔各列时,此命令适用。

Split the current buffer, which contains two-column text, into two buffers, and display them side by side (2C-split). The current buffer becomes the left-hand buffer, but the text in the right-hand column is moved into the right-hand buffer. The current column specifies the split point. Splitting starts with the current line and continues to the end of the buffer.

This command is appropriate when you have a buffer that already contains two-column text, and you wish to separate the columns temporarily.

F2 b buffer RET
F2 b buffer RET
C-x 6 b buffer RET
C-x 6 b buffer RET

进入两列模式,使用当前缓冲区作为左侧缓冲区,并使用缓冲区buffer作为右侧缓冲区 ( 2C-associate-buffer)。

Enter two-column mode using the current buffer as the left-hand buffer, and using buffer buffer as the right-hand buffer (2C-associate-buffer).

F2 sC-x 6 s查找列分隔符,它是出现在两列之间的每一行上的字符串。您可以使用 ; 的数字参数指定分隔符的宽度 F2 s。点之前的许多字符构成分隔符字符串。默认情况下,宽度为1,因此列分隔符是点之前的字符。

F2 s or C-x 6 s looks for a column separator, which is a string that appears on each line between the two columns. You can specify the width of the separator with a numeric argument to F2 s; that many characters, before point, constitute the separator string. By default, the width is 1, so the column separator is the character before point.

当一行在正确的位置有分隔符时,F2 s 将分隔符后面的文本放入右侧缓冲区,并删除分隔符。在适当位置没有列分隔符的行保持不分割;它们保留在左侧缓冲区中,右侧缓冲区有一个空行来对应。 (这是在双列模式下编写跨越两列的行的方法:将其写入左侧缓冲区,并在右侧缓冲区中放置一个空行。)

When a line has the separator at the proper place, F2 s puts the text after the separator into the right-hand buffer, and deletes the separator. Lines that don’t have the column separator at the proper place remain unsplit; they stay in the left-hand buffer, and the right-hand buffer gets an empty line to correspond. (This is the way to write a line that spans both columns while in two-column mode: write it in the left-hand buffer, and put an empty line in the right-hand buffer.)

命令F2 RET或 ( ) 在两个缓冲区的相应位置插入换行符。这是在分割缓冲区中编辑两列文本时向其添加新行的最简单方法。 C-x 6 RET2C-newline

The command F2 RET or C-x 6 RET (2C-newline) inserts a newline in each of the two buffers at corresponding positions. This is the easiest way to add a new line to the two-column text while editing it in split buffers.

当您根据需要编辑了两个缓冲区后,用 F2 1C-x 6 1( 2C-merge) 合并它们。这会将右侧缓冲区中的文本复制为另一个缓冲区中的第二列。要返回两列编辑,请使用F2 s.

When you have edited both buffers as you wish, merge them with F2 1 or C-x 6 1 (2C-merge). This copies the text from the right-hand buffer as a second column in the other buffer. To go back to two-column editing, use F2 s.

使用F2 dC-x 6 d来分离两个缓冲区,使每个缓冲区保持原样 ( 2C-dissociate)。如果另一个缓冲区(您键入 时不是当前的缓冲区)F2 d为空, F2 d则会杀死它。

Use F2 d or C-x 6 d to dissociate the two buffers, leaving each as it stands (2C-dissociate). If the other buffer, the one not current when you type F2 d, is empty, F2 d kills it.


27 编辑程序

27 Editing Programs

本章介绍 Emacs 方便编辑程序的功能。这些功能可以做的一些事情包括:

This chapter describes Emacs features for facilitating editing programs. Some of the things these features can do are:


27.1 编程语言的主要模式

27.1 Major Modes for Programming Languages

Emacs为许多编程语言提供了专门的主要模式(请参阅主要模式)。编程语言模式通常指定表达式的语法、缩进的习惯规则、如何对语言进行语法突出显示以及如何查找函数定义的开头或结尾。它通常还具有编译和调试程序的功能。每种语言的主要模式均以该语言命名;例如,C 编程语言的主要模式是c-mode.

Emacs has specialized major modes (see Major Modes) for many programming languages. A programming language mode typically specifies the syntax of expressions, the customary rules for indentation, how to do syntax highlighting for the language, and how to find the beginning or end of a function definition. It often has features for compiling and debugging programs as well. The major mode for each language is named after the language; for instance, the major mode for the C programming language is c-mode.

Emacs 具有 Lisp、Scheme、基于 Scheme 的 DSSSL 表达式语言、Ada、ASM、AWK、C、C++、C#、Fortran、Icon、IDL (CORBA)、IDLWAVE、Java、Javascript、M4、Makefiles、Metafont 的编程语言模式(TeX 的字体创建伴侣)、Modula2、Object Pascal、Objective-C、Octave、Pascal、Perl、Pike、PostScript、Prolog、Python、Ruby、Simula、SQL、Tcl、TypeScript、Verilog 和 VHDL。 Perl 的另一种模式称为 CPerl 模式。模式还适用于常见 GNU 和 Unix shell 以及 MS-DOS/MS-Windows 的脚本语言蝙蝠' 文件、JSON、DNS 主文件、CSS(级联样式表)、Dockerfile、CMake 文件和各种配置文件。

Emacs has programming language modes for Lisp, Scheme, the Scheme-based DSSSL expression language, Ada, ASM, AWK, C, C++, C#, Fortran, Icon, IDL (CORBA), IDLWAVE, Java, Javascript, M4, Makefiles, Metafont (TeX’s companion for font creation), Modula2, Object Pascal, Objective-C, Octave, Pascal, Perl, Pike, PostScript, Prolog, Python, Ruby, Simula, SQL, Tcl, TypeScript, Verilog, and VHDL. An alternative mode for Perl is called CPerl mode. Modes are also available for the scripting languages of the common GNU and Unix shells, and MS-DOS/MS-Windows ‘BAT’ files, JSON, DNS master files, CSS (Cascading Style Sheets), Dockerfiles, CMake files, and various sorts of configuration files.

理想情况下,Emacs 应该为您可能想要编辑的每种编程语言提供一个主要模式。如果它没有适合您最喜欢的语言的模式,则该模式可能会在未随 Emacs 分发的包中实现(请参阅Emacs Lisp 包);或者您也可以贡献一份。

Ideally, Emacs should have a major mode for each programming language that you might want to edit. If it doesn’t have a mode for your favorite language, the mode might be implemented in a package not distributed with Emacs (see Emacs Lisp Packages); or you can contribute one.

如果 Emacs 已使用 ' 进行编译树保姆' 库,它提供了几种基于该库的可选编辑模式,这些模式利用了 ' 提供的增量解析功能树保姆'。这些模式有'-ts-' 在他们的名字中;例如c-ts-mode, python-ts-mode, 等

If Emacs has been compiled with the ‘tree-sitter’ library, it offers several optional editing modes based on that library, which utilize the incremental parsing capabilities provided by ‘tree-sitter’. These modes have ‘-ts-’ in their names; for example c-ts-mode, python-ts-mode, etc.

在大多数编程语言中,行与行之间的缩进应该有所不同,以说明程序的结构。因此,在大多数编程语言模式中,键入TAB会更新当前行的缩进(请参阅程序缩进)。此外,DEL通常绑定到 backward-delete-char-untabify,它将向后删除将每个制表符视为相同数量的空格,这样您就可以删除一列缩进,而不必担心空格是否由空格或制表符组成。

In most programming languages, indentation should vary from line to line to illustrate the structure of the program. Therefore, in most programming language modes, typing TAB updates the indentation of the current line (see Indentation for Programs). Furthermore, DEL is usually bound to backward-delete-char-untabify, which deletes backward treating each tab as if it were the equivalent number of spaces, so that you can delete one column of indentation without worrying whether the whitespace consists of spaces or tabs.

进入编程语言模式会运行钩子变量中指定的自定义 Lisp 函数prog-mode-hook,然后运行该模式自己的模式钩子中指定的函数(请参阅主要模式)。例如,进入 C 模式会运行 hooksprog-mode-hookc-mode-hook.有关钩子的信息,请 参阅钩子。

Entering a programming language mode runs the custom Lisp functions specified in the hook variable prog-mode-hook, followed by those specified in the mode’s own mode hook (see Major Modes). For instance, entering C mode runs the hooks prog-mode-hook and c-mode-hook. See Hooks, for information about hooks.

Ada 模式(请参阅Ada 模式中的Ada 模式)、C/C++/Objective C/Java/Corba IDL/Pike/AWK(请参阅CC 模式中的CC 模式)、Octave、VHDL 和 IDLWAVE(请参阅IDLWAVEIDLWAVE 用户手册)。

Separate manuals are available for the modes for Ada (see Ada Mode in Ada Mode), C/C++/Objective C/Java/Corba IDL/Pike/AWK (see CC Mode in CC Mode), Octave, VHDL, and IDLWAVE (see IDLWAVE in IDLWAVE User Manual).


27.2 顶级定义,或 Defuns

27.2 Top-Level Definitions, or Defuns

在 Emacs 中,缓冲区顶层的主要定义(例如函数)称为defun。该名称来自 Lisp,但在 Emacs 中我们将它用于所有语言。

In Emacs, a major definition at the top level in the buffer, such as a function, is called a defun. The name comes from Lisp, but in Emacs we use it for all languages.


27.2.1 左边距约定

27.2.1 Left Margin Convention

许多编程语言模式传统上假设在左边距找到的任何左括号或大括号都是顶级定义或 defun 的开始。因此,默认情况下,寻求 defun 开头的命令接受这样的分隔符来表示该位置。

Many programming-language modes have traditionally assumed that any opening parenthesis or brace found at the left margin is the start of a top-level definition, or defun. So, by default, commands which seek the beginning of a defun accept such a delimiter as signifying that position.

如果您想覆盖此约定,可以通过将用户选项设置open-paren-in-column-0-is-defun-start为 来 实现nil。如果此选项设置为t(默认值),则寻找 defun 开头的命令将在零列处的左括号或大括号处停止,而这些括号或大括号不在注释或字符串中。当它是 时 nil,可以通过在最外层搜索括号或大括号来找到 defun。由于低级 Emacs 例程不再依赖于此约定,因此您通常不需要更改 open-paren-in-column-0-is-defun-start其默认值。

If you want to override this convention, you can do so by setting the user option open-paren-in-column-0-is-defun-start to nil. If this option is set to t (the default), commands seeking the start of a defun will stop at opening parentheses or braces at column zero which aren’t in a comment or string. When it is nil, defuns are found by searching for parens or braces at the outermost level. Since low-level Emacs routines no longer depend on this convention, you usually won’t need to change open-paren-in-column-0-is-defun-start from its default.


27.2.2 通过 Defuns 移动

27.2.2 Moving by Defuns

这些命令根据顶级主要定义(也称为defuns )移动点或设置区域。

These commands move point or set up the region based on top-level major definitions, also called defuns.

C-M-a
C-M-a

移至当前或前一个 defun 的开头 ( beginning-of-defun)。

Move to beginning of current or preceding defun (beginning-of-defun).

C-M-e
C-M-e

移至当前或下一个 defun ( end-of-defun) 的末尾。

Move to end of current or following defun (end-of-defun).

C-M-h
C-M-h

将区域放在整个当前或后续 defun ( mark-defun) 周围。

Put region around whole current or following defun (mark-defun).

移动到当前 defun 的开头和结尾的命令是C-M-a( beginning-of-defun) 和C-M-e ( end-of-defun)。如果重复这些命令之一,或使用正数值参数,则每次重复都会移动到运动方向上的下一个 defun。

The commands to move to the beginning and end of the current defun are C-M-a (beginning-of-defun) and C-M-e (end-of-defun). If you repeat one of these commands, or use a positive numeric argument, each repetition moves to the next defun in the direction of motion.

C-M-a如果参数为负,则n向前移动 n次到 defun 的下一个开头。这C-M-e与参数n移动到的位置不完全相同;该 defun 的结尾通常与下一个 defun 的开头不完全相同。 (空格、注释,也许还有声明可以将它们分开。)同样,使用否定参数会移回到 defun 的末尾,这与使用肯定参数 C-M-e不太一样。C-M-a

C-M-a with a negative argument −n moves forward n times to the next beginning of a defun. This is not exactly the same place that C-M-e with argument n would move to; the end of this defun is not usually exactly the same place as the beginning of the following defun. (Whitespace, comments, and perhaps declarations can separate them.) Likewise, C-M-e with a negative argument moves back to an end of a defun, which is not quite the same as C-M-a with a positive argument.

要对当前 defun 进行操作,请使用C-M-h ( mark-defun),它将标记设置在当前 defun 的末尾,并将 point 放在其开头。请参阅标记文本对象的命令。这是准备杀死 defun 以便将其移动到文件中的其他位置的最简单方法。如果 defun 直接前面有注释(中间没有空行),它们也会被标记。如果在点位于 defun 之间时使用该命令,它将使用以下 defun。如果在标记已处于活动状态时使用该命令,它会扩展该区域的末尾以包含另一个 defun。使用前缀参数,它可以标记许多 defun 或通过适当数量的 defun 扩展区域。使用负前缀参数,它会在相反方向标记 defuns,并且还会更改后续使用的选择方向mark-defun

To operate on the current defun, use C-M-h (mark-defun), which sets the mark at the end of the current defun and puts point at its beginning. See Commands to Mark Textual Objects. This is the easiest way to get ready to kill the defun in order to move it to a different place in the file. If the defun is directly preceded by comments (with no intervening blank lines), they are marked, too. If you use the command while point is between defuns, it uses the following defun. If you use the command while the mark is already active, it extends the end of the region to include one more defun. With a prefix argument, it marks that many defuns or extends the region by the appropriate number of defuns. With negative prefix argument it marks defuns in the opposite direction and also changes the direction of selecting for subsequent uses of mark-defun.

在C模式下,C-M-h运行函数c-mark-function,与 几乎相同mark-defun;不同之处在于,它备份参数声明、函数名称和返回的数据类型,以便整个 C 函数位于该区域内。这是主要模式如何调整标准键绑定以便它们以更好地适合特定语言的方式完成其标准工作的示例。为此目的,其他主要模式可能会替换任何或所有这些键绑定。

In C mode, C-M-h runs the function c-mark-function, which is almost the same as mark-defun; the difference is that it backs up over the argument declarations, function name and returned data type so that the entire C function is inside the region. This is an example of how major modes adjust the standard key bindings so that they do their standard jobs in a way better fitting a particular language. Other major modes may replace any or all of these key bindings for that purpose.

一些编程语言支持嵌套 defun,由此可以在另一个 defun 内部(即,作为主体的一部分)定义一个 defun(例如函数、方法或类)。上面描述的命令默认查找点周围最里面的defun的开头和结尾 。基于 tree-sitter 库的主要模式提供了对此行为的控制:如果变量 treesit-defun-tactic设置为 value top-level,则 defun 命令将查找最外层的defun。

Some programming languages supported nested defuns, whereby a defun (such as a function or a method or a class) can be defined inside (i.e., as part of the body) of another defun. The commands described above by default find the beginning and the end of the innermost defun around point. Major modes based on the tree-sitter library provide control of this behavior: if the variable treesit-defun-tactic is set to the value top-level, the defun commands will find the outermost defuns instead.


27.2.3 菜单

27.2.3 Imenu

Imenu 工具提供了一种按名称查找文件中主要定义的方法。它在文本格式化程序主要模式中也很有用,它将每个章节、部分等视为定义。 (有关同时处理多个文件的更强大功能, 请参阅查找标识符引用。)

The Imenu facility offers a way to find the major definitions in a file by name. It is also useful in text formatter major modes, where it treats each chapter, section, etc., as a definition. (See Find Identifier References, for a more powerful feature that handles multiple files together.)

如果您键入M-g i( imenu),它会使用微型缓冲区读取定义的名称,然后将指针移动到该定义。您可以使用补全来指定名称;该命令始终显示有效名称的完整列表。

If you type M-g i (imenu), it reads the name of a definition using the minibuffer, then moves point to that definition. You can use completion to specify the name; the command always displays the whole list of valid names.

或者,您可以将该命令绑定imenu到鼠标单击。然后它会显示鼠标菜单供您选择定义名称。您还可以通过调用将缓冲区的索引添加到菜单栏 imenu-add-menubar-index。如果您希望此菜单栏项可用于某个主要模式下的所有缓冲区,您可以通过添加imenu-add-menubar-index到其模式挂钩来实现。但如果您这样做了,每次在该模式下访问文件时,您都必须等待一段时间,而 Emacs 会查找该缓冲区中的所有定义。

Alternatively, you can bind the command imenu to a mouse click. Then it displays mouse menus for you to select a definition name. You can also add the buffer’s index to the menu bar by calling imenu-add-menubar-index. If you want to have this menu bar item available for all buffers in a certain major mode, you can do this by adding imenu-add-menubar-index to its mode hook. But if you have done that, you will have to wait a little while each time you visit a file in that mode, while Emacs finds all the definitions in that buffer.

当您更改缓冲区的内容时,如果您添加或删除定义,则可以通过调用 '*重新扫描*' 菜单中的项目。如果您设置imenu-auto-rescan为非值,则会自动进行重新扫描nil。无需因为文本的微小变化而重新扫描。

When you change the contents of a buffer, if you add or delete definitions, you can update the buffer’s index based on the new contents by invoking the ‘*Rescan*’ item in the menu. Rescanning happens automatically if you set imenu-auto-rescan to a non-nil value. There is no need to rescan because of small changes in the text.

imenu-auto-rescan将在大于字节的缓冲区中禁用imenu-auto-rescan-maxout,如果扫描时间超过imenu-max-index-time几秒,则停止扫描。

imenu-auto-rescan will be disabled in buffers that are larger than imenu-auto-rescan-maxout in bytes, and scanning is stopped if it takes more than imenu-max-index-time seconds.

您可以通过设置变量来自定义菜单的排序方式imenu-sort-function。默认情况下,名称按照它们在缓冲区中出现的顺序进行排序;如果您想要按字母顺序排序,请使用符号imenu--sort-by-name作为值。您还可以通过编写 Lisp 代码来定义自己的比较函数。

You can customize the way the menus are sorted by setting the variable imenu-sort-function. By default, names are ordered as they occur in the buffer; if you want alphabetic sorting, use the symbol imenu--sort-by-name as the value. You can also define your own comparison function by writing Lisp code.

如果为当前缓冲区的项目(请参阅使用项目)和当前缓冲区的主要模式激活了 Eglot ,则 Eglot 会提供自己的工具,用于根据管理当前缓冲区的语言服务器对程序源的分析来生成缓冲区的索引。请参阅Eglot中的Eglot 功能:Emacs LSP 客户端

If Eglot is activated for the current buffer’s project (see Working with Projects) and the current buffer’s major mode, Eglot provides its own facility for producing the buffer’s index based on the analysis of the program source by the language-server which manages the current buffer. See Eglot Features in Eglot: The Emacs LSP Client.

Imenu 提供指导哪种功能模式的信息(请参阅哪种功能模式)。 Speedbar 也可以使用它(请参阅Speedbar 框架)。

Imenu provides the information to guide Which Function mode (see Which Function Mode). The Speedbar can also use it (see Speedbar Frames).


27.2.4 哪种功能模式

27.2.4 Which Function Mode

哪个函数模式是全局次要模式(请参阅次要模式),它在模式行中显示当前函数名称,并在您在缓冲区中移动时更新它。

Which Function mode is a global minor mode (see Minor Modes) which displays the current function name in the mode line, updating it as you move around in a buffer.

要启用或禁用 Which Function 模式,请使用命令 M-x which-function-mode。其中Function模式是全局次要模式。默认情况下,它在所有知道如何支持它的主要模式下生效(即所有支持Imenu的主要模式)。您可以通过将变量的值which-func-modest(这意味着支持所有可用的主要模式)更改为主要模式名称列表来将其限制为特定的主要模式列表。

To either enable or disable Which Function mode, use the command M-x which-function-mode. Which Function mode is a global minor mode. By default, it takes effect in all major modes that know how to support it (i.e., all the major modes that support Imenu). You can restrict it to a specific list of major modes by changing the value of the variable which-func-modes from t (which means to support all available major modes) to a list of major mode names.


27.3 程序的缩进

27.3 Indentation for Programs

保持程序正确缩进的最佳方法是在更改程序时使用 Emacs 重新缩进。 Emacs 具有用于缩进单行、指定行数或单个括号分组内的所有行的命令。

The best way to keep a program properly indented is to use Emacs to reindent it as you change it. Emacs has commands to indent either a single line, a specified number of lines, or all of the lines inside a single parenthetical grouping.

有关缩进的一般信息,请参阅缩进。本节介绍特定于编程语言模式的缩进功能。

See Indentation, for general information about indentation. This section describes indentation features specific to programming language modes.

Emacs 还在包中提供了一个 Lisp 漂亮打印机pp,它可以用漂亮的缩进重新格式化 Lisp 对象。请参阅Emacs Lisp 参考手册中的pp

Emacs also provides a Lisp pretty-printer in the pp package, which reformats Lisp objects with nice-looking indentation. See pp in The Emacs Lisp Reference Manual.


27.3.1 基本程序缩进命令

27.3.1 Basic Program Indentation Commands

TAB
TAB

调整当前行的缩进 ( indent-for-tab-command)。

Adjust indentation of current line (indent-for-tab-command).

RET
RET

插入换行符,然后调整下一行的缩进 ( newline)。

Insert a newline, then adjust indentation of following line (newline).

基本的缩进命令是TAB ( indent-for-tab-command),其记录在 Indentation中。在编程语言模式中,TAB 根据前一行的缩进和语法内容缩进当前行;如果该区域处于活动状态,则 TAB缩进该区域内的每一行,而不仅仅是当前行。

The basic indentation command is TAB (indent-for-tab-command), which was documented in Indentation. In programming language modes, TAB indents the current line, based on the indentation and syntactic content of the preceding lines; if the region is active, TAB indents each line within the region, not just the current line.

命令RET( newline)(在插入文本C-j中进行了记录)的作用与后面的 命令相同TAB:它插入一个新行,然后调整该行的缩进。

The command RET (newline), which was documented in Inserting Text, does the same as C-j followed by TAB: it inserts a new line, then adjusts the line’s indentation.

当缩进在括号分组内开始的行时,Emacs 通常将行的开头放在组内的前一行下方,或者放在括号后面的文本下方。如果您手动为这些行之一指定非标准缩进(例如,出于美观目的),则下面的行将跟随它。

When indenting a line that starts within a parenthetical grouping, Emacs usually places the start of the line under the preceding line within the group, or under the text after the parenthesis. If you manually give one of these lines a nonstandard indentation (e.g., for aesthetic purposes), the lines below will follow it.

大多数编程语言模式的缩进命令假定左侧的左括号、左大括号或其他左分隔符是函数的开始。如果您正在编辑的代码违反了此假设(即使分隔符出现在字符串或注释中),则必须将缩进open-paren-in-column-0-is-defun-start 设置nil为 才能正常工作。请参阅左边距约定

The indentation commands for most programming language modes assume that an open-parenthesis, open-brace or other opening delimiter at the left margin is the start of a function. If the code you are editing violates this assumption—even if the delimiters occur in strings or comments—you must set open-paren-in-column-0-is-defun-start to nil for indentation to work properly. See Left Margin Convention.


27.3.2 缩进多行

27.3.2 Indenting Several Lines

有时,您可能想一次重新缩进多行代码。一种方法是使用标记;当标记处于活动状态并且该区域非空时,TAB缩进该区域中的每一行。或者,命令C-M-\( indent-region) 缩进区域中的每一行,无论标记是否处于活动状态(请参阅缩进命令)。

Sometimes, you may want to reindent several lines of code at a time. One way to do this is to use the mark; when the mark is active and the region is non-empty, TAB indents every line in the region. Alternatively, the command C-M-\ (indent-region) indents every line in the region, whether or not the mark is active (see Indentation Commands).

此外,Emacs 还提供了以下命令来缩进大块代码:

In addition, Emacs provides the following commands for indenting large chunks of code:

C-M-q
C-M-q

重新缩进一组括号内的所有行。

Reindent all the lines within one parenthetical grouping.

C-u TAB
C-u TAB

将整个括号组严格地横向移动,以便其第一行正确缩进。

Shift an entire parenthetical grouping rigidly sideways so that its first line is properly indented.

M-x indent-code-rigidly
M-x indent-code-rigidly

严格地向侧面移动该区域中的所有行,但不要更改在注释和字符串内开始的行。

Shift all the lines in the region rigidly sideways, but do not alter lines that start inside comments and strings.

要重新缩进单个括号分组的内容,请将 point 放在分组开头之前并键入 C-M-q。这会更改分组内的相对缩进,而不影响其整体缩进(即分组开始的行的缩进)。运行的函数 C-M-q取决于主模式;它 indent-pp-sexp处于 Lisp 模式、c-indent-expC 模式等。要更正整体缩进,请先键入TAB

To reindent the contents of a single parenthetical grouping, position point before the beginning of the grouping and type C-M-q. This changes the relative indentation within the grouping, without affecting its overall indentation (i.e., the indentation of the line where the grouping starts). The function that C-M-q runs depends on the major mode; it is indent-pp-sexp in Lisp mode, c-indent-exp in C mode, etc. To correct the overall indentation as well, type TAB first.

如果您喜欢分组内的相对缩进,但不喜欢其第一行的缩进,请将 point 移至第一行并键入 。在 Lisp、C 和其他一些主要模式中, 使用数字参数照常重新缩进当前行,然后以相同的量重新缩进从当前行开始的括号分组中的所有行。不过,它很聪明,并且不会改变从字符串内部开始的行。在 C 模式下,它也不会改变 C 预处理器行,但它会重新缩进可能附加到它们的任何连续行。 C-u TABTAB

If you like the relative indentation within a grouping but not the indentation of its first line, move point to that first line and type C-u TAB. In Lisp, C, and some other major modes, TAB with a numeric argument reindents the current line as usual, then reindents by the same amount all the lines in the parenthetical grouping starting on the current line. It is clever, though, and does not alter lines that start inside strings. Neither does it alter C preprocessor lines when in C mode, but it does reindent any continuation lines that may be attached to them.

该命令M-x indent-code-rigidly严格地将区域中的所有行横向移动,就像indent-rigidly所做的那样(请参阅缩进命令)。它不会改变在字符串内开始的行的缩进,除非该区域也在该字符串内开始。前缀 arg 指定要缩进的列数。

The command M-x indent-code-rigidly rigidly shifts all the lines in the region sideways, like indent-rigidly does (see Indentation Commands). It doesn’t alter the indentation of lines that start inside a string, unless the region also starts inside that string. The prefix arg specifies the number of columns to indent.


27.3.3 自定义 Lisp 缩进

27.3.3 Customizing Lisp Indentation

Lisp 表达式的缩进模式取决于表达式调用的函数。对于每个 Lisp 函数,您可以在几种预定义的缩进模式中进行选择,或者使用 Lisp 程序定义任意一种缩进模式。

The indentation pattern for a Lisp expression can depend on the function called by the expression. For each Lisp function, you can choose among several predefined patterns of indentation, or define an arbitrary one with a Lisp program.

标准的缩进模式如下:如果第一个参数与表达式的开头位于同一行,则表达式的第二行缩进到第一个参数下方;否则,第二行将在函数名称下方缩进。接下来的每一行都缩进到嵌套深度相同的前一行下方。

The standard pattern of indentation is as follows: the second line of the expression is indented under the first argument, if that is on the same line as the beginning of the expression; otherwise, the second line is indented underneath the function name. Each following line is indented under the previous line whose nesting depth is the same.

如果变量lisp-indent-offset为 non- nil,它会覆盖表达式第二行的常用缩进模式,因此此类行始终缩进lisp-indent-offset比包含列表更多的列。

If the variable lisp-indent-offset is non-nil, it overrides the usual indentation pattern for the second line of an expression, so that such lines are always indented lisp-indent-offset more columns than the containing list.

某些函数会覆盖标准模式。名称以 开头的函数将第二行视为正文def的开头,方法是将第二行 附加列缩进超出开始表达式的左括号。 lisp-body-indent

Certain functions override the standard pattern. Functions whose names start with def treat the second lines as the start of a body, by indenting the second line lisp-body-indent additional columns beyond the open-parenthesis that starts the expression.

您可以根据lisp-indent-function函数名称的属性,以各种方式覆盖各个函数的标准模式。这通常是使用构造来完成宏定义的declare。请参阅Emacs Lisp 参考手册中的定义宏

You can override the standard pattern in various ways for individual functions, according to the lisp-indent-function property of the function name. This is normally done for macro definitions, using the declare construct. See Defining Macros in The Emacs Lisp Reference Manual.

在 Emacs Lisp 中,列表通常是缩进的,就好像它们是类似函数的形式:

In Emacs Lisp, lists are usually indented as if they are function-like forms:

(setq foo '(酒吧 zot
                加松克))
(setq foo '(bar zot
                gazonk))

然而,如果你在左括号后添加一个空格,这会告诉 Emacs 这是一个数据列表而不是一段代码,然后 Emacs 会像这样缩进:

However, if you add a space after the opening parenthesis, this tells Emacs that it’s a data list instead of a piece of code, and Emacs will then indent it like this:

(setq foo '( 酒吧 zot
             加松克))
(setq foo '( bar zot
             gazonk))

27.3.4 C 缩进命令

27.3.4 Commands for C Indentation

以下是 C 模式和相关模式中缩进的特殊功能:

Here are special features for indentation in C mode and related modes:

C-c C-q
C-c C-q

重新缩进当前顶级函数定义或聚合类型声明(c-indent-defun在 CC 模式下, c-ts-mode-indent-defun基于c-ts-mode树守护者)。

Reindent the current top-level function definition or aggregate type declaration (c-indent-defun in CC mode, c-ts-mode-indent-defun in c-ts-mode based on tree-sitter).

C-M-q
C-M-q

重新缩进平衡表达式中的每一行(请参阅带平衡括号的表达式),也称为“sexp”,位于点后面。在 CC 模式下,这会调用 c-indent-exp;在基于树保姆的情况下c-ts-mode,这会调用更通用的prog-indent-sexp.前缀参数禁止显示有关无效语法的警告消息。

Reindent each line in the balanced expression (see Expressions with Balanced Parentheses), also known as “sexp”, that follows point. In CC mode, this invokes c-indent-exp; in tree-sitter based c-ts-mode this invokes a more general prog-indent-sexp. A prefix argument inhibits warning messages about invalid syntax.

TAB
TAB

重新缩进当前行、活动区域或从此行开始的块 ( c-indent-line-or-region)。使用前缀参数,如果当前行需要重新缩进,则严格重新缩进从当前行开始的平衡表达式。

如果c-tab-always-indentt,则此命令始终重新缩进当前行并且不执行任何其他操作。这是默认设置。

如果该变量为nil,则仅当点位于左边距或行缩进中时,此命令才会重新缩进当前行;否则,它会插入一个制表符(或同等数量的空格,如果indent-tabs-mode是的话nil)。

任何其他值(notnilt)意味着始终重新缩进该行,并且如果在注释或字符串中则插入制表符。

Reindent the current line, active region, or block starting on this line (c-indent-line-or-region). With prefix argument, rigidly reindent the balanced expression which starts on the current line, if the current line needs reindentation.

If c-tab-always-indent is t, this command always reindents the current line and does nothing else. This is the default.

If that variable is nil, this command reindents the current line only if point is at the left margin or in the line’s indentation; otherwise, it inserts a tab (or the equivalent number of spaces, if indent-tabs-mode is nil).

Any other value (not nil or t) means always reindent the line, and also insert a tab if within a comment or a string.

要重新缩进整个当前缓冲区,请键入C-x h C-M-\。首先选择整个缓冲区作为区域,然后重新缩进该区域。

To reindent the whole current buffer, type C-x h C-M-\. This first selects the whole buffer as the region, then reindents that region.

要重新缩进当前块,请使用C-M-u C-M-q.这会移动到块的前面,然后将其全部重新缩进。

To reindent the current block, use C-M-u C-M-q. This moves to the front of the block and then reindents it all.


27.3.5 自定义 C 缩进

27.3.5 Customizing C Indentation

C 模式和相关模式使用灵活的机制来自定义缩进。 C 模式分两步缩进源代码行:首先,根据内容和上下文对行进行语法分类;其次,它确定与所选样式与语法结构相关联的缩进偏移量,并将其添加到锚语句的缩进中。

C mode and related modes use a flexible mechanism for customizing indentation. C mode indents a source line in two steps: first it classifies the line syntactically according to its contents and context; second, it determines the indentation offset associated by your selected style with the syntactic construct and adds this onto the indentation of the anchor statement.

C-c . style RET
C-c . style RET

选择预定义的样式c-set-styleCC 模式下, c-ts-mode-set-style基于c-ts-mode树保姆)。

Select a predefined style style (c-set-style in CC mode, c-ts-mode-set-style in c-ts-mode based on tree-sitter).

样式可在 C 模式和相关模式中使用的命名的自定义集合。 CC 模式手册中的样式,有完整的描述。 Emacs 附带了多种预定义样式,包括, , , , , , , , ,和。其中一些样式主要适用于一种语言,但其中任何一种都可以与这些模式支持的任何语言一起使用。要了解样式的外观,请选择它并重新缩进一些代码,例如,通过在函数定义的开头键入。 gnuk&rbsdstroustruplinuxpythonjavawhitesmithellemtelawkC-M-q

A style is a named collection of customizations that can be used in C mode and the related modes. Styles in The CC Mode Manual, for a complete description. Emacs comes with several predefined styles, including gnu, k&r, bsd, stroustrup, linux, python, java, whitesmith, ellemtel, and awk. Some of these styles are primarily intended for one language, but any of them can be used with any of the languages supported by these modes. To find out what a style looks like, select it and reindent some code, e.g., by typing C-M-q at the start of a function definition.

要为当前缓冲区选择样式,请使用命令C-c .。指定样式名称作为参数(大小写不重要)。该命令仅影响当前缓冲区,并且仅影响将来调用的缩进命令;它不会重新缩进缓冲区中已有的代码。要以新样式重新缩进整个缓冲区,您可以键入C-x h C-M-\

To choose a style for the current buffer, use the command C-c .. Specify a style name as an argument (case is not significant). This command affects the current buffer only, and it affects only future invocations of the indentation commands; it does not reindent the code already in the buffer. To reindent the whole buffer in the new style, you can type C-x h C-M-\.

使用CC模式时,还可以设置该变量 c-default-style来指定各种主要模式的默认样式。它的值应该是样式的名称(字符串)或列表,其中每个元素指定一种主要模式以及要使用的缩进样式。例如,

When using CC mode, you can also set the variable c-default-style to specify the default style for various major modes. Its value should be either the style’s name (a string) or an alist, in which each element specifies one major mode and which indentation style to use for it. For example,

(setq c-默认样式
      '((java-模式.“java”)
        (awk 模式。“awk”)
        (其他。“gnu”)))
(setq c-default-style
      '((java-mode . "java")
        (awk-mode . "awk")
        (other . "gnu")))

指定 Java 和 AWK 模式的显式选择,以及默认的 '格努' 其他类 C 模式的样式。 (这些设置实际上是默认设置。)当您选择一种类 C 主要模式时,此变量才会生效;因此,如果为 Java 模式指定新的默认样式,则可以通过在现有的 Java 模式缓冲区中键入来使其生效M-x java-mode

specifies explicit choices for Java and AWK modes, and the default ‘gnu’ style for the other C-like modes. (These settings are actually the defaults.) This variable takes effect when you select one of the C-like major modes; thus, if you specify a new default style for Java mode, you can make it take effect in an existing Java mode buffer by typing M-x java-mode there.

使用tree-sitter based时c-ts-mode,可以通过自定义变量来设置默认的缩进样式 c-ts-mode-indent-style

When using the tree-sitter based c-ts-mode, you can set the default indentation style by customizing the variable c-ts-mode-indent-style.

样式gnu指定 GNU 项目推荐的 C 格式;它是默认的,以鼓励使用我们推荐的样式。

The gnu style specifies the formatting recommended by the GNU Project for C; it is the default, so as to encourage use of our recommended style.

有关自定义 C 和相关模式缩进的更多信息,包括如何覆盖现有样式的部分以及如何定义您自己的样式, 请参阅CC 模式手册中的缩进引擎基础知识CC 模式手册中的自定义缩进。

See Indentation Engine Basics in the CC Mode Manual, and Customizing Indentation in the CC Mode Manual, for more information on customizing indentation for C and related modes, including how to override parts of an existing style and how to define your own styles.

作为指定样式的替代方法,您可以通过M-x c-guess在示例代码缓冲区中键入来告诉 Emacs 猜测样式。然后,您可以将猜测的样式应用到其他缓冲区M-x c-guess-install。有关详细信息,请参阅CC 模式手册中的猜测风格

As an alternative to specifying a style, you can tell Emacs to guess a style by typing M-x c-guess in a sample code buffer. You can then apply the guessed style to other buffers with M-x c-guess-install. See Guessing the Style in the CC Mode Manual, for details.


27.4 带括号的编辑命令

27.4 Commands for Editing with Parentheses

本节介绍在程序中利用括号结构或帮助您保持平衡的命令和功能。

This section describes the commands and features that take advantage of the parenthesis structure in a program, or help you keep it balanced.

当谈论这些设施时,术语“括号”还包括大括号、方括号或定义为成对匹配的任何分隔符。主要模式通过语法表控制哪些定界符是重要的(请参阅Emacs Lisp 参考手册中的语法表)。在 Lisp 中,只有括号才算数;在 C 语言中,这些命令也适用于大括号和方括号。

When talking about these facilities, the term “parenthesis” also includes braces, brackets, or whatever delimiters are defined to match in pairs. The major mode controls which delimiters are significant, through the syntax table (see Syntax Tables in The Emacs Lisp Reference Manual). In Lisp, only parentheses count; in C, these commands apply to braces and brackets too.

您可以使用它M-x check-parens来查找缓冲区中任何不平衡的括号和不平衡的字符串引号。

You can use M-x check-parens to find any unbalanced parentheses and unbalanced string quotes in the buffer.


27.4.1 带平衡括号的表达式

27.4.1 Expressions with Balanced Parentheses

每种编程语言模式都有自己的 平衡表达式定义。平衡表达式通常包括单独的符号、数字和字符串常量,以及包含在一对匹配的分隔符中的代码段。以下命令处理平衡表达式(在 Emacs 中,此类表达式在内部称为sexps 14)。

Each programming language mode has its own definition of a balanced expression. Balanced expressions typically include individual symbols, numbers, and string constants, as well as pieces of code enclosed in a matching pair of delimiters. The following commands deal with balanced expressions (in Emacs, such expressions are referred to internally as sexps14).

C-M-f
C-M-f

在平衡表达式 ( ) 上前进forward-sexp

Move forward over a balanced expression (forward-sexp).

C-M-b
C-M-b

向后移动平衡表达式 ( backward-sexp)。

Move backward over a balanced expression (backward-sexp).

C-M-k
C-M-k

向前杀死平衡表达式 ( kill-sexp)。

Kill balanced expression forward (kill-sexp).

C-M-t
C-M-t

转置表达式 ( transpose-sexps)。

Transpose expressions (transpose-sexps).

C-M-@
C-M-@
C-M-SPC
C-M-SPC

在下面的表达式后加上标记(mark-sexp)。

Put mark after following expression (mark-sexp).

要在平衡表达式上前进,请使用C-M-f ( forward-sexp)。如果点之后的第一个有效字符是开始分隔符(例如,'','[' 或者 '{' 在 C) 中,该命令移过匹配的结束分隔符。如果该字符以符号、字符串或数字开头,则命令将移至其上方。

To move forward over a balanced expression, use C-M-f (forward-sexp). If the first significant character after point is an opening delimiter (e.g., ‘(’, ‘[’ or ‘{’ in C), this command moves past the matching closing delimiter. If the character begins a symbol, string, or number, the command moves over that.

命令C-M-b( backward-sexp) 在平衡表达式上向后移动,类似于C-M-f,但方向相反。如果表达式前面有任何前缀字符(Lisp 中的单引号、反引号和逗号),则命令也会向后移动到它们之上。

The command C-M-b (backward-sexp) moves backward over a balanced expression—like C-M-f, but in the reverse direction. If the expression is preceded by any prefix characters (single-quote, backquote and comma, in Lisp), the command moves back over them as well.

C-M-fC-M-b使用参数重复该操作指定的次数;带有否定参数意味着朝相反方向移动。在大多数模式下,这两个命令在注释之间移动,就像它们是空格一样。请注意,它们的键 C-M-fC-M-b类似于按字符移动的 和 ,按字符移动(请参阅更改 C-f的位置)和按单词移动(请参阅单词)。 C-bM-fM-b

C-M-f or C-M-b with an argument repeats that operation the specified number of times; with a negative argument means to move in the opposite direction. In most modes, these two commands move across comments as if they were whitespace. Note that their keys, C-M-f and C-M-b, are analogous to C-f and C-b, which move by characters (see Changing the Location of Point), and M-f and M-b, which move by words (see Words).

要终止整个平衡表达式,请输入C-M-k ( kill-sexp)。这会杀死C-M-f要移动 的文本。

To kill a whole balanced expression, type C-M-k (kill-sexp). This kills the text that C-M-f would move over.

C-M-t( transpose-sexps) 交换上一个平衡表达式和下一个平衡表达式的位置。它类似于 C-t转置字符的命令(请参阅转置文本)。的参数用作C-M-t重复计数,将前一个表达式移动到许多后续表达式上。否定参数将先前的平衡表达式向后移动到之前的表达式。参数为零,而不是不执行任何操作,而是转置在点和标记处或之后结束的平衡表达式。

C-M-t (transpose-sexps) switches the positions of the previous balanced expression and the next one. It is analogous to the C-t command, which transposes characters (see Transposing Text). An argument to C-M-t serves as a repeat count, moving the previous expression over that many following ones. A negative argument moves the previous balanced expression backwards across those before it. An argument of zero, rather than doing nothing, transposes the balanced expressions ending at or after point and the mark.

要使用作用于区域的命令对平衡表达式进行操作,请键入( )。这设置了要移动到的标记。当标记处于活动状态时,每次连续调用此命令都会通过将标记移动一个表达式来扩展区域。正或负数值参数将标记向前或向后移动指定数量的表达式。别名相当于.有关此命令和相关命令的更多信息, 请参阅标记文本对象的命令。C-M-SPCmark-sexpC-M-fC-M-@C-M-SPC

To operate on balanced expressions with a command which acts on the region, type C-M-SPC (mark-sexp). This sets the mark where C-M-f would move to. While the mark is active, each successive call to this command extends the region by shifting the mark by one expression. Positive or negative numeric arguments move the mark forward or backward by the specified number of expressions. The alias C-M-@ is equivalent to C-M-SPC. See Commands to Mark Textual Objects, for more information about this and related commands.

在使用中缀运算符的语言(例如 C)中,不可能识别所有平衡表达式,因为给定位置可能存在多种可能性。例如,C 模式不处理 '富+酒吧' 作为单个表达式,即使它一个 C 表达式;相反,它识别 '' 作为一个表达式并且 '酒吧' 作为另一个,与 '+' 作为它们之间的标点符号。然而,C 模式识别 '(富+酒吧)' 作为单个表达式,因为有括号。

In languages that use infix operators, such as C, it is not possible to recognize all balanced expressions because there can be multiple possibilities at a given position. For example, C mode does not treat ‘foo + bar’ as a single expression, even though it is one C expression; instead, it recognizes ‘foo’ as one expression and ‘bar’ as another, with the ‘+’ as punctuation between them. However, C mode recognizes ‘(foo + bar)’ as a single expression, because of the parentheses.


27.4.2 在括号结构中移动

27.4.2 Moving in the Parenthesis Structure

以下命令移动由括号(或您正在使用的语言中充当分隔符的任何其他内容)分隔的分组。它们忽略字符串和注释,包括其中的任何括号,并且还忽略用转义字符引用的括号。这些命令主要用于编辑程序,但对于编辑任何包含括号的文本也很有用。它们在内部被称为“列表命令”,因为在 Lisp 中这些分组是列表。

The following commands move over groupings delimited by parentheses (or whatever else serves as delimiters in the language you are working with). They ignore strings and comments, including any parentheses within them, and also ignore parentheses that are quoted with an escape character. These commands are mainly intended for editing programs, but can be useful for editing any text containing parentheses. They are referred to internally as “list commands” because in Lisp these groupings are lists.

这些命令假定起点不在字符串或注释内。如果从字符串或注释内部调用它们,结果是不可靠的。

These commands assume that the starting point is not inside a string or a comment. If you invoke them from inside a string or comment, the results are unreliable.

C-M-n
C-M-n

向前移动到括号组 ( forward-list)。

Move forward over a parenthetical group (forward-list).

C-M-p
C-M-p

向后移动到括号组 ( backward-list)。

Move backward over a parenthetical group (backward-list).

C-M-u
C-M-u

在括号结构 ( ) 中向上移动backward-up-list

Move up in parenthesis structure (backward-up-list).

C-M-d
C-M-d

括号结构中向下移动 ( down-list)。

Move down in parenthesis structure (down-list).

列表命令C-M-n( forward-list) 和 C-M-p( ) 在一个(或n 个)括号 backward-list内向前或向后移动。

The list commands C-M-n (forward-list) and C-M-p (backward-list) move forward or backward over one (or n) parenthetical groupings.

C-M-nC-M-p尽量在括号结构中保持同一水平。要向上移动一级(或n级),请使用 C-M-u( backward-up-list)。 C-M-u向后移动超过一个不匹配的起始分隔符。正数作为重复计数;负参数会反转运动方向,以便命令向前移动并向上移动一层或多层。

C-M-n and C-M-p try to stay at the same level in the parenthesis structure. To move up one (or n) levels, use C-M-u (backward-up-list). C-M-u moves backward up past one unmatched opening delimiter. A positive argument serves as a repeat count; a negative argument reverses the direction of motion, so that the command moves forward and up one or more levels.

要在括号结构中向下C-M-d移动,请使用 ( down-list)。在 Lisp 模式下,其中 '' 是唯一的开始分隔符,这几乎与搜索 ' 相同'。参数指定要下降的级别数。

To move down in the parenthesis structure, use C-M-d (down-list). In Lisp mode, where ‘(’ is the only opening delimiter, this is nearly the same as searching for a ‘(’. An argument specifies the number of levels to go down.


27.4.3 匹配括号

27.4.3 Matching Parentheses

Emacs 具有许多括号匹配功能,可以轻松查看括号(或其他分隔符)如何匹配以及是否匹配。

Emacs has a number of parenthesis matching features, which make it easy to see how and whether parentheses (or other delimiters) match up.

每当您键入作为结束分隔符的自插入字符时,Emacs 都会简要指示匹配的开始分隔符的位置(前提是该字符位于屏幕上)。如果它不在屏幕上,Emacs 会在回显区域中显示其附近的一些文本。无论哪种方式,您都可以知道要关闭哪个分组。如果开始分隔符和结束分隔符不匹配,例如 '[X)'—一条警告消息显示在回波区域中。

Whenever you type a self-inserting character that is a closing delimiter, Emacs briefly indicates the location of the matching opening delimiter, provided that is on the screen. If it is not on the screen, Emacs displays some of the text near it in the echo area. Either way, you can tell which grouping you are closing off. If the opening delimiter and closing delimiter are mismatched—such as in ‘[x)’—a warning message is displayed in the echo area.

三个变量控制匹配括号的显示:

Three variables control the display of matching parentheses:

  • blink-matching-paren打开或关闭该功能:nil 禁用它,但默认情况下是t启用它。将其设置为 jump通过将光标暂时移动到匹配的开始分隔符来使指示起作用。将其设置为jump-offscreen以使光标跳转,即使起始分隔符在屏幕外也是如此。
  • blink-matching-paren turns the feature on or off: nil disables it, but the default is t to enable it. Set it to jump to make indication work by momentarily moving the cursor to the matching opening delimiter. Set it to jump-offscreen to make the cursor jump, even if the opening delimiter is off screen.
  • blink-matching-delay表示保持指示匹配的开始分隔符的秒数。这可以是整数或浮点数;默认值为 1。
  • blink-matching-delay says how many seconds to keep indicating the matching opening delimiter. This may be an integer or floating-point number; the default is 1.
  • blink-matching-paren-distance指定返回搜索多少个字符以查找匹配的开始分隔符。如果在该距离内未找到匹配项,Emacs 将停止扫描并且不显示任何内容。默认值为 102400。
  • blink-matching-paren-distance specifies how many characters back to search to find the matching opening delimiter. If the match is not found in that distance, Emacs stops scanning and nothing is displayed. The default is 102400.

Show Paren 模式是一种次要模式,提供更强大的自动匹配。每当点位于开始分隔符之前或结束分隔符之后时,该分隔符、其匹配的分隔符以及它们之间的文本(可选)都会突出显示。要全局切换 Show Paren 模式,请键入M-x show-paren-mode。要仅在当前缓冲区中切换它,请键入M-x show-paren-local-mode

Show Paren mode is a minor mode that provides a more powerful kind of automatic matching. Whenever point is before an opening delimiter or after a closing delimiter, the delimiter, its matching delimiter, and optionally the text between them are highlighted. To toggle Show Paren mode globally, type M-x show-paren-mode. To toggle it only in the current buffer, type M-x show-paren-local-mode.

默认情况下,此模式在所有用于编辑的缓冲区中打开,但在显示数据的缓冲区中不启用。这是由show-paren-predicate用户选项控制的。

By default, this mode is switched on in all buffers that are meant for editing, but is not enabled in buffers that show data. This is controlled by the show-paren-predicate user option.

要自定义模式,请键入。控制此模式操作的可自定义选项包括: M-x customize-group RET paren-showing

To customize the mode, type M-x customize-group RET paren-showing. The customizable options which control the operation of this mode include:

  • show-paren-highlight-openparen控制当点位于其前面时是否突出显示左括号,因此无论如何它的位置都会由光标标记。默认为非nil(是)。
  • show-paren-highlight-openparen controls whether to highlight an open paren when point is just before it, and hence its position is marked by the cursor anyway. The default is non-nil (yes).
  • show-paren-style控制是否仅突出显示两个括号或它们之间的文本。这里的有效选项是 parenthesis(显示匹配的括号)、expression (突出显示括号内的整个表达式)和 mixed(如果匹配的括号在窗口中可见,则突出显示匹配的括号,否则突出显示表达式)。
  • show-paren-style controls whether just the two parens, or also the text between them get highlighted. The valid options here are parenthesis (show the matching paren), expression (highlight the entire expression enclosed by the parens), and mixed (highlight the matching paren if it is visible in the window, the expression otherwise).
  • show-paren-when-point-inside-paren,当非 时nil,当点位于括号内时也会导致突出显示。默认为nil.
  • show-paren-when-point-inside-paren, when non-nil, causes highlighting also when point is inside of the parentheses. The default is nil.
  • show-paren-when-point-in-periphery,当非 时nil,当 point 位于行首的空白中并且该行的第一个或最后一个非空白位置有一个括号时,或者当 point 位于行的末尾并且有行中最后一个非空白位置的括号。
  • show-paren-when-point-in-periphery, when non-nil, causes highlighting also when point is in whitespace at the beginning of a line and there is a paren at the first or last non-whitespace position on the line, or when point is at the end of a line and there is a paren at the last non-whitespace position on the line.
  • show-paren-context-when-offscreen,当非 时nil,当点位于结束分隔符且开始分隔符位于屏幕外时,会在回显区域中显示一些上下文。上下文通常是包含开始定界符的行,除非开始定界符位于其自己的行上,在这种情况下,上下文包括前一个非空行。
  • show-paren-context-when-offscreen, when non-nil, shows some context in the echo area when point is in a closing delimiter and the opening delimiter is offscreen. The context is usually the line that contains the opening delimiter, except if the opening delimiter is on its own line, in which case the context includes the previous nonblank line.

Electric Pair 模式是一种全局次要模式,提供了一种轻松插入匹配分隔符的方法:圆括号、大括号、方括号等。每当插入左分隔符时,也会自动插入匹配的右分隔符,并在两者之间留下点。相反,当您在现有分隔符上插入结束分隔符时,不会发生任何插入,并且只会跳过该位置。如果该区域处于活动状态(请参阅标记和区域),则将在该区域上插入分隔符:该区域中的字符包含在一对匹配的分隔符中,在您键入的分隔符后面留下点。

Electric Pair mode, a global minor mode, provides a way to easily insert matching delimiters: parentheses, braces, brackets, etc. Whenever you insert an opening delimiter, the matching closing delimiter is automatically inserted as well, leaving point between the two. Conversely, when you insert a closing delimiter over an existing one, no insertion takes places, and that position is simply skipped over. If the region is active (see The Mark and the Region), insertion of a delimiter operates on the region: the characters in the region are enclosed in a pair of matching delimiters, leaving point after the delimiter you typed.

这些变量控制电动配对模式的附加功能:

These variables control additional features of Electric Pair mode:

  • electric-pair-preserve-balance,当非 时nil,使默认配对逻辑平衡开始和结束分隔符的数量。
  • electric-pair-preserve-balance, when non-nil, makes the default pairing logic balance out the number of opening and closing delimiters.
  • electric-pair-delete-adjacent-pairs,当非 时nil,使两个相邻分隔符之间的退格也会自动删除结束分隔符。
  • electric-pair-delete-adjacent-pairs, when non-nil, makes backspacing between two adjacent delimiters also automatically delete the closing delimiter.
  • electric-pair-open-newline-between-pairs,当非 时nil,使得在两个相邻对之间插入换行符也会在点之后自动打开一个额外的换行符。
  • electric-pair-open-newline-between-pairs, when non-nil, makes inserting a newline between two adjacent pairs also automatically open an extra newline after point.
  • electric-pair-skip-whitespace,当非 时nil,导致次要模式在决定是否跳过结束分隔符之前向前跳过空格。
  • electric-pair-skip-whitespace, when non-nil, causes the minor mode to skip whitespace forward before deciding whether to skip over the closing delimiter.

要切换电动配对模式,请键入M-x electric-pair-mode。要在单个缓冲区中切换模式,请使用M-x electric-pair-local-mode

To toggle Electric Pair mode, type M-x electric-pair-mode. To toggle the mode in a single buffer, use M-x electric-pair-local-mode.


27.5 操纵注释

27.5 Manipulating Comments

由于注释是编程的重要组成部分,因此 Emacs 提供了用于编辑和插入注释的特殊命令。它还可以使用 Flyspell Prog 模式对注释进行拼写检查(请参阅检查和更正拼写)。

Because comments are such an important part of programming, Emacs provides special commands for editing and inserting comments. It can also do spell checking on comments with Flyspell Prog mode (see Checking and Correcting Spelling).

一些主要模式对于缩进不同类型的注释有特殊的规则。例如,在 Lisp 代码中,以两个分号开头的注释会缩进,就好像它们是代码行一样,而以三个分号开头的注释应该与左边距对齐,并且通常用于分段目的。 Emacs 理解这些约定;例如,TAB在注释行上键入会将注释缩进到适当的位置。

Some major modes have special rules for indenting different kinds of comments. For example, in Lisp code, comments starting with two semicolons are indented as if they were lines of code, while those starting with three semicolons are supposed to be aligned to the left margin and are often used for sectioning purposes. Emacs understands these conventions; for instance, typing TAB on a comment line will indent the comment to the appropriate position.

;;这个函数只是一个例子。
;;;这里两个或三个分号是合适的。
(defun foo(x)
;;;现在,该函数的第一部分:
  ;;下面一行添加一。
  (1+x)) ;这一行加了一个。
;; This function is just an example.
;;; Here either two or three semicolons are appropriate.
(defun foo (x)
;;;  And now, the first part of the function:
  ;; The following line adds one.
  (1+ x))           ; This line adds one.

27.5.1 注释命令

27.5.1 Comment Commands

以下命令对注释进行操作:

The following commands operate on comments:

M-;
M-;

在当前行插入或重新对齐注释;如果该区域处于活动状态,请注释或取消注释该区域 ( comment-dwim)。

Insert or realign comment on current line; if the region is active, comment or uncomment the region instead (comment-dwim).

C-x C-;
C-x C-;

注释或取消注释当前行 ( comment-line)。如果该区域处于活动状态,请注释或取消注释该区域中的行。

Comment or uncomment the current line (comment-line). If the region is active, comment or uncomment the lines in the region instead.

C-u M-;
C-u M-;

删除当前行的注释 ( comment-kill)。

Kill comment on current line (comment-kill).

C-x ;
C-x ;

设置注释栏(comment-set-column)。

Set comment column (comment-set-column).

C-M-j
C-M-j
M-j
M-j

RET就像随后插入并对齐注释 ( )一样default-indent-new-line。请参阅多行注释

Like RET followed by inserting and aligning a comment (default-indent-new-line). See Multiple Lines of Comments.

M-x comment-region
M-x comment-region
C-c C-c(在类 C 模式下)
C-c C-c (in C-like modes)

向该区域中的所有行添加注释分隔符。

Add comment delimiters to all the lines in the region.

创建或对齐注释的命令是M-; ( comment-dwim)。 “dwim”这个词是“Do What I Mean”的缩写;它表明该命令可以用于许多与注释相关的不同工作,具体取决于您使用它的情况。

The command to create or align a comment is M-; (comment-dwim). The word “dwim” is an acronym for “Do What I Mean”; it indicates that this command can be used for many different jobs relating to comments, depending on the situation where you use it.

当某个区域处于活动状态时(请参阅标记和区域),M-;可以向该区域添加注释分隔符,也可以将其删除。如果该区域中的每一行都已经是注释,则会通过删除注释分隔符来取消注释每一行。否则,它会添加注释分隔符以将文本括在该区域中。

When a region is active (see The Mark and the Region), M-; either adds comment delimiters to the region, or removes them. If every line in the region is already a comment, it uncomments each of those lines by removing their comment delimiters. Otherwise, it adds comment delimiters to enclose the text in the region.

如果您在区域处于活动状态时提供前缀参数M-;,则指定要添加或删除的注释分隔符的数量。正参数n添加n 个分隔符,而负参数 - n删除n分隔符。

If you supply a prefix argument to M-; when a region is active, that specifies the number of comment delimiters to add or delete. A positive argument n adds n delimiters, while a negative argument −n removes n delimiters.

如果该区域未激活,并且当前行上没有现有注释,则M-;向当前行添加新注释。如果该行为空(即空或仅包含空白字符),则注释将缩进到 TAB缩进到的相同位置(请参阅基本程序缩进命令)。如果该行非空白,则注释将放置在该行最后一个非空白字符之后。如果可能的话,Emacs 尝试将注释放在变量指定的列之间comment-columncomment-fill-column请参阅控制注释的选项)。否则,它会选择其他一些合适的位置,通常与非注释文本至少间隔一个空格。在每种情况下,Emacs 都会在注释的起始分隔符之后放置点,以便您可以立即开始输入注释文本。

If the region is not active, and there is no existing comment on the current line, M-; adds a new comment to the current line. If the line is blank (i.e., empty or containing only whitespace characters), the comment is indented to the same position where TAB would indent to (see Basic Program Indentation Commands). If the line is non-blank, the comment is placed after the last non-whitespace character on the line. Emacs tries to fit the comment between the columns specified by the variables comment-column and comment-fill-column (see Options Controlling Comments), if possible. Otherwise, it will choose some other suitable position, usually separated from the non-comment text by at least one space. In each case, Emacs places point after the comment’s starting delimiter, so that you can start typing the comment text right away.

您还可以用来M-;对齐现有注释。如果一行已经包含注释开始字符串,M-;则将其重新对齐到常规对齐方式并将点移到注释的起始分隔符之后。作为例外,从第 0 列开始的注释不会被移动。即使现有评论已正确对齐, M-;对于直接移动到评论文本的开头仍然很有用。

You can also use M-; to align an existing comment. If a line already contains the comment-start string, M-; realigns it to the conventional alignment and moves point after the comment’s starting delimiter. As an exception, comments starting in column 0 are not moved. Even when an existing comment is properly aligned, M-; is still useful for moving directly to the start of the comment text.

C-x C-;( comment-line) 注释或取消注释完整行。当某个区域处于活动状态时(请参阅标记和区域),C-x C-;可以注释或取消注释该区域中的行。如果该区域未激活,此命令将注释或取消注释该线点。使用正前缀参数n,它会在从当前行开始的n行上运行;使用负参数 - n,它会影响前面的n行。使用负参数调用此命令后,使用正参数的连续调用将在前面的行上运行,就像参数被否定一样。

C-x C-; (comment-line) comments or uncomments complete lines. When a region is active (see The Mark and the Region), C-x C-; either comments or uncomments the lines in the region. If the region is not active, this command comments or uncomments the line point is on. With a positive prefix argument n, it operates on n lines starting with the current one; with a negative argument −n, it affects n preceding lines. After invoking this command with a negative argument, successive invocations with a positive argument will operate on preceding lines as if the argument were negated.

C-u M-;comment-dwim带有前缀参数)当该区域不活动时,会杀死当前行上的任何注释及其前面的空格。由于注释已保存到 Kill Ring,因此您可以通过移动到该行的末尾,执行C-y,然后M-;重新对齐注释,将其重新插入到另一行。您可以C-u M-;通过键入实现相同的效果M-x comment-killcomment-dwim实际上,comment-kill 当给定前缀参数时,它会作为子例程进行调用)。comment-dwim使用前缀数字参数调用(如 中所示),当 没有活动区域时,会告诉 您删除n行 上的注释。C-u n M-;comment-kill

C-u M-; (comment-dwim with a prefix argument) when the region is not active kills any comment on the current line, along with the whitespace before it. Since the comment is saved to the kill ring, you can reinsert it on another line by moving to the end of that line, doing C-y, and then M-; to realign the comment. You can achieve the same effect as C-u M-; by typing M-x comment-kill (comment-dwim actually calls comment-kill as a subroutine when it is given a prefix argument). Invoking comment-dwim with a prefix numeric argument, as in C-u n M-;, when there’s no active region, tells comment-kill to kill comments on n lines.

该命令M-x comment-region相当于调用 M-;活动区域,只不过它始终作用于该区域,即使标记处于非活动状态也是如此。在 C 模式及相关模式下,该命令绑定到C-c C-c.该命令M-x uncomment-region取消该区域中每一行的注释;数字前缀参数指定要删除的注释分隔符的数量(负参数指定要添加的注释分隔符的数量)。

The command M-x comment-region is equivalent to calling M-; on an active region, except that it always acts on the region, even if the mark is inactive. In C mode and related modes, this command is bound to C-c C-c. The command M-x uncomment-region uncomments each line in the region; a numeric prefix argument specifies the number of comment delimiters to remove (negative arguments specify the number of comment delimiters to add).

M-;对于类 C 模式,您可以通过设置变量c-indent-comment-alist和 来配置 的确切效果c-indent-comments-syntactically-p。例如,在以右大括号结尾的行上,M-;将注释放在大括号后面一个空格而不是 at comment-column。有关完整详细信息,请参阅 CC 模式手册中的注释命令

For C-like modes, you can configure the exact effect of M-; by setting the variables c-indent-comment-alist and c-indent-comments-syntactically-p. For example, on a line ending in a closing brace, M-; puts the comment one space after the brace rather than at comment-column. For full details see Comment Commands in The CC Mode Manual.


27.5.2 多行注释

27.5.2 Multiple Lines of Comments

如果您正在输入注释并希望继续到另一行,请输入M-jC-M-j( default-indent-new-line)。这会中断当前行,并插入必要的注释分隔符和缩进以继续注释。

If you are typing a comment and wish to continue it to another line, type M-j or C-M-j (default-indent-new-line). This breaks the current line, and inserts the necessary comment delimiters and indentation to continue the comment.

对于带有结束注释分隔符的语言(例如,'*/' 在 C) 中, 的确切行为M-j取决于变量 的值comment-multi-line。如果值为nil,则该命令关闭旧行上的注释并在新行上开始新注释。否则,它将在当前注释分隔符内打开一个新行。

For languages with closing comment delimiters (e.g., ‘*/’ in C), the exact behavior of M-j depends on the value of the variable comment-multi-line. If the value is nil, the command closes the comment on the old line and starts a new comment on the new line. Otherwise, it opens a new line within the current comment delimiters.

当自动填充模式打开时,在键入注释时越过填充列也会继续注释,就像显式调用M-j.

When Auto Fill mode is on, going past the fill column while typing a comment also continues the comment, in the same way as an explicit invocation of M-j.

要将现有行转换为注释行,请M-;与活动区域一起使用,或M-x comment-region 按照上一节中所述的方式使用。

To turn existing lines into comment lines, use M-; with the region active, or use M-x comment-region as described in the preceding section.

您可以配置 C 模式,以便当您键入 '/' 在多行块注释的行开头,这将关闭注释。comment-close-slash为此启用清理。请参阅CC 模式手册中的清理

You can configure C Mode such that when you type a ‘/’ at the start of a line in a multi-line block comment, this closes the comment. Enable the comment-close-slash clean-up for this. See Clean-ups in The CC Mode Manual.


27.5.3 控制注释的选项

27.5.3 Options Controlling Comments

如注释命令中所述,当该M-j命令向行添加注释时,它会尝试将注释放置在缓冲区局部变量comment-column 和指定的列之间comment-fill-column(或者如果是nil,则为 的值fill-column,请参阅显式填充命令)。您可以按照通常的方式设置这些缓冲区局部变量的局部值或默认值(请参阅局部变量)。或者,您可以键入C-x ;( ) 将当前缓冲区中 comment-set-column的值设置 为点当前所在的列。设置注释列以匹配缓冲区中点之前的最后一个注释,然后执行 a 将当前行的注释与前一行的注释对齐。 comment-columnC-u C-x ;M-;

As mentioned in Comment Commands, when the M-j command adds a comment to a line, it tries to place the comment between the columns specified by the buffer-local variables comment-column and comment-fill-column (or if that is nil, then the value of fill-column, see Explicit Fill Commands). You can set either the local value or the default value of these buffer-local variables in the usual way (see Local Variables). Alternatively, you can type C-x ; (comment-set-column) to set the value of comment-column in the current buffer to the column where point is currently located. C-u C-x ; sets the comment column to match the last comment before point in the buffer, and then does a M-; to align the current line’s comment under the previous one.

注释命令根据作为变量值的正则表达式来识别注释comment-start-skip。确保此正则表达式与空字符串不匹配。它可能比严格意义上的注释起始分隔符匹配更多;例如,在 C 模式下,变量的值可以是 "/\\*+[ \t]*\\|//+[ \t]*",它匹配 ' 后的额外星号和空格/*' 本身,并接受 C++ 风格 ('//')评论也。 (注意 '\\' 在 Lisp 语法中需要包含 '\' 在字符串中,需要它来否认第一个星号在正则表达式语法中的特殊含义。请参阅正则表达式中的反斜杠。)

The comment commands recognize comments based on the regular expression that is the value of the variable comment-start-skip. Make sure this regexp does not match the null string. It may match more than the comment starting delimiter in the strictest sense of the word; for example, in C mode the value of the variable could be "/\\*+[ \t]*\\|//+[ \t]*", which matches extra stars and spaces after the ‘/*’ itself, and accepts C++ style (‘//’) comments also. (Note that ‘\\’ is needed in Lisp syntax to include a ‘\’ in the string, which is needed to deny the first star its special meaning in regexp syntax. See Backslash in Regular Expressions.)

当注释命令创建新注释时,它会插入 的值 comment-start作为开始注释分隔符。它还插入后点的值comment-end,作为结束注释分隔符。例如,在 Lisp 模式下,comment-start是 '“;”' 并且comment-end""(空字符串)。在 C 模式下,comment-startis"/* "comment-endis " */"

When a comment command makes a new comment, it inserts the value of comment-start as an opening comment delimiter. It also inserts the value of comment-end after point, as a closing comment delimiter. For example, in Lisp mode, comment-start is ‘";"’ and comment-end is "" (the empty string). In C mode, comment-start is "/* " and comment-end is " */".

该变量comment-padding指定注释命令应在注释分隔符和注释文本之间插入的字符串。默认值,'” “', 指定一个空格。或者,该值可以是一个数字,它指定空格数,或者nil,这意味着根本没有空格。

The variable comment-padding specifies a string that the commenting commands should insert between the comment delimiter(s) and the comment text. The default, ‘" "’, specifies a single space. Alternatively, the value can be a number, which specifies that number of spaces, or nil, which means no spaces at all.

该变量comment-multi-line控制如何M-j和自动填充模式在多行上继续注释。请参阅多行注释

The variable comment-multi-line controls how M-j and Auto Fill mode continue comments over multiple lines. See Multiple Lines of Comments.

该变量comment-indent-function应包含一个函数,该函数将被调用来计算新插入注释的对齐方式或对齐现有注释。不同主要模式的设置不同。调用该函数时不带参数,但在注释的开头加上点,如果要插入新注释,则在行的末尾加上点。它应该返回评论应该开始的列。例如,默认函数根据现有注释开始的注释字符数来决定。

The variable comment-indent-function should contain a function that will be called to compute the alignment for a newly inserted comment or for aligning an existing comment. It is set differently by various major modes. The function is called with no arguments, but with point at the beginning of the comment, or at the end of a line if a new comment is to be inserted. It should return the column in which the comment ought to start. For example, the default function bases its decision on how many comment characters begin an existing comment.

Emacs 还尝试对齐相邻行上的注释。为了覆盖这一点,该函数可以返回两个(可能相等)整数的 cons 以指示可接受的缩进范围。

Emacs also tries to align comments on adjacent lines. To override this, the function may return a cons of two (possibly equal) integers to indicate an acceptable range of indentation.


27.6 文档查找

27.6 Documentation Lookup

Emacs 提供了多种功能,可用于查找您计划在程序中使用的函数、变量和命令的文档。

Emacs provides several features you can use to look up the documentation of functions, variables and commands that you plan to use in your program.


27.6.1 信息文档查找

27.6.1 Info Documentation Lookup

对于适用于在 Info 中具有文档的语言的主要模式,您可以使用C-h S( info-lookup-symbol) 查看程序中使用的符号的 Info 文档。您可以使用迷你缓冲区指定符号;默认值是出现在缓冲区中的符号。例如,在 C 模式下,它会在 C 库手册中查找符号。仅当安装了相应手册的信息文件时,该命令才有效。

For major modes that apply to languages which have documentation in Info, you can use C-h S (info-lookup-symbol) to view the Info documentation for a symbol used in the program. You specify the symbol with the minibuffer; the default is the symbol appearing in the buffer at point. For example, in C mode this looks for the symbol in the C Library Manual. The command only works if the appropriate manual’s Info files are installed.

Emacs 根据主模式确定在哪里查找符号文档 - 要查找哪些信息文件以及要搜索哪些索引。您还可以用于M-x info-lookup-file查找文件名的文档。

Emacs determines where to look for documentation for the symbol—which Info files to look in, and which indices to search—based on the major mode. You can also use M-x info-lookup-file to look for documentation for a file name.

C-h S如果您在不支持的主要模式下使用,它会要求您指定符号帮助模式。您应该输入一个命令,例如c-mode选择C-h S支持的主要模式。

If you use C-h S in a major mode that does not support it, it asks you to specify the symbol help mode. You should enter a command such as c-mode that would select a major mode which C-h S does support.


27.6.2 手册页查找

27.6.2 Man Page Lookup

在 Unix 上,在线文档的主要形式是手册页手册页。在 GNU 操作系统中,我们的目标是用组织更好的手册取代手册页,您可以使用 Info 浏览这些手册(请参阅其他帮助命令)。此过程尚未完成,因此阅读手册页仍然有用。

On Unix, the main form of on-line documentation was the manual page or man page. In the GNU operating system, we aim to replace man pages with better-organized manuals that you can browse with Info (see Other Help Commands). This process is not finished, so it is still useful to read manual pages.

您可以使用命令阅读操作系统命令、库函数或系统调用的手册页M-x man。这会提示输入主题并完成(请参阅完成),并运行man程序以格式化相应的手册页。如果系统允许,它会man异步运行,以便您可以在页面格式化时继续编辑。结果进入名为的缓冲区*男人话题*。这些缓冲区使用一种特殊的主要模式,即“Man”模式,可以方便地滚动和跳转到其他手册页。有关详细信息,请C-h m在“手动”模式缓冲区中键入。

You can read the man page for an operating system command, library function, or system call, with the M-x man command. This prompts for a topic, with completion (see Completion), and runs the man program to format the corresponding man page. If the system permits, it runs man asynchronously, so that you can keep on editing while the page is being formatted. The result goes in a buffer named *Man topic*. These buffers use a special major mode, Man mode, that facilitates scrolling and jumping to other manual pages. For details, type C-h m while in a Man mode buffer.

每个手册页属于十个或更多部分之一,每个部分均由数字或数字和字母命名。有时,不同部分中会有同名的手册页。要阅读特定部分的手册页,请输入 '主题' 或者 ' 主题' 当M-x man提示输入主题时。例如,C 库函数的手册页 chmod位于第 2 节,但有一个同名的 shell 命令,其手册页位于第 1 节;要查看前者,请输入 . M-x man RET chmod(2) RET

Each man page belongs to one of ten or more sections, each named by a digit or by a digit and a letter. Sometimes there are man pages with the same name in different sections. To read a man page from a specific section, type ‘topic(section)’ or ‘section topic’ when M-x man prompts for the topic. For example, the man page for the C library function chmod is in section 2, but there is a shell command of the same name, whose man page is in section 1; to view the former, type M-x man RET chmod(2) RET.

如果不指定部分,M-x man通常仅显示找到的第一个手册页。在某些系统上,man 程序接受 '-A' 命令行选项,告诉它显示指定主题的所有手册页。要利用此功能,请将变量的值更改Man-switches为 '“-A”'。然后,在手册模式缓冲区中,您可以键入M-nM-p在不同部分的手册页之间切换。模式行显示有多少手册页可用。

If you do not specify a section, M-x man normally displays only the first man page found. On some systems, the man program accepts a ‘-a’ command-line option, which tells it to display all the man pages for the specified topic. To make use of this, change the value of the variable Man-switches to ‘"-a"’. Then, in the Man mode buffer, you can type M-n and M-p to switch between man pages in different sections. The mode line shows how many manual pages are available.

阅读手册页的另一种方法是使用M-x woman 命令。与 不同的是M-x man,它不运行任何外部程序来格式化和显示手册页;格式化是由 Emacs 完成的,因此它可以在 MS-Windows 等系统上运行,因为该man 程序可能不可用。它提示输入手册页,并将其显示在名为的缓冲区中*女性部分 主题

An alternative way of reading manual pages is the M-x woman command. Unlike M-x man, it does not run any external programs to format and display the man pages; the formatting is done by Emacs, so it works on systems such as MS-Windows where the man program may be unavailable. It prompts for a man page, and displays it in a buffer named *WoMan section topic.

M-x woman第一次调用命令时计算联机帮助页的完成列表。使用数字参数,它会重新计算该列表;如果您添加或删除手册页,这非常有用。

M-x woman computes the completion list for manpages the first time you invoke the command. With a numeric argument, it recomputes this list; this is useful if you add or delete manual pages.

如果您键入手册页的名称,并M-x woman发现不同部分中存在多个同名的手册页,则会弹出一个窗口,其中包含可能的候选者,要求您选择其中一个。

If you type a name of a manual page and M-x woman finds that several manual pages by the same name exist in different sections, it pops up a window with possible candidates asking you to choose one of them.

请注意,M-x woman尚不支持现代手册页的最新功能,因此我们建议您使用(M-x man如果您的系统可用)。

Note that M-x woman doesn’t yet support the latest features of modern man pages, so we recommend using M-x man if that is available on your system.

有关设置和使用 的更多信息M-x woman,请参阅随 Emacs 一起分发的 WoMan Info 手册。

For more information about setting up and using M-x woman, see the WoMan Info manual, which is distributed with Emacs.


27.6.3 编程语言文档查找

27.6.3 Programming Language Documentation Lookup

编辑 Emacs Lisp 代码时,可以使用命令C-h f ( describe-function) 和C-h v( describe-variable) 查看要使用的 Lisp 函数和变量的内置文档。请参阅命令或变量名称的帮助

When editing Emacs Lisp code, you can use the commands C-h f (describe-function) and C-h v (describe-variable) to view the built-in documentation for the Lisp functions and variables that you want to use. See Help by Command or Variable Name.

ElDoc 15是一种缓冲区本地次要模式,有助于查找程序中符号(函数、方法、类、变量等)的文档。启用此模式后,只要该点有记录的符号,回显区域就会显示有用的信息。例如,在 Emacs Lisp 模式下的缓冲区中,它显示函数在该点的参数列表,对于 Lisp 变量,它显示变量文档字符串的第一行。

ElDoc15 is a buffer-local minor mode that helps with looking up documentation of symbols (functions, methods, classes, variables, etc.) in your program. When this mode is enabled, the echo area displays useful information whenever there is a documented symbol at point. For example, in buffers under the Emacs Lisp mode, it shows the argument list of a function at point, and for a Lisp variable it shows the first line of the variable’s documentation string.

要切换 ElDoc 模式,请键入M-x eldoc-mode。还有一个全局 ElDoc 模式,默认情况下打开,并在其主要模式设置下面描述的变量的缓冲区中打开 ElDoc 模式。用于全局关闭它。 M-x global-eldoc-mode

To toggle ElDoc mode, type M-x eldoc-mode. There’s also a Global ElDoc mode, which is turned on by default, and turns on the ElDoc mode in buffers whose major mode sets the variables described below. Use M-x global-eldoc-mode to turn it off globally.

各种主要模式配置 Global ElDoc 模式以使用其文档功能。示例包括 Emacs Lisp 模式、Python 模式和 Cfengine 模式。此外,为几种主要模式提供支持的 Emacs 功能将 ElDoc 配置为使用其工具来检索文档。示例包括 Eglot(请参阅Eglot中的Eglot 功能:Emacs LSP 客户端),它提供基于来自语言服务器的信息的文档; Semantic 的 Idle Summary 模式(参见Semantic 手册中的Idle Summary 模式); Flymake,它使用 ElDoc 在点上显示诊断信息(请参阅GNU Flymake 手册中的查找诊断信息)。

Various major modes configure the Global ElDoc mode to use their documentation functions. Examples include Emacs Lisp mode, Python mode, and Cfengine mode. In addition, Emacs features that provide support for several major modes configure ElDoc to use their facilities for retrieving the documentation. Examples include Eglot (see Eglot Features in Eglot: The Emacs LSP Client), which provides documentation based on information from language servers; Semantic’s Idle Summary mode (see Idle Summary Mode in Semantic Manual); and Flymake, which uses ElDoc to show diagnostics at point (see Finding diagnostics in GNU Flymake manual).

ElDoc 模式的工作原理是在 Emacs 空闲一段时间后安排显示符号的可用文档。当您快速无延迟地键入时,这可以避免回显区域或模式行中文档消息出现烦人的闪烁。

The ElDoc mode works by scheduling the display of the available documentation for the symbol at point after Emacs has been idle for some short time. This avoids annoying flickering of documentation messages in the echo area or the mode line when you type quickly and without delay.

您还可以使用命令触发显示符号的文档M-x eldoc-print-current-symbol-info

You can also trigger the display of documentation for a symbol at point by using the command M-x eldoc-print-current-symbol-info.

以下变量可用于配置 ElDoc 模式:

The following variables can be used to configure ElDoc mode:

eldoc-idle-delay
eldoc-idle-delay

该用户选项的值控制显示当前文档之前的空闲时间量。应设置为等待的秒数;值为零表示没有任何延迟地显示。默认值为 0.5 秒。

The value of this user option controls the amount of idle time before the at-point documentation is displayed. It should be set to the number of seconds to wait; the value of zero means to display without any delay. The default is 0.5 sec.

eldoc-print-after-edit
eldoc-print-after-edit

如果此用户选项为非nil,ElDoc 将仅在某些编辑命令(例如插入或删除某些文本)之后显示文档。如果您希望 Emacs 仅显示有关您键入的符号的文档,而不显示有关缓冲区中已有符号的文档(因此仅阅读源代码将不会显示文档),那么这会很方便。默认值为nil。如果更改该值,则需要关闭eldoc-mode然后再次打开。

If this user option is non-nil, ElDoc will show documentation only after some editing command, like inserting or deleting some text. This comes in handy if you want Emacs to display documentation only about symbols that you type, but not about symbols that are already in the buffer (so just reading the source code will not show documentation). The default value is nil. If you change the value, you need to toggle eldoc-mode off and on again.

eldoc-echo-area-use-multiline-p
eldoc-echo-area-use-multiline-p

此用户选项控制是否以及如何截断文档文本(如果文档文本长于回显区域可以显示为单个屏幕行的长度)。如果该值为正数,则指定ElDoc允许在回显区域显示而不截断文档的屏幕行数。正整数指定要使用的绝对最大屏幕行数;浮点数指定屏幕行数作为框架高度的一部分。的值t意味着永远不会截断文档(回显区域的大小将调整到允许的高度max-mini-window-height,请参阅在迷你缓冲区中编辑),而值意味着nil如果文档长于单个屏幕行,则截断。最后,特殊值 truncate-sym-name-if-fit(默认值)意味着截断文档中表示符号名称的部分(如果这样做将使文档适合单个屏幕行)。

This user option controls whether and how to truncate documentation text if it is longer than the echo-area can display as a single screen line. If the value is a positive number, it specifies the number of screen lines that ElDoc is allowed to display in the echo area without truncating the documentation. A positive integer specifies the absolute maximum number of screen lines to use; a floating-point number specifies the number of screen lines as a fraction of the frame’s height. The value of t means never truncate the documentation (the echo-area will be resized up to the height allowed by max-mini-window-height, see Editing in the Minibuffer), whereas the value of nil means truncate if the documentation is longer than a single screen line. Finally, the special value truncate-sym-name-if-fit (the default) means to truncate the part of the documentation that represents a symbol’s name if doing that will allow the documentation to fit on a single screen line.

eldoc-echo-area-display-truncation-message
eldoc-echo-area-display-truncation-message

如果非nil(默认),并且回显区域中显示的文档由于太长而被截断,请按照文档中有关如何查看完整文档文本的说明进行操作。如果 nil,只需用 ' 表示……' 文档被截断了。

If non-nil (the default), and documentation shown in the echo area is truncated because it’s too long, follow the documentation by instructions about how to view the complete documentation text. If nil, just indicate with ‘’ that the documentation was truncated.

eldoc-echo-area-prefer-doc-buffer
eldoc-echo-area-prefer-doc-buffer

如果此用户选项的值为t,并且带有文档的 ElDoc 缓冲区已显示在某些窗口中,则 ElDoc 将不会在回显区域中显示文档。 (您可以M-x eldoc-doc-buffer随时使用该命令来显示ElDoc缓冲区。)如果该选项的值为符号maybe,则当ElDoc缓冲区显示在某些窗口中并且文档文本具有如果显示在回显区域中,则被截断。最后,(默认值)的值 nil意味着始终在回显区域中显示文档。

If the value of this user option is t, ElDoc will not show the documentation in the echo area if the ElDoc buffer with the documentation is already displayed in some window. (You can use the command M-x eldoc-doc-buffer any time to show the ElDoc buffer.) If the value of this option is the symbol maybe, the documentation will not be displayed in the echo area if the ElDoc buffer is shown in some window, and the documentation text has to be truncated if displayed in the echo area. Finally, the value of nil (the default) means always show the documentation in the echo area.

eldoc-documentation-strategy
eldoc-documentation-strategy

此可自定义变量的值是用于检索和显示该符号的文档的函数。该文档是由 hook 中的函数生成的 eldoc-documentation-functions。默认值 eldoc-documentation-strategy指定 ElDoc 应显示挂钩中函数生成的第一个文档文本 eldoc-documentation-functions,但您可以自定义 eldoc-documentation-strategy以其他方式工作,例如显示连接在一起的所有文档文本。

This customizable variable’s value is the function which is used to retrieve and display documentation for the symbol at point. The documentation is produced by the functions in the hook eldoc-documentation-functions. The default value of eldoc-documentation-strategy specifies that ElDoc should display the first documentation text produced by functions in the eldoc-documentation-functions hook, but you can customize eldoc-documentation-strategy to work in other ways, such as displaying all of the documentation texts concatenated together.

eldoc-documentation-functions
eldoc-documentation-functions

这个异常钩子的值是一个函数列表,可以为当前缓冲区的主模式生成适当的符号文档。这些函数充当 ElDoc 后端的集合。主要模式通过将其函数添加到该变量的缓冲区本地值来向 ElDoc 注册其文档查找函数。

This abnormal hook’s value is a list of functions that can produce documentation for the symbol at point as appropriate for the current buffer’s major-mode. These functions act as a collection of backends for ElDoc. Major modes register their documentation lookup functions with ElDoc by adding their functions to the buffer-local value of this variable.


27.7 Hideshow 小模式

27.7 Hideshow minor mode

Hideshow 模式是一种缓冲区本地次要模式,允许您有选择地显示程序的某些部分,这些部分称为 “块”。键入M-x hs-minor-mode以切换此次要模式(请参阅次要模式)。

Hideshow mode is a buffer-local minor mode that allows you to selectively display portions of a program, which are referred to as blocks. Type M-x hs-minor-mode to toggle this minor mode (see Minor Modes).

当您使用隐藏模式隐藏某个块时,该块将从屏幕上消失,并替换为省略号(连续三个句点)。块的构成取决于主模式。在 C 模式和相关模式中,块由大括号分隔,而在 Lisp 模式中它们由括号分隔。多行注释也算作块。

When you use Hideshow mode to hide a block, the block disappears from the screen, to be replaced by an ellipsis (three periods in a row). Just what constitutes a block depends on the major mode. In C mode and related modes, blocks are delimited by braces, while in Lisp mode they are delimited by parentheses. Multi-line comments also count as blocks.

Hideshow模式提供以下命令:

Hideshow mode provides the following commands:

C-c @ C-h
C-c @ C-h
C-c @ C-d
C-c @ C-d

隐藏当前块 ( hs-hide-block)。

Hide the current block (hs-hide-block).

C-c @ C-s
C-c @ C-s

显示当前块(hs-show-block)。

Show the current block (hs-show-block).

C-c @ C-c
C-c @ C-c
C-c @ C-e
C-c @ C-e
S-mouse-2
S-mouse-2

隐藏或显示当前块 ( hs-toggle-hiding)。

Either hide or show the current block (hs-toggle-hiding).

C-c @ C-M-h
C-c @ C-M-h
C-c @ C-t
C-c @ C-t

隐藏所有顶级块 ( hs-hide-all)。

Hide all top-level blocks (hs-hide-all).

C-c @ C-M-s
C-c @ C-M-s
C-c @ C-a
C-c @ C-a

显示缓冲区中的所有块 ( hs-show-all)。

Show all blocks in the buffer (hs-show-all).

C-u n C-c @ C-l
C-u n C-c @ C-l

隐藏该块以下nhs-hide-level层的所有块 ( )。

Hide all blocks n levels below this block (hs-hide-level).

这些变量可用于自定义 Hideshow 模式:

These variables can be used to customize Hideshow mode:

hs-hide-comments-when-hiding-all
hs-hide-comments-when-hiding-all

如果非nilC-c @ C-M-h( hs-hide-all) 也会隐藏注释。

If non-nil, C-c @ C-M-h (hs-hide-all) hides comments too.

hs-isearch-open
hs-isearch-open

此变量指定当块中出现匹配文本时增量搜索应取消隐藏隐藏块的条件。它的值应该是code(仅取消隐藏代码块)、comment(仅取消隐藏注释)、t(同时取消隐藏代码块和注释)或nil(既不取消隐藏代码块也不取消注释)。默认值为code

This variable specifies the conditions under which incremental search should unhide a hidden block when matching text occurs within the block. Its value should be either code (unhide only code blocks), comment (unhide only comments), t (unhide both code blocks and comments), or nil (unhide neither code blocks nor comments). The default value is code.


27.8 符号名称的完成

27.8 Completion for Symbol Names

完成通常在迷你缓冲区中完成(请参阅完成),但您也可以在普通 Emacs 缓冲区中完成符号名称。

Completion is normally done in the minibuffer (see Completion), but you can also complete symbol names in ordinary Emacs buffers.

在大多数编程语言模式中,C-M-i(或 16 ) 调用命令,该命令生成该符号的可能完成列表。此命令使用可用的支持设施来提出完成候选: M-TABcompletion-at-point

In most programming language modes, C-M-i (or M-TAB16) invokes the command completion-at-point, which generates the list of possible completions for the symbol at point. This command uses the available support facilities to come up with the completion candidates:

  • 如果为当前缓冲区的项目(请参阅使用项目)和当前缓冲区的主要模式激活了 Eglot ,则该命令会尝试使用相应的语言服务器来生成完成候选列表。请参阅Eglot中的Eglot 功能:Emacs LSP 客户端
  • If Eglot is activated for the current buffer’s project (see Working with Projects) and the current buffer’s major mode, the command tries to use the corresponding language server for producing the list of completion candidates. See Eglot Features in Eglot: The Emacs LSP Client.
  • 如果启用语义模式(请参阅语义),该命令将尝试使用语义解析器数据来完成。
  • If Semantic mode is enabled (see Semantic), the command tries to use the Semantic parser data for completion.
  • 如果语义模式未启用或执行完成失败,该命令会尝试使用选定的标签表来完成(请参阅标签表);您需要访问标签表才能使其工作。 M-x visit-tags-table
  • If Semantic mode is not enabled or fails at performing completion, the command tries to complete using the selected tags table (see Tags Tables); you need to visit the tags table with M-x visit-tags-table for that to work.
  • 在 Emacs Lisp 模式下,该命令使用当前 Emacs 会话中定义的函数、变量或属性名称来执行补全。
  • In Emacs Lisp mode, the command performs completion using the function, variable, or property names defined in the current Emacs session.

在所有其他方面,缓冲区内符号完成的行为类似于迷你缓冲区完成。例如,如果 Emacs 无法补全唯一符号,它会在另一个窗口中显示补全选项列表。然后,您可以使用键和 浏览完成缓冲区中显示的完成,而无需离开原始缓冲区,并且可以使用键将当前突出显示的完成插入到缓冲区中。请参阅完成M-DOWNM-UPM-RET

In all other respects, in-buffer symbol completion behaves like minibuffer completion. For instance, if Emacs cannot complete to a unique symbol, it displays a list of completion alternatives in another window. Then you can use the keys M-DOWN and M-UP to navigate through the completions displayed in the completions buffer without leaving the original buffer, and the key M-RET to insert the currently highlighted completion to the buffer. See Completion.

在文本模式和相关模式下,根据拼写检查器的词典完成单词。请参阅检查和更正拼写M-TAB

In Text mode and related modes, M-TAB completes words based on the spell-checker’s dictionary. See Checking and Correcting Spelling.


27.9 混合大小写单词

27.9 MixedCase Words

一些编程风格使用混合大小写(或“CamelCase”)符号,例如 '不可读的符号'。 (在 GNU 项目中,我们建议使用下划线来分隔标识符中的单词,而不是使用大小写区别。)Emacs 具有各种功能,可以更轻松地处理此类符号。

Some programming styles make use of mixed-case (or “CamelCase”) symbols like ‘unReadableSymbol’. (In the GNU project, we recommend using underscores to separate words within an identifier, rather than using case distinctions.) Emacs has various features to make it easier to deal with such symbols.

眼镜模式是一种缓冲区本地次要模式,通过改变这些符号的显示方式,可以更轻松地读取这些符号。默认情况下,它在每个小写字母和后面的大写字母之间显示额外的下划线。这不会改变缓冲区文本,只会改变它的显示方式。

Glasses mode is a buffer-local minor mode that makes it easier to read such symbols, by altering how they are displayed. By default, it displays extra underscores between each lower-case letter and the following capital letter. This does not alter the buffer text, only how it is displayed.

要切换眼镜模式,请键入M-x glasses-mode(请参阅次要模式)。当启用眼镜模式时,次要模式指示灯 '哦^o' 出现在模式行中。有关眼镜模式的更多信息,请键入。 C-h P glasses RET

To toggle Glasses mode, type M-x glasses-mode (see Minor Modes). When Glasses mode is enabled, the minor mode indicator ‘o^o’ appears in the mode line. For more information about Glasses mode, type C-h P glasses RET.

子字模式是另一种缓冲区本地次要模式。在 subword 模式下,Emacs 的单词命令识别 ' 中的大写字母StudlyCaps标识符' 作为单词边界。当子字模式启用时,次要模式指示符 ',' 出现在模式行中。另请参阅类似内容superword-mode(请参阅对编辑程序有用的其他功能)。

Subword mode is another buffer-local minor mode. In subword mode, Emacs’s word commands recognize upper case letters in ‘StudlyCapsIdentifiers’ as word boundaries. When Subword mode is enabled, the minor mode indicator ‘,’ appears in the mode line. See also the similar superword-mode (see Other Features Useful for Editing Programs).


27.10 语义

27.10 Semantic

Semantic 是一个提供基于source code parsers.本节提供语义的简要描述;有关完整详细信息,请参阅语义中的语义

Semantic is a package that provides language-aware editing commands based on source code parsers. This section provides a brief description of Semantic; for full details, see Semantic in Semantic.

Emacs 中的大多数语言感知功能,例如字体锁定模式(请参阅字体锁定模式),都依赖于经验法则17,这些法则通常会给出良好的结果,但永远不会完全准确。相比之下,Semantic 使用的解析器对编程语言语法有准确的理解。这使得 Semantic 能够提供强大且精确的搜索、导航和完成命令。

Most of the language-aware features in Emacs, such as Font Lock mode (see Font Lock mode), rely on rules of thumb17 that usually give good results but are never completely exact. In contrast, the parsers used by Semantic have an exact understanding of programming language syntax. This allows Semantic to provide search, navigation, and completion commands that are powerful and precise.

要开始使用 Semantic,请键入M-x semantic-mode或单击名为“源代码解析器(语义)' 在里面 '工具' 菜单。这将启用语义模式,一种全局次要模式。

To begin using Semantic, type M-x semantic-mode or click on the menu item named ‘Source Code Parsers (Semantic)’ in the ‘Tools’ menu. This enables Semantic mode, a global minor mode.

启用语义模式后,Emacs 会自动尝试解析您访问的每个文件。目前,Semantic 可以理解 C、C++、HTML、Java、Javascript、Make、Python、Scheme、SRecode 和 Texinfo。在每个解析的缓冲区中,可以使用以下命令:

When Semantic mode is enabled, Emacs automatically attempts to parse each file you visit. Currently, Semantic understands C, C++, HTML, Java, Javascript, Make, Python, Scheme, SRecode, and Texinfo. Within each parsed buffer, the following commands are available:

C-c , j
C-c , j

提示输入当前文件中定义的函数名称,并将点移动到那里 ( semantic-complete-jump-local)。

Prompt for the name of a function defined in the current file, and move point there (semantic-complete-jump-local).

C-c , J
C-c , J

提示输入 Emacs 已解析的任何文件中定义的函数名称,并将点移动到那里 ( semantic-complete-jump)。

Prompt for the name of a function defined in any file Emacs has parsed, and move point there (semantic-complete-jump).

C-c , SPC
C-c , SPC

显示点 ( ) 处符号的可能补全列表semantic-complete-analyze-inline。这还会激活一组用于选择完成的特殊键绑定:RET 接受当前完成,M-nM-p循环可能的完成,TAB尽可能完成然后循环,和/C-g或任何其他键中止完成。

Display a list of possible completions for the symbol at point (semantic-complete-analyze-inline). This also activates a set of special key bindings for choosing a completion: RET accepts the current completion, M-n and M-p cycle through possible completions, TAB completes as far as possible and then cycles, and C-g or any other key aborts completion.

C-c , l
C-c , l

semantic-analyze-possible-completions在另一个窗口 ( ) 中显示该点处符号可能完成的列表。

Display a list of the possible completions of the symbol at point, in another window (semantic-analyze-possible-completions).

除了上述命令之外,Semantic 包还提供了多种其他方式来使用解析器信息。例如,您可以使用它在 Emacs 空闲时显示完成列表。有关详细信息,请参阅语义中的语义

In addition to the above commands, the Semantic package provides a variety of other ways to make use of parser information. For instance, you can use it to display a list of completions when Emacs is idle. See Semantic in Semantic, for details.


27.11 对编辑程序有用的其他功能

27.11 Other Features Useful for Editing Programs

尽管如此,一些并非专门为编辑程序而设计的 Emacs 命令对此很有用。

Some Emacs commands that aren’t designed specifically for editing programs are useful for that nonetheless.

对单词、句子和段落进行操作的 Emacs 命令对于编辑代码非常有用。大多数符号名称都包含单词(请参阅单词),而句子可以在字符串和注释中找到(请参阅句子)。至于段落,它们在大多数编程语言模式中被定义为以空行开始和结束(请参阅段落)。因此,明智地使用空行使程序更清晰也将为段落命令的处理提供有用的文本块。如果在编程语言主要模式中启用自动填充模式,则会缩进它创建的新行。

The Emacs commands that operate on words, sentences and paragraphs are useful for editing code. Most symbol names contain words (see Words), while sentences can be found in strings and comments (see Sentences). As for paragraphs, they are defined in most programming language modes to begin and end at blank lines (see Paragraphs). Therefore, judicious use of blank lines to make the program clearer will also provide useful chunks of text for the paragraph commands to work on. Auto Fill mode, if enabled in a programming language major mode, indents the new lines which it creates.

超级字模式是一种缓冲区本地次要模式,它会导致编辑和运动命令处理符号(例如,'这是一个符号')作为单词。当启用 Superword 模式时,次要模式指示灯 '²' 出现在模式行中。另请参阅类似内容subword-mode (请参阅混合大小写单词)。

Superword mode is a buffer-local minor mode that causes editing and motion commands to treat symbols (e.g., ‘this_is_a_symbol’) as words. When Superword mode is enabled, the minor mode indicator ‘²’ appears in the mode line. See also the similar subword-mode (see MixedCase Words).

电动布局模式 ( M-x electric-layout-mode) 是一种全局次要模式,当您键入某些字符时会自动插入换行符;例如, '{','}' 和 ';' 在 JavaScript 模式下。

Electric Layout mode (M-x electric-layout-mode) is a global minor mode that automatically inserts newlines when you type certain characters; for example, ‘{’, ‘}’ and ‘;’ in Javascript mode.

除了隐藏显示模式(请参阅隐藏显示次要模式)之外,选择性显示节目部分的另一种方法是使用选择性显示功能(请参阅选择性显示)。编程模式通常还支持大纲次要模式(请参阅大纲模式),该模式可以与 Foldout 包一起使用(请参阅折叠编辑)。

Apart from Hideshow mode (see Hideshow minor mode), another way to selectively display parts of a program is to use the selective display feature (see Selective Display). Programming modes often also support Outline minor mode (see Outline Mode), which can be used with the Foldout package (see Folding Editing).

美化符号模式是一种缓冲区本地次要模式,出于显示目的,它用更具吸引力的版本替换某些字符串。例如,在 Emacs Lisp 模式下,它替换字符串 '拉姆达' 带有希腊 lambda 字符 'λ'。在 TeX 缓冲区中,它将替换 ''……'欧米伽' 以及其他数学宏及其 Unicode 字符。您可能也希望在非编程模式下使用它。您可以通过添加更多条目来自定义模式 prettify-symbols-alistprettify-symbols-compose-predicate如果其默认值prettify-symbols-default-compose-p不合适,可以通过定制进行更精细的定制。还有一个全局版本, global-prettify-symbols-mode它在所有支持它的缓冲区中启用该模式。

Prettify Symbols mode is a buffer-local minor mode that replaces certain strings with more attractive versions for display purposes. For example, in Emacs Lisp mode, it replaces the string ‘lambda’ with the Greek lambda character ‘λ’. In a TeX buffer, it will replace ‘\alpha’ … ‘\omega’ and other math macros with their Unicode characters. You may wish to use this in non-programming modes as well. You can customize the mode by adding more entries to prettify-symbols-alist. More elaborate customization is available via customizing prettify-symbols-compose-predicate if its default value prettify-symbols-default-compose-p is not appropriate. There is also a global version, global-prettify-symbols-mode, which enables the mode in all buffers that support it.

点处的符号可以以其原始形式显示。这是由变量 控制的prettify-symbols-unprettify-at-point:如果不是nil,则只要 point 位于该点,该点符号的原始形式就会被恢复。

The symbol at point can be shown in its original form. This is controlled by the variable prettify-symbols-unprettify-at-point: if non-nil, the original form of symbol at point will be restored for as long as point is at it.


27.12 C and Related Modes

本节简要描述 C、C++、Objective-C、Java、CORBA IDL、Pike 和 AWK 模式中可用的特殊功能。 (这些称为“C 模式和相关模式”。)有关更多详细信息,请参阅随 Emacs 一起分发的 CC 模式信息手册。

This section gives a brief description of the special features available in C, C++, Objective-C, Java, CORBA IDL, Pike and AWK modes. (These are called “C mode and related modes”.) For more details, see the CC mode Info manual, which is distributed with Emacs.


27.12.1 C 模式运动命令

27.12.1 C Mode Motion Commands

本节介绍 C 模式及相关模式下的移动点命令。

This section describes commands for moving point, in C mode and related modes.

C-M-a
C-M-a
C-M-e
C-M-e

将点移动到当前函数或顶级定义的开头或结尾。在具有封闭作用域的语言(例如 C++ 的类)中,当前函数是直接函数,可能位于某个作用域内。否则它是由最少的封闭大括号定义的。 (相比之下,beginning-of-defunend-of-defun在零列中搜索大括号。)请参阅Moving by Defuns

Move point to the beginning or end of the current function or top-level definition. In languages with enclosing scopes (such as C++’s classes) the current function is the immediate one, possibly inside a scope. Otherwise it is the one defined by the least enclosing braces. (By contrast, beginning-of-defun and end-of-defun search for braces in column zero.) See Moving by Defuns.

C-c C-u
C-c C-u

将点移回包含预处理器的条件,留下标记。前缀参数充当重复计数。如果参数为负,则将点向前移动到包含预处理器条件的末尾。

'#elif' 相当于 '#别的' 其次是 '#如果',因此函数将停止在 '#elif’向后退时,但前进时则不然。

Move point back to the containing preprocessor conditional, leaving the mark behind. A prefix argument acts as a repeat count. With a negative argument, move point forward to the end of the containing preprocessor conditional.

#elif’ is equivalent to ‘#else’ followed by ‘#if’, so the function will stop at a ‘#elif’ when going backward, but not when going forward.

C-c C-p
C-c C-p

将点移回到预处理器条件上,留下标记。前缀参数充当重复计数。带着消极的论点,继续前进。

Move point back over a preprocessor conditional, leaving the mark behind. A prefix argument acts as a repeat count. With a negative argument, move forward.

C-c C-n
C-c C-n

在预处理器条件中向前移动点,将标记留在后面。前缀参数充当重复计数。有了否定的论据,就向后退。

Move point forward across a preprocessor conditional, leaving the mark behind. A prefix argument acts as a repeat count. With a negative argument, move backward.

M-a
M-a

将指针移至最内层 C 语句的开头 ( c-beginning-of-statement)。如果 point 已经位于语句的开头,则移至前一个语句的开头。使用前缀参数n,向后移动n − 1 个语句。

在注释或跨越多行的字符串中,此命令按句子而不是语句移动。

Move point to the beginning of the innermost C statement (c-beginning-of-statement). If point is already at the beginning of a statement, move to the beginning of the preceding statement. With prefix argument n, move back n − 1 statements.

In comments or in strings which span more than one line, this command moves by sentences instead of statements.

M-e
M-e

将point移动到最里面的C语句或句子的末尾;类似 M-a,只是它向另一个方向移动 ( c-end-of-statement)。

Move point to the end of the innermost C statement or sentence; like M-a except that it moves in the other direction (c-end-of-statement).


27.12.2 电气 C 字符

27.12.2 Electric C Characters

在 C 模式和相关模式中,某些打印字符是 电动的— 除了插入自身之外,它们还重新缩进当前行,并且还可以选择插入换行符。电字符有{、、、、、、、、、、、、、、、。 }​​​​​​​ ​ :#;,<>/*()

In C mode and related modes, certain printing characters are electric—in addition to inserting themselves, they also reindent the current line, and optionally also insert newlines. The electric characters are {, }, :, #, ;, ,, <, >, /, *, (, and ).

如果您正在编辑混乱的缩进代码,您可能会发现电动缩进很不方便。如果您是 CC 模式的新手,您可能会发现它令人不安。您可以使用命令切换电动动作 C-c C-l;当它被启用时,'/ cl' 出现在模式行中模式名称之后(其中c如果存在,则为 '*' 或者 '/',取决于注释样式是块还是行)。有关 CC 模式中模式线指示器的更多信息, 请参阅CC 模式手册中的次要模式。

You might find electric indentation inconvenient if you are editing chaotically indented code. If you are new to CC Mode, you might find it disconcerting. You can toggle electric action with the command C-c C-l; when it is enabled, ‘/cl’ appears in the mode line after the mode name (where c, if present, is ‘*’ or ‘/’, depending on whether the comment style is block or line). See Minor Modes in The CC Mode Manual, for more about mode-line indicators in CC Mode.

C-c C-l
C-c C-l

切换电动动作 ( c-toggle-electric-state)。如果前缀参数为正,则该命令启用电动动作,如果前缀参数为负,则禁用电动动作。

Toggle electric action (c-toggle-electric-state). With a positive prefix argument, this command enables electric action, with a negative one it disables it.

仅当除了电动状态外,还启用了自动换行功能(由 ' 表示)时,电动字符才会插入换行符/' 在模式名称后面的模式行中)。您可以使用以下命令打开或关闭此功能C-c C-a

Electric characters insert newlines only when, in addition to the electric state, the auto-newline feature is enabled (indicated by ‘/cla’ in the mode line after the mode name). You can turn this feature on or off with the command C-c C-a:

C-c C-a
C-c C-a

切换自动换行功能 ( c-toggle-auto-newline)。使用前缀参数时,如果参数为正,此命令将打开自动换行功能;如果参数为负,则关闭自动换行功能。

Toggle the auto-newline feature (c-toggle-auto-newline). With a prefix argument, this command turns the auto-newline feature on if the argument is positive, and off if it is negative.

通常,CC 模式样式会配置 Emacs 插入自动换行符的确切环境。您也可以直接配置它。请参阅CC 模式手册中的自定义自动换行符

Usually the CC Mode style configures the exact circumstances in which Emacs inserts auto-newlines. You can also configure this directly. See Custom Auto-newlines in The CC Mode Manual.


27.12.3 C 中的饥饿删除功能

27.12.3 Hungry Delete Feature in C

如果你想删除整个空白块,你可以使用饥饿删除。这会在单个操作中删除点之前或点之后的所有连续空格。 这里的空白包括制表符和换行符,但不包括注释或预处理器命令。

If you want to delete an entire block of whitespace at point, you can use hungry deletion. This deletes all the contiguous whitespace either before point or after point in a single operation. Whitespace here includes tabs and newlines, but not comments or preprocessor commands.

C-c C-DEL
C-c C-DEL
C-c DEL
C-c DEL

删除点 ( ) 之前的整个空白块c-hungry-delete-backwards

Delete the entire block of whitespace preceding point (c-hungry-delete-backwards).

C-c C-d
C-c C-d
C-c C-Delete
C-c C-Delete
C-c Delete
C-c Delete

删除 ( ) 点之后的整个空白块c-hungry-delete-forward

Delete the entire block of whitespace after point (c-hungry-delete-forward).

作为上述命令的替代方法,您可以启用饥饿删除模式。当启用此功能时(由 ' 表示)H' 之后 '/' 在模式名称后面的模式行中),单个 DEL删除所有前面的空格,而不仅仅是一个空格,单个C-d(但不是plain Delete)删除所有后面的空格。

As an alternative to the above commands, you can enable hungry delete mode. When this feature is enabled (indicated by ‘h’ after a ‘/’ in the mode line after the mode name), a single DEL deletes all preceding whitespace, not just one space, and a single C-d (but not plain Delete) deletes all following whitespace.

M-x c-toggle-hungry-state
M-x c-toggle-hungry-state

切换饥饿删除功能 ( c-toggle-hungry-state)。使用前缀参数时,如果参数为正,则此命令将打开饥饿删除功能;如果参数为负,则关闭饥饿删除功能。

Toggle the hungry-delete feature (c-toggle-hungry-state). With a prefix argument, this command turns the hungry-delete feature on if the argument is positive, and off if it is negative.

该变量c-hungry-delete-key控制是否启用饥饿删除功能。

The variable c-hungry-delete-key controls whether the hungry-delete feature is enabled.


27.12.4 C 模式的其他命令

27.12.4 Other Commands for C Mode

M-x c-context-line-break
M-x c-context-line-break

此命令插入换行符并以适合上下文的方式缩进新行。在普通代码中,它执行RET( )的工作 newline,在 C 预处理器行中,它另外插入一个 '\' 在换行符处,在注释中就像 M-j( c-indent-new-comment-line)。

c-context-line-break默认情况下不绑定到键,但它需要绑定才能有用。以下代码将其绑定到 RET.我们使用c-initialization-hook此处来确保在尝试更改键映射之前已加载它。

(defun my-bind-clb ()
  (键盘映射设置 c-mode-base-map“RET”
              'c-上下文换行符))
(添加钩子“c-初始化钩子”my-bind-clb)

This command inserts a line break and indents the new line in a manner appropriate to the context. In normal code, it does the work of RET (newline), in a C preprocessor line it additionally inserts a ‘\’ at the line break, and within comments it’s like M-j (c-indent-new-comment-line).

c-context-line-break isn’t bound to a key by default, but it needs a binding to be useful. The following code will bind it to RET. We use c-initialization-hook here to make sure the keymap is loaded before we try to change it.

(defun my-bind-clb ()
  (keymap-set c-mode-base-map "RET"
              'c-context-line-break))
(add-hook 'c-initialization-hook 'my-bind-clb)
C-M-h
C-M-h

将标记放在函数定义的末尾,将点放在开头 ( c-mark-function)。

Put mark at the end of a function definition, and put point at the beginning (c-mark-function).

M-q
M-q

填写一个段落,处理 C 和 C++ 注释 ( c-fill-paragraph)。如果当前行的任何部分是注释或注释内,则此命令将填充注释或该点所在的段落,并保留注释缩进和注释分隔符。

Fill a paragraph, handling C and C++ comments (c-fill-paragraph). If any part of the current line is a comment or within a comment, this command fills the comment or the paragraph of it that point is in, preserving the comment indentation and comment delimiters.

C-c C-e
C-c C-e

对区域中的文本运行 C 预处理器,并显示结果,其中包括所有宏调用的扩展 ( c-macro-expand)。为了在那里定义的宏,该区域之前的缓冲区文本也包含在预处理中,但未显示该部分的输出。

当您调试使用宏的 C 代码时,有时很难准确地弄清楚宏是如何扩展的。有了这个命令,你就不用去弄清楚;你可以看到扩展。

Run the C preprocessor on the text in the region, and show the result, which includes the expansion of all the macro calls (c-macro-expand). The buffer text before the region is also included in preprocessing, for the sake of macros defined there, but the output from this part isn’t shown.

When you are debugging C code that uses macros, sometimes it is hard to figure out precisely how the macros expand. With this command, you don’t have to figure it out; you can see the expansions.

C-c C-\
C-c C-\

插入或对齐 '\' 字符位于区域 ( ) 的行末尾c-backslash-region。这在编写或编辑 C 宏定义后非常有用。

如果一行已经以 ' 结尾\',此命令调整其前面的空白量。否则,它会插入一个新的 '\'。然而,该区域的最后一行是经过特殊处理的;不 '\' 被插入到该行,并且任何 '\' 那里被删除了。

Insert or align ‘\’ characters at the ends of the lines of the region (c-backslash-region). This is useful after writing or editing a C macro definition.

If a line already ends in ‘\’, this command adjusts the amount of whitespace before it. Otherwise, it inserts a new ‘\’. However, the last line in the region is treated specially; no ‘\’ is inserted on that line, and any ‘\’ there is deleted.

M-x cpp-highlight-buffer
M-x cpp-highlight-buffer

根据预处理器条件突出显示文本的各个部分。此命令显示另一个名为*CPP编辑*,它用作图形菜单,用于选择如何显示特定类型的条件及其内容。更改各种设置后,单击“[A]应用这些设置' (或转到该缓冲区并输入 a)以相应地重新突出显示 C 模式缓冲区。

Highlight parts of the text according to its preprocessor conditionals. This command displays another buffer named *CPP Edit*, which serves as a graphic menu for selecting how to display particular kinds of conditionals and their contents. After changing various settings, click on ‘[A]pply these settings’ (or go to that buffer and type a) to rehighlight the C mode buffer accordingly.

C-c C-s
C-c C-s

显示有关当前源代码行的语法信息 ( c-show-syntactic-information)。此信息指示该行的缩进方式。

Display the syntactic information about the current source line (c-show-syntactic-information). This information directs how the line is indented.

M-x cwarn-mode
M-x cwarn-mode
M-x global-cwarn-mode
M-x global-cwarn-mode

CWarn 次要模式突出显示某些可疑的 C 和 C++ 结构:

  • 表达式内的赋值。
  • 紧跟在 ' 之后的分号如果','为了', 和 '尽管'(除了'之后做……同时' 陈述);
  • 带有参考参数的 C++ 函数。

您可以使用该命令为一个缓冲区启用该模式,也可以使用该命令或通过自定义变量 M-x cwarn-mode为所有合适的缓冲区启用该模式。您还必须启用字体锁定模式才能使其工作。 M-x global-cwarn-modeglobal-cwarn-mode

CWarn minor mode highlights certain suspicious C and C++ constructions:

  • Assignments inside expressions.
  • Semicolon following immediately after ‘if’, ‘for’, and ‘while’ (except after a ‘do … while’ statement);
  • C++ functions with reference parameters.

You can enable the mode for one buffer with the command M-x cwarn-mode, or for all suitable buffers with the command M-x global-cwarn-mode or by customizing the variable global-cwarn-mode. You must also enable Font Lock mode to make it work.

M-x hide-ifdef-mode
M-x hide-ifdef-mode

Hide-ifdef 次要模式隐藏 ' 中选定的代码#如果' 和 '#ifdef' 预处理器块。如果将变量更改 hide-ifdef-shadowt,则 Hide-ifdef 次要模式会通过以不太突出的面显示预处理器块来隐藏它们,而不是完全隐藏它们。hide-ifdef-mode有关详细信息, 请参阅 的文档字符串。

Hide-ifdef minor mode hides selected code within ‘#if’ and ‘#ifdef’ preprocessor blocks. If you change the variable hide-ifdef-shadow to t, Hide-ifdef minor mode shadows preprocessor blocks by displaying them with a less prominent face, instead of hiding them entirely. See the documentation string of hide-ifdef-mode for more information.

M-x ff-find-related-file

查找与当前缓冲区访问的文件以特殊方式相关的文件。通常,这将是与 C/C++ 源文件对应的头文件,反之亦然。该变量 ff-related-file-alist指定如何计算相关文件名。

Find a file related in a special way to the file visited by the current buffer. Typically this will be the header file corresponding to a C/C++ source file, or vice versa. The variable ff-related-file-alist specifies how to compute related file names.


27.13 汇编模式

27.13 Asm Mode

Asm模式是编辑汇编代码文件的主要模式。它定义了这些命令:

Asm mode is a major mode for editing files of assembler code. It defines these commands:

TAB
TAB

tab-to-tab-stop

tab-to-tab-stop.

C-j
C-j

插入换行符,然后使用 缩进tab-to-tab-stop

Insert a newline and then indent using tab-to-tab-stop.

:
:

插入冒号,然后删除冒号前面的标签之前的缩进。然后做tab-to-tab-stop

Insert a colon and then remove the indentation from before the label preceding colon. Then do tab-to-tab-stop.

;
;

插入或对齐注释。

Insert or align a comment.

该变量asm-comment-char指定汇编语法中注释的起始字符。

The variable asm-comment-char specifies which character starts comments in assembler syntax.


27.14 Fortran模式

27.14 Fortran Mode

Fortran 模式用于编辑固定形式(以及制表符格式)源代码(通常为 Fortran 77)。要编辑更现代的自由格式源代码(Fortran 90、95、2003、2008),请使用 F90 模式 ( f90-mode)。 Emacs 通常对扩展名为 ' 的文件使用 Fortran 模式。F','。F' 或者 '。为了',以及扩展的 F90 模式 '.f90','.f95','.f03' 和 '.f08'。自定义auto-mode-alist以添加更多扩展。 GNU Fortran 支持自由形式和固定形式。本手册主要记录 Fortran 模式,但在相关时会提到相应的 F90 模式功能。

Fortran mode is meant for editing fixed form (and also tab format) source code (normally Fortran 77). For editing more modern free-form source code (Fortran 90, 95, 2003, 2008), use F90 mode (f90-mode). Emacs normally uses Fortran mode for files with extension ‘.f’, ‘.F’ or ‘.for’, and F90 mode for the extensions ‘.f90’, ‘.f95’, ‘.f03’ and ‘.f08’. Customize auto-mode-alist to add more extensions. GNU Fortran supports both free and fixed form. This manual mainly documents Fortran mode, but the corresponding F90 mode features are mentioned when relevant.

Fortran 模式为 Fortran 语句和子程序提供特殊的运动命令,以及了解 Fortran 嵌套、行号和连续语句约定的缩进命令。 Fortran 模式支持自动填充模式,该模式可将长行分成适当的 Fortran 连续行。 Fortran 模式还支持 Hideshow 小模式(请参阅Hideshow 小模式)和 Imenu (请参阅Imenu)。

Fortran mode provides special motion commands for Fortran statements and subprograms, and indentation commands that understand Fortran conventions of nesting, line numbers and continuation statements. Fortran mode has support for Auto Fill mode that breaks long lines into proper Fortran continuation lines. Fortran mode also supports Hideshow minor mode (see Hideshow minor mode), and Imenu (see Imenu).

由于 Fortran 注释与其他语言的注释不同,因此提供了特殊的注释命令。当您插入 Fortran 关键字时,内置缩写可选择节省输入。

Special commands for comments are provided because Fortran comments are unlike those of other languages. Built-in abbrevs optionally save typing when you insert Fortran keywords.

用于M-x fortran-mode切换到该主要模式。该命令运行钩子fortran-mode-hook。请参阅钩子

Use M-x fortran-mode to switch to this major mode. This command runs the hook fortran-mode-hook. See Hooks.


27.14.1 运动命令

27.14.1 Motion Commands

除了用于移动和操作 defun 的常规命令(Fortran 子程序 - 函数和子例程,以及 F90 模式的模块,使用命令fortran-end-of-subprogramfortran-beginning-of-subprogram)之外,Fortran 模式还提供特殊命令来通过语句和其他程序单元移动。

In addition to the normal commands for moving by and operating on defuns (Fortran subprograms—functions and subroutines, as well as modules for F90 mode, using the commands fortran-end-of-subprogram and fortran-beginning-of-subprogram), Fortran mode provides special commands to move by statements and other program units.

C-c C-n
C-c C-n

移至下一条语句的开头 ( fortran-next-statement/ f90-next-statement)。

Move to the beginning of the next statement (fortran-next-statement/f90-next-statement).

C-c C-p
C-c C-p

移至上一条语句的开头 ( fortran-previous-statement/ f90-previous-statement)。如果没有先前的语句(即,如果从缓冲区中的第一个语句调用),则移至缓冲区的开头。

Move to the beginning of the previous statement (fortran-previous-statement/f90-previous-statement). If there is no previous statement (i.e., if called from the first statement in the buffer), move to the start of the buffer.

C-c C-e
C-c C-e

将点向前移动到下一个代码块的开头或当前代码块的结尾,以先到者为准 ( f90-next-block)。代码块是子例程、ifendif语句等。该命令仅适用于 F90 模式,不适用于 Fortran 模式。使用数字参数,它会向前移动许多块。

Move point forward to the start of the next code block, or the end of the current one, whichever comes first (f90-next-block). A code block is a subroutine, ifendif statement, and so forth. This command exists for F90 mode only, not Fortran mode. With a numeric argument, it moves forward that many blocks.

C-c C-a
C-c C-a

将点向后移动到上一个块 ( f90-previous-block)。这就像f90-next-block,但向后移动。

Move point backward to the previous block (f90-previous-block). This is like f90-next-block, but moves backwards.

C-M-n
C-M-n

移至当前代码块的末尾 ( fortran-end-of-block/ f90-end-of-block)。使用数字参数,向前移动该数量的块。该标记设置在移动点之前。此命令的 F90 模式版本检查块类型和标签(如果存在)的一致性,但它不检查最外面的块,因为它可能不完整。

Move to the end of the current code block (fortran-end-of-block/f90-end-of-block). With a numeric argument, move forward that number of blocks. The mark is set before moving point. The F90 mode version of this command checks for consistency of block types and labels (if present), but it does not check the outermost block since that may be incomplete.

C-M-p
C-M-p

移至当前代码块的开头 ( fortran-beginning-of-block/ f90-beginning-of-block)。这就像fortran-end-of-block,但向后移动。

Move to the start of the current code block (fortran-beginning-of-block/f90-beginning-of-block). This is like fortran-end-of-block, but moves backwards.

命令fortran-beginning-of-subprogramfortran-end-of-subprogram分别移动到当前子程序的开头或结尾。命令fortran-mark-do 和标记当前或 块fortran-mark-if的结尾,并将点移动到开头。 doif

The commands fortran-beginning-of-subprogram and fortran-end-of-subprogram move to the start or end of the current subprogram, respectively. The commands fortran-mark-do and fortran-mark-if mark the end of the current do or if block, and move point to the start.


27.14.2 Fortran 缩进

27.14.2 Fortran Indentation

缩进固定(或制表符)形式的 Fortran 代码需要特殊的命令和功能,以确保各种语法实体(行号、注释行指示符和续行标志)出现在所需的列中。

Special commands and features are needed for indenting fixed (or tab) form Fortran code in order to make sure various syntactic entities (line numbers, comment line indicators and continuation line flags) appear in the required columns.


27.14.2.1 Fortran 缩进和填充命令

27.14.2.1 Fortran Indentation and Filling Commands

C-M-j
C-M-j

在点处断开当前线并建立一条延续线 ( fortran-split-line)。

Break the current line at point and set up a continuation line (fortran-split-line).

M-^
M-^

将此行连接到上一行 ( fortran-join-line)。

Join this line to the previous line (fortran-join-line).

C-M-q
C-M-q

缩进( ) 中该点所在子程序的所有行fortran-indent-subprogram

Indent all the lines of the subprogram that point is in (fortran-indent-subprogram).

M-q
M-q

填写注释块或语句(使用fortran-fill-paragraphfortran-fill-statement)。

Fill a comment block or statement (using fortran-fill-paragraph or fortran-fill-statement).

C-M-q运行fortran-indent-subprogram,命令重新缩进包含点的 Fortran 子程序(函数或子例程)的所有行。

The key C-M-q runs fortran-indent-subprogram, a command to reindent all the lines of the Fortran subprogram (function or subroutine) containing point.

C-M-j运行fortran-split-line,它以适合 Fortran 的方式分割一行。在非注释行中,后半部分成为延续行并相应缩进。在注释行中,两半都成为单独的注释行。

The key C-M-j runs fortran-split-line, which splits a line in the appropriate fashion for Fortran. In a non-comment line, the second half becomes a continuation line and is indented accordingly. In a comment line, both halves become separate comment lines.

M-^或者C-c C-d运行命令fortran-join-line,该命令将续行连接回上一行,大致与 的相反fortran-split-line。调用此命令时,该点必须位于连续线上。

M-^ or C-c C-d run the command fortran-join-line, which joins a continuation line back to the previous line, roughly as the inverse of fortran-split-line. The point must be on a continuation line when this command is invoked.

M-q在 Fortran 模式下,填充该点所在的注释块或语句。这会删除任何多余的语句延续。

M-q in Fortran mode fills the comment block or statement that point is in. This removes any excess statement continuations.


27.14.2.2 延续线

27.14.2.2 Continuation Lines

大多数 Fortran 77 编译器允许两种编写连续行的方法。如果一行中的第一个非空格字符位于第 5 列,则该行是上一行的延续。我们称这种固定形式。 (在 GNU Emacs 中,我们总是从 0 开始计算列;但请注意,Fortran 标准从 1 开始计数。您可以自定义变量 column-number-indicator-zero-based以使列显示为类似 Fortran;请参阅可选模式行功能。)该变量 fortran-continuation-string指定要输入的字符第 5 列。以制表符开头的行,后跟除 ' 之外的任何数字0' 也是一个延续行。我们将这种风格称为连续制表符格式。 (Fortran 90 引入了自由形式的连续线。)

Most Fortran 77 compilers allow two ways of writing continuation lines. If the first non-space character on a line is in column 5, then that line is a continuation of the previous line. We call this fixed form. (In GNU Emacs we always count columns from 0; but note that the Fortran standard counts from 1. You can customize the variable column-number-indicator-zero-based to make the column display Fortran-like; see Optional Mode Line Features.) The variable fortran-continuation-string specifies what character to put in column 5. A line that starts with a tab character followed by any digit except ‘0’ is also a continuation line. We call this style of continuation tab format. (Fortran 90 introduced free-form continuation lines.)

Fortran 模式可以使用任一样式的续行。当您进入 Fortran 模式时,它会尝试从缓冲区内容自动推断出正确的延续样式。它通过fortran-analyze-depth从缓冲区开头扫描最多(默认 100)行来实现此目的 。以制表符或六个空格开头的第一行决定了选择。如果扫描失败(例如,如果缓冲区是新的,因此为空),则 使用fortran-tab-mode-default(nil表示固定格式,非制表符格式) 的值。 nil'/吨模式行中的( fortran-tab-mode-string) 表示选择制表符格式。 Fortran 模式相应地设置 的值indent-tabs-mode

Fortran mode can use either style of continuation line. When you enter Fortran mode, it tries to deduce the proper continuation style automatically from the buffer contents. It does this by scanning up to fortran-analyze-depth (default 100) lines from the start of the buffer. The first line that begins with either a tab character or six spaces determines the choice. If the scan fails (for example, if the buffer is new and therefore empty), the value of fortran-tab-mode-default (nil for fixed form, and non-nil for tab format) is used. ‘/t’ (fortran-tab-mode-string) in the mode line indicates tab format is selected. Fortran mode sets the value of indent-tabs-mode accordingly.

如果一行中的文本以 Fortran 继续标记 ' 开头$',或者如果它以第 5 列中的任何非空白字符开头,Fortran 模式会将其视为续行。当您使用 缩进连续行时TAB,它会将该行转换为当前的连续样式。当您使用 分割 Fortran 语句时 C-M-j,将根据延续样式创建换行符上的延续标记。

If the text on a line starts with the Fortran continuation marker ‘$’, or if it begins with any non-whitespace character in column 5, Fortran mode treats it as a continuation line. When you indent a continuation line with TAB, it converts the line to the current continuation style. When you split a Fortran statement with C-M-j, the continuation marker on the newline is created according to the continuation style.

延续样式的设置会影响 Fortran 模式下编辑的其他几个方面。在固定格式模式下,语句主体的最小列号为 6。Fortran 块内缩进到较大列号的行必须仅使用空格字符作为空白。在制表符格式模式下,语句体的最小列数为8,并且第8列之前的空格必须由1个制表符组成。

The setting of continuation style affects several other aspects of editing in Fortran mode. In fixed form mode, the minimum column number for the body of a statement is 6. Lines inside of Fortran blocks that are indented to larger column numbers must use only the space character for whitespace. In tab format mode, the minimum column number for the statement body is 8, and the whitespace before column 8 must consist of one tab character.


27.14.2.3 行号

27.14.2.3 Line Numbers

如果数字是行中的第一个非空格,Fortran 缩进会假定它是行号,并将其移动到第 0 列到第 4 列。(在 Emacs 中,列始终从 0 开始计数,但设置 column-number-indicator-zero-basednil可以更改这一点,请参阅可选模式行特征。)

If a number is the first non-whitespace in the line, Fortran indentation assumes it is a line number and moves it to columns 0 through 4. (Columns always count from 0 in Emacs, but setting column-number-indicator-zero-based to nil can change that, see Optional Mode Line Features.)

四位或更少的行号通常缩进一个空格。变量fortran-line-number-indent控制这一点;它指定行号可以有的最大缩进。该变量的默认值为 1。Fortran 模式会尝试阻止行号数字超过第 4 列,并在必要时将缩进减少到指定的最大值以下。如果fortran-line-number-indent值为 5,则行号右对齐以在第 4 列结束。

Line numbers of four digits or less are normally indented one space. The variable fortran-line-number-indent controls this; it specifies the maximum indentation a line number can have. The default value of the variable is 1. Fortran mode tries to prevent line number digits passing column 4, reducing the indentation below the specified maximum if necessary. If fortran-line-number-indent has the value 5, line numbers are right-justified to end in column 4.

只需插入行号就足以根据这些规则缩进它。插入每个数字时,都会重新计算缩进。要关闭此功能,请将变量设置 fortran-electric-line-numbernil

Simply inserting a line number is enough to indent it according to these rules. As each digit is inserted, the indentation is recomputed. To turn off this feature, set the variable fortran-electric-line-number to nil.


27.14.2.4 语法约定

27.14.2.4 Syntactic Conventions

Fortran 模式假设您遵循某些约定,这些约定可以简化理解 Fortran 程序的任务,使其能够正确缩进:

Fortran mode assumes that you follow certain conventions that simplify the task of understanding a Fortran program well enough to indent it properly:

  • 两个嵌套''循环从不共享'继续' 陈述。
  • Two nested ‘do’ loops never share a ‘continue’ statement.
  • Fortran 关键字,例如 '如果','别的','然后','' 而其他的则没有嵌入空格或换行符。

    Fortran 编译器通常会忽略字符串常量之外的空格,但 Fortran 模式不会识别这些不连续的关键字。构造如 '否则如果' 或者 '结束做' 是可以接受的,但第二个单词应该与第一个单词在同一行,而不是连续行。

  • Fortran keywords such as ‘if’, ‘else’, ‘then’, ‘do’ and others are written without embedded whitespace or line breaks.

    Fortran compilers generally ignore whitespace outside of string constants, but Fortran mode does not recognize these keywords if they are not contiguous. Constructs such as ‘else if’ or ‘end do’ are acceptable, but the second word should be on the same line as the first and not on a continuation line.

如果您不遵循这些约定,缩进命令可能会不美观地缩进某些行。然而,即使不遵循约定,正确的 Fortran 程序在重新缩进时仍保留其含义。

If you fail to follow these conventions, the indentation commands may indent some lines unaesthetically. However, a correct Fortran program retains its meaning when reindented even if the conventions are not followed.


27.14.2.5 Fortran 缩进变量

27.14.2.5 Variables for Fortran Indentation

几个附加变量控制 Fortran 缩进的工作方式:

Several additional variables control how Fortran indentation works:

fortran-do-indent
fortran-do-indent

每个级别内的额外缩进 '' 语句(默认 3)。

Extra indentation within each level of ‘do’ statement (default 3).

fortran-if-indent
fortran-if-indent

每个级别内的额外缩进 '如果','选择案例', 或者 '在哪里' 语句(默认 3)。

Extra indentation within each level of ‘if’, ‘select case’, or ‘where’ statements (default 3).

fortran-structure-indent
fortran-structure-indent

每个级别内的额外缩进 '结构','联盟','地图', 或者 '界面' 语句(默认 3)。

Extra indentation within each level of ‘structure’, ‘union’, ‘map’, or ‘interface’ statements (default 3).

fortran-continuation-indent
fortran-continuation-indent

连续行主体的额外缩进(默认 5)。

Extra indentation for bodies of continuation lines (default 5).

fortran-check-all-num-for-matching-do
fortran-check-all-num-for-matching-do

在 Fortran 77 中,编号 '' 语句由任何具有匹配行号的语句终止。使用 ' 是常见的(但不是强制性的)继续' 为此目的声明。如果此变量具有非nil值,则缩进任何编号语句必须检查 '’到此结束。如果你总是结束'' 带有 ' 的语句继续' 行(或者如果您使用更现代的 '恩多nil'),那么您可以通过将此变量设置为(默认值) 来加快缩进速度 。

In Fortran 77, a numbered ‘do’ statement is terminated by any statement with a matching line number. It is common (but not compulsory) to use a ‘continue’ statement for this purpose. If this variable has a non-nil value, indenting any numbered statement must check for a ‘do’ that ends there. If you always end ‘do’ statements with a ‘continue’ line (or if you use the more modern ‘enddo’), then you can speed up indentation by setting this variable to nil (the default).

fortran-blink-matching-if
fortran-blink-matching-if

如果是这样t,则缩进 '万一' (或者 '恩多') 语句将光标暂时移动到匹配的 '如果' (或者 '') 声明来显示它在哪里。默认为nil.

If this is t, indenting an ‘endif’ (or ‘enddo’) statement moves the cursor momentarily to the matching ‘if’ (or ‘do’) statement to show where it is. The default is nil.

fortran-minimum-statement-indent-fixed
fortran-minimum-statement-indent-fixed

使用固定形式连续行样式时 Fortran 语句的最小缩进。语句体的缩进永远不会小于这个值。默认值为 6。

Minimum indentation for Fortran statements when using fixed form continuation line style. Statement bodies are never indented by less than this. The default is 6.

fortran-minimum-statement-indent-tab
fortran-minimum-statement-indent-tab

制表符格式延续行样式的 Fortran 语句的最小缩进。声明体的缩进永远不会小于这个值。默认值为 8。

Minimum indentation for Fortran statements for tab format continuation line style. Statement bodies are never indented by less than this. The default is 8.

以下部分描述了控制注释缩进的变量。

The following section describes the variables controlling the indentation of comments.


27.14.3 Fortran 注释

27.14.3 Fortran Comments

通常的 Emacs 注释命令假定注释可以跟在一行代码后面。在 Fortran 77 中,标准注释语法要求整行只是注释。因此,Fortran模式取代了标准的Emacs注释命令并定义了一些新的变量。

The usual Emacs comment commands assume that a comment can follow a line of code. In Fortran 77, the standard comment syntax requires an entire line to be just a comment. Therefore, Fortran mode replaces the standard Emacs comment commands and defines some new variables.

Fortran 模式还可以处理 Fortran 90 注释语法,其中注释以 ' 开头' 并且可以跟在其他文本后面。因为只有某些 Fortran 77 编译器接受此语法,所以 Fortran 模式不会插入此类注释,除非您事先说过这样做。为此,请将变量设置fortran-comment-line-start为 '“!”'。如果您使用不寻常的值,则可能需要更改 fortran-comment-line-start-skip

Fortran mode can also handle the Fortran 90 comment syntax where comments start with ‘!’ and can follow other text. Because only some Fortran 77 compilers accept this syntax, Fortran mode will not insert such comments unless you have said in advance to do so. To do this, set the variable fortran-comment-line-start to ‘"!"’. If you use an unusual value, you may need to change fortran-comment-line-start-skip.

M-;
M-;

对齐注释或插入新注释 ( comment-dwim)。

Align comment or insert new comment (comment-dwim).

C-x ;
C-x ;

适用于非标'' 仅限评论 ( comment-set-column)。

Applies to nonstandard ‘!’ comments only (comment-set-column).

C-c ;
C-c ;

将区域中的所有行转换为注释,或者(带参数)将它们转换回真实代码 ( fortran-comment-region)。

Turn all lines of the region into comments, or (with argument) turn them back into real code (fortran-comment-region).

M-;在 Fortran 模式下运行标准comment-dwim.它可以识别任何类型的现有评论并适当地对齐其文本;如果没有现有注释,则会插入并对齐注释。 Fortran 模式下插入和对齐注释与其他模式下不同。

M-; in Fortran mode runs the standard comment-dwim. This recognizes any kind of existing comment and aligns its text appropriately; if there is no existing comment, a comment is inserted and aligned. Inserting and aligning comments are not the same in Fortran mode as in other modes.

当必须插入新注释时,如果当前行为空,则插入整行注释。在非空行上,非标准 '' 如果您说过要使用它们,则会插入注释。否则,将在当前行之前的新行中插入整行注释。

When a new comment must be inserted, if the current line is blank, a full-line comment is inserted. On a non-blank line, a nonstandard ‘!’ comment is inserted if you have said you want to use them. Otherwise, a full-line comment is inserted on a new line before the current line.

非标'' 注释与其他语言中的注释一样对齐,但全行注释不同。在标准的全行注释中,注释分隔符本身必须始终出现在零列中。可以对齐的是注释中的文本。您可以通过将变量设置fortran-comment-indent-style为以下值之一来 选择三种对齐方式 :

Nonstandard ‘!’ comments are aligned like comments in other languages, but full-line comments are different. In a standard full-line comment, the comment delimiter itself must always appear in column zero. What can be aligned is the text within the comment. You can choose from three styles of alignment by setting the variable fortran-comment-indent-style to one of these values:

fixed
fixed

将文本对齐固定列,该列是 fortran-comment-line-extra-indent最小语句缩进的总和。这是默认设置。

最小缩进适用 fortran-minimum-statement-indent-tab于制表符格式连续线样式和fortran-minimum-statement-indent-fixed 固定表单样式。

Align the text at a fixed column, which is the sum of fortran-comment-line-extra-indent and the minimum statement indentation. This is the default.

The minimum indentation is fortran-minimum-statement-indent-tab for tab format continuation line style and fortran-minimum-statement-indent-fixed for fixed form style.

relative
relative

像一行代码一样对齐文本,但带有额外的 fortran-comment-line-extra-indent缩进列。

Align the text as if it were a line of code, but with an additional fortran-comment-line-extra-indent columns of indentation.

nil
nil

不要自动移动全行注释中的文本。

Don’t move text in full-line comments automatically.

此外,您可以通过将变量设置 fortran-comment-indent-char为要使用的单字符字符串来指定用于在全行注释中缩进的字符。

In addition, you can specify the character to be used to indent within full-line comments by setting the variable fortran-comment-indent-char to the single-character string you want to use.

编译器指令行或预处理器行与注释行的外观非常相似。但重要的是,无论 的值是多少,这些行都不要缩进 fortran-comment-indent-style。该变量 fortran-directive-re是一个正则表达式,指定哪些行是指令。匹配行从不缩进,并接受独特的字体锁定。

Compiler directive lines, or preprocessor lines, have much the same appearance as comment lines. It is important, though, that such lines never be indented at all, no matter what the value of fortran-comment-indent-style. The variable fortran-directive-re is a regular expression that specifies which lines are directives. Matching lines are never indented, and receive distinctive font-locking.

普通的 Emacs 注释命令C-x ;( comment-set-column) 没有被重新定义。如果你使用'' 注释,此命令可以与它们一起使用。否则,在Fortran模式下是没有用的。

The normal Emacs comment command C-x ; (comment-set-column) has not been redefined. If you use ‘!’ comments, this command can be used with them. Otherwise, it is useless in Fortran mode.

命令C-c ;( fortran-comment-region) 通过插入字符串 ' 将区域的所有行变成注释美元$$$' 在每一个的前面。使用数字参数,它通过删除 ' 将区域恢复为实时代码美元$$$' 从每行的前面开始。用于这些注释的字符串可以通过设置变量来控制fortran-comment-region。请注意,这里有一个命令和同名变量的示例;该名称的这两种用法从不冲突,因为在 Lisp 和 Emacs 中,从上下文中总是可以清楚地看出哪一个的含义。

The command C-c ; (fortran-comment-region) turns all the lines of the region into comments by inserting the string ‘c$$$’ at the front of each one. With a numeric argument, it turns the region back into live code by deleting ‘c$$$’ from the front of each line in it. The string used for these comments can be controlled by setting the variable fortran-comment-region. Note that here we have an example of a command and a variable with the same name; these two uses of the name never conflict because in Lisp and in Emacs it is always clear from the context which one is meant.


27.14.4 Fortran 模式下的自动填充

27.14.4 Auto Fill in Fortran Mode

Fortran 模式专门支持自动填充模式,这是一种次要模式,当您插入语句时,当语句变得太宽时,它会自动分割语句。拆分语句涉及使用以下内容创建连续行fortran-continuation-string (请参阅连续行)。当您键入SPCRETTAB或 以及 Fortran 缩进命令时,会发生这种分割 。您可以按照正常方式在 Fortran 模式下激活自动填充。请参阅自动填充模式

Fortran mode has specialized support for Auto Fill mode, which is a minor mode that automatically splits statements as you insert them when they become too wide. Splitting a statement involves making continuation lines using fortran-continuation-string (see Continuation Lines). This splitting happens when you type SPC, RET, or TAB, and also in the Fortran indentation commands. You activate Auto Fill in Fortran mode in the normal way. See Auto Fill Mode.

当行长超过所需宽度( 的值fill-column)时,自动填充会在空格或分隔符处断行。自动填充可以中断的分隔符(除了空格)是 '+','-','/','*','=','<','>', 和 ','。如果变量fortran-break-before-delimitersnil,则换行符位于分隔符之后。否则(默认情况下),分隔符位于分隔符之前。

Auto Fill breaks lines at spaces or delimiters when the lines get longer than the desired width (the value of fill-column). The delimiters (besides whitespace) that Auto Fill can break at are ‘+’, ‘-’, ‘/’, ‘*’, ‘=’, ‘<’, ‘>’, and ‘,’. The line break comes after the delimiter if the variable fortran-break-before-delimiters is nil. Otherwise (and by default), the break comes before the delimiter.

要在所有 Fortran 缓冲区中启用自动填充,请添加 auto-fill-modefortran-mode-hook.请参阅钩子

To enable Auto Fill in all Fortran buffers, add auto-fill-mode to fortran-mode-hook. See Hooks.


27.14.5 检查 Fortran 中的列

27.14.5 Checking Columns in Fortran

在标准 Fortran 77 中,第 72 列之外的任何内容都会被忽略。大多数编译器提供了一个选项来更改此设置(例如,'-固定线长度-N' 在 gfortran 中)。自定义变量 fortran-line-length以更改 Fortran 模式下的行长度。超出这一点的任何内容都将作为注释被字体锁定。 (除非它在字符串内部:超出范围的字符串fortran-line-length 会混淆字体锁定。)

In standard Fortran 77, anything beyond column 72 is ignored. Most compilers provide an option to change this (for example, ‘-ffixed-line-length-N’ in gfortran). Customize the variable fortran-line-length to change the line length in Fortran mode. Anything beyond this point is font-locked as a comment. (Unless it is inside a string: strings that extend beyond fortran-line-length will confuse font-lock.)

C-c C-r
C-c C-r

在当前行上方立即显示列标尺 ( fortran-column-ruler)。

Display a column ruler momentarily above the current line (fortran-column-ruler).

C-c C-w
C-c C-w

暂时水平分割当前窗口,使其为 fortran-line-length列宽 ( fortran-window-create-momentarily)。这可以帮助您避免使行的长度超过 Fortran 编译器施加的限制。

Split the current window horizontally temporarily so that it is fortran-line-length columns wide (fortran-window-create-momentarily). This may help you avoid making lines longer than the limit imposed by your Fortran compiler.

C-u C-c C-w
C-u C-c C-w

水平分割当前窗口,使其为 fortran-line-length列宽 ( fortran-window-create)。然后您可以继续编辑。

Split the current window horizontally so that it is fortran-line-length columns wide (fortran-window-create). You can then continue editing.

M-x fortran-strip-sequence-nos
M-x fortran-strip-sequence-nos

删除列中及以后的所有文本fortran-line-length

Delete all text in column fortran-line-length and beyond.

命令C-c C-r( fortran-column-ruler) 在当前行上方暂时显示一个列标尺。注释标尺是两行文本,显示 Fortran 程序中具有特殊意义的列的位置。方括号显示行号的列限制,大括号显示语句主体的列限制。列号显示在其上方。

The command C-c C-r (fortran-column-ruler) shows a column ruler momentarily above the current line. The comment ruler is two lines of text that show you the locations of columns with special significance in Fortran programs. Square brackets show the limits of the columns for line numbers, and curly brackets show the limits of the columns for the statement body. Column numbers appear above them.

请注意,列号从零开始计数,就像 GNU Emacs 中一样(但自定义column-number-indicator-zero-based可以更改列显示以匹配 Fortran 的显示;请参阅可选模式行功能。)因此,数字可能比您熟悉的数字少 1 ;但它们在行中指示的位置是 Fortran 的标准位置。

Note that the column numbers count from zero, as always in GNU Emacs (but customizing column-number-indicator-zero-based can change column display to match that of Fortran; see Optional Mode Line Features.) As a result, the numbers may be one less than those you are familiar with; but the positions they indicate in the line are standard for Fortran.

用于显示列标尺的文本取决于变量的值indent-tabs-mode。如果indent-tabs-modenil,则变量的值 fortran-column-ruler-fixed用作列标尺。否则,fortran-column-ruler-tab显示变量的值。通过更改这些变量,您可以更改列标尺的显示。

The text used to display the column ruler depends on the value of the variable indent-tabs-mode. If indent-tabs-mode is nil, then the value of the variable fortran-column-ruler-fixed is used as the column ruler. Otherwise, the value of the variable fortran-column-ruler-tab is displayed. By changing these variables, you can change the column ruler display.

C-c C-w( fortran-window-create-momentarily) 暂时水平分割当前窗口,使窗口 fortran-line-length列宽,以便您可以看到任何太长的行。键入一个空格以恢复正常宽度。

C-c C-w (fortran-window-create-momentarily) temporarily splits the current window horizontally, making a window fortran-line-length columns wide, so you can see any lines that are too long. Type a space to restore the normal width.

您还可以水平分割窗口并在分割到位的情况下继续编辑。为此,请使用C-u C-c C-w( M-x fortran-window-create)。通过在此窗口中进行编辑,您可以立即看到何时使一行太宽而无法正确显示 Fortran。

You can also split the window horizontally and continue editing with the split in place. To do this, use C-u C-c C-w (M-x fortran-window-create). By editing in this window you can immediately see when you make a line too wide to be correct Fortran.

该命令M-x fortran-strip-sequence-nos删除fortran-line-length当前缓冲区中所有行上列及列外的所有文本。这是摆脱旧序列号的最简单方法。

The command M-x fortran-strip-sequence-nos deletes all text in column fortran-line-length and beyond, on all lines in the current buffer. This is the easiest way to get rid of old sequence numbers.


27.14.6 Fortran 关键字缩写

27.14.6 Fortran Keyword Abbrevs

Fortran 模式为常见关键字和声明提供了许多内置缩写。这些缩写与您可以自己定义的缩写相同。要使用它们,您必须打开缩写模式。参见缩写

Fortran mode provides many built-in abbrevs for common keywords and declarations. These are the same sort of abbrev that you can define yourself. To use them, you must turn on Abbrev mode. See Abbrevs.

内置缩写在一方面是不寻常的:它们都以分号开头。例如,一个内置的 Fortran 缩写是 ';C' 为了 '继续'。如果你插入 ';C',然后插入标点符号,例如空格或换行符,';C' 自动扩展为 '继续',前提是启用了缩写模式。

The built-in abbrevs are unusual in one way: they all start with a semicolon. For example, one built-in Fortran abbrev is ‘;c’ for ‘continue’. If you insert ‘;c’ and then insert a punctuation character such as a space or a newline, the ‘;c’ expands automatically to ‘continue’, provided Abbrev mode is enabled.

类型 ';?' 或者 ';Ch' 显示所有内置 Fortran 缩写及其代表含义的列表。

Type ‘;?’ or ‘;C-h’ to display a list of all the built-in Fortran abbrevs and what they stand for.


28 编译和测试程序

28 Compiling and Testing Programs

上一章讨论了可用于更改程序的 Emacs 命令。本章讨论有助于编译和测试程序的命令。

The previous chapter discusses the Emacs commands that are useful for making changes in programs. This chapter deals with commands that assist in the process of compiling and testing programs.


28.1 在 Emacs 下运行编译

28.1 Running Compilations under Emacs

Emacs 可以运行 C 和 Fortran 等语言的编译器,将编译日志输入 Emacs 缓冲区。它还可以解析错误消息并显示错误发生的位置。

Emacs can run compilers for languages such as C and Fortran, feeding the compilation log into an Emacs buffer. It can also parse the error messages and show you where the errors occurred.

M-x compile
M-x compile

在 Emacs 下异步运行编译器,错误消息将发送到*汇编*缓冲。

Run a compiler asynchronously under Emacs, with error messages going to the *compilation* buffer.

M-x recompile
M-x recompile
g (Compilation mode)
g (Compilation mode)

使用与上次调用 相同的命令调用编译器 M-x compile

Invoke a compiler with the same command as in the last invocation of M-x compile.

M-x kill-compilation
M-x kill-compilation

终止正在运行的编译子进程。

Kill the running compilation subprocess.

要运行make或其他编译命令,请键入M-x compile。它使用迷你缓冲区读取 shell 命令行,然后通过将 shell 作为 Emacs 的子进程(或 下级进程)运行来执行命令。输出被插入到名为的缓冲区中*汇编*。当前缓冲区的默认目录用作执行命令的工作目录,因此默认情况下编译发生在该目录中。

To run make or another compilation command, type M-x compile. This reads a shell command line using the minibuffer, and then executes the command by running a shell as a subprocess (or inferior process) of Emacs. The output is inserted in a buffer named *compilation*. The current buffer’s default directory is used as the working directory for the execution of the command, so by default compilation takes place in that directory.

默认编译命令是'使-k',这对于使用该make实用程序编译的程序通常是正确的('-k' 标志告诉make在错误发生后尽可能继续编译)。请参阅GNU Make 手册中的Make。如果您之前已经执行过,则您指定的命令会自动存储在变量中 ;这将在您下次键入时用作默认值。文件还可以指定文件本地值(请参阅文件中的本地变量)。 M-x compilecompile-commandM-x compilecompile-command

The default compilation command is ‘make -k’, which is usually correct for programs compiled using the make utility (the ‘-k’ flag tells make to continue compiling as much as possible after an error). See Make in GNU Make Manual. If you have done M-x compile before, the command that you specified is automatically stored in the variable compile-command; this is used as the default the next time you type M-x compile. A file can also specify a file-local value for compile-command (see Local Variables in Files).

开始编译会显示*汇编*在另一个窗口中缓冲但不选择它。当编译运行时,单词 '跑步' 显示在主模式指示器中*汇编*缓冲区,以及单词 '编译' 出现在所有模式行中。您不必保留*汇编* 编译运行时缓冲区可见;无论如何,它都会继续。当编译结束时,无论出于何种原因,模式行 *汇编*缓冲区更改为“出口'(后跟退出代码:'[0]' 正常退出),或 '信号'(如果信号终止了进程)。

Starting a compilation displays the *compilation* buffer in another window but does not select it. While the compilation is running, the word ‘run’ is shown in the major mode indicator for the *compilation* buffer, and the word ‘Compiling’ appears in all mode lines. You do not have to keep the *compilation* buffer visible while compilation is running; it continues in any case. When the compilation ends, for whatever reason, the mode line of the *compilation* buffer changes to say ‘exit’ (followed by the exit code: ‘[0]’ for a normal exit), or ‘signal’ (if a signal terminated the process).

如果您想观看出现的编译记录,请切换到*汇编*缓冲区并将指针移动到缓冲区的末尾。当 point 位于末尾时,新的编译输出将插入到 point 之上,并保留在末尾。否则,当编译输出添加到缓冲区末尾时,点保持固定。

If you want to watch the compilation transcript as it appears, switch to the *compilation* buffer and move point to the end of the buffer. When point is at the end, new compilation output is inserted above point, which remains at the end. Otherwise, point remains fixed while compilation output is added at the end of the buffer.

当编译进行时,模式行显示编译器迄今为止发出的错误、警告和信息性消息的数量。

While compilation proceeds, the mode line shows the number of errors, warnings, and informational messages emitted by the compiler so far.

如果将变量更改compilation-scroll-output为非值nil,则*汇编*缓冲区自动滚动以跟随输出。如果值为 first-error,则在出现第一个错误时停止滚动,并将光标停留在该错误处。对于任何其他非nil值,滚动将继续,直到不再有输出。

If you change the variable compilation-scroll-output to a non-nil value, the *compilation* buffer scrolls automatically to follow the output. If the value is first-error, scrolling stops when the first error appears, leaving point at that error. For any other non-nil value, scrolling continues until there is no more output.

要使用相同的命令重新运行上次编译,请键入M-x recompile。这将重用上次调用的编译命令M-x compile。它还重用了 *汇编*buffer 并在其默认目录中开始编译,该目录是先前编译开始的目录。在*汇编*此命令绑定到的缓冲区 g

To rerun the last compilation with the same command, type M-x recompile. This reuses the compilation command from the last invocation of M-x compile. It also reuses the *compilation* buffer and starts the compilation in its default directory, which is the directory in which the previous compilation was started. In *compilation* buffers this command is bound to g.

启动新的编译也会杀死已经运行的任何编译*汇编*,因为缓冲区在任何时候只能处理一次编译。但是,在实际终止正在运行的编译之前要求确认M-x compileM-x recompile要始终自动终止编译而不询问,请将变量更改compilation-always-killt.您还可以使用命令终止编译进程 M-x kill-compilation

Starting a new compilation also kills any compilation already running in *compilation*, as the buffer can only handle one compilation at any time. However, M-x compile and M-x recompile ask for confirmation before actually killing a compilation that is running; to always automatically kill the compilation without asking, change the variable compilation-always-kill to t. You can also kill a compilation process with the command M-x kill-compilation.

要同时运行两个编译,请启动第一个编译,然后重命名*汇编*buffer(也许使用rename-uniquely;请参阅其他缓冲区操作),然后切换缓冲区并开始另一个编译。这将创建一个新的*汇编*缓冲。

To run two compilations at once, start the first one, then rename the *compilation* buffer (perhaps using rename-uniquely; see Miscellaneous Buffer Operations), then switch buffers and start the other compilation. This will create a new *compilation* buffer.

您可以使用变量控制传递给编译命令的环境compilation-environment。它的值是环境变量设置的列表;每个元素应该是 形式的字符串。这些环境变量设置会覆盖通常的环境变量设置。 "envvarname=value"

You can control the environment passed to the compilation command with the variable compilation-environment. Its value is a list of environment variable settings; each element should be a string of the form "envvarname=value". These environment variable settings override the usual ones.

在编译输出中显示极长的行会降低 Emacs 的速度。长度超过的行 compilation-max-output-line-length会将超过该限制的部分隐藏在按钮后面,单击该按钮即可显示隐藏的部分。将此变量设置为nil从不隐藏任何内容。

Displaying extremely long lines in compilation output can slow Emacs down. Lines that are longer than compilation-max-output-line-length will have the portion that’s exceeds that limit hidden behind a button that can be clicked on to reveal the hidden portion. Set this variable to nil to never hide anything.


28.2 编译模式

28.2 Compilation Mode

*汇编*buffer 使用一种称为编译模式的主要模式。编译模式将缓冲区中的每条错误信息都变成一个超链接;您可以将指针移至该位置并键入RET,或用鼠标单击它(请参阅使用鼠标跟随参考),以在单独的窗口中访问错误消息的位置。轨迹是文件中发生错误的特定位置。

The *compilation* buffer uses a major mode called Compilation mode. Compilation mode turns each error message in the buffer into a hyperlink; you can move point to it and type RET, or click on it with the mouse (see Following References with the Mouse), to visit the locus of the error message in a separate window. The locus is the specific position in a file where that error occurred.

外观*汇编*可以通过自定义用于突出显示部分的面来控制缓冲区 *汇编*缓冲区,例如compilation-errorcompilation-warning,分别用于错误和警告消息。请注意,由于这些面继承自 errorwarning面,因此也可以直接自定义父面。

The appearance of the *compilation* buffer can be controlled by customizing the faces which are used to highlight parts of the *compilation* buffer, e.g., compilation-error or compilation-warning, for error and warning messages respectively. Note that since those faces inherit from the error and warning faces, it is also possible to customize the parent face directly instead.

用于查看自定义变量和面孔的完整列表。 M-x customize-group RET compilation

Use M-x customize-group RET compilation to see the entire list of customization variables and faces.

如果将变量更改 compilation-auto-jump-to-first-error为非值nil,Emacs 会自动访问出现在*汇编*缓冲。 (该变量还可以具有值if-location-knownfirst-known,它们修改自动访问错误轨迹的条件。)

If you change the variable compilation-auto-jump-to-first-error to a non-nil value, Emacs automatically visits the locus of the first error message that appears in the *compilation* buffer. (This variable can also have the values if-location-known and first-known, which modify the conditions for automatically visiting the error locus.)

编译模式提供以下附加命令。这些命令也可用于*grep*缓冲区,其中的超链接是搜索匹配项而不是错误消息(请参阅Emacs 下的使用 Grep 进行搜索)。

Compilation mode provides the following additional commands. These commands can also be used in *grep* buffers, where the hyperlinks are search matches rather than error messages (see Searching with Grep under Emacs).

M-g M-n
M-g M-n
M-g n
M-g n
C-x `
C-x `

访问下一条错误消息或匹配的位置 ( next-error)。

Visit the locus of the next error message or match (next-error).

M-g M-p
M-g M-p
M-g p
M-g p

访问上一个错误消息的位置或匹配 ( previous-error)。

Visit the locus of the previous error message or match (previous-error).

M-n
M-n

将点移动到下一个错误消息或匹配项,而不访问其轨迹 ( compilation-next-error)。

Move point to the next error message or match, without visiting its locus (compilation-next-error).

M-p
M-p

将点移动到上一个错误消息或匹配项,而不访问其轨迹 ( compilation-previous-error)。

Move point to the previous error message or match, without visiting its locus (compilation-previous-error).

M-}
M-}

将指针移至下一个错误消息或在不同文件中出现的匹配项 ( compilation-next-file)。

Move point to the next error message or match occurring in a different file (compilation-next-file).

M-{
M-{

将点移至上一个错误消息或在不同文件中出现的匹配项 ( compilation-previous-file)。

Move point to the previous error message or match occurring in a different file (compilation-previous-file).

C-c C-f
C-c C-f

切换下一个错误跟随次要模式,这使得编译缓冲区中的光标移动产生自动源显示。

Toggle Next Error Follow minor mode, which makes cursor motion in the compilation buffer produce automatic source display.

g
g

重新运行最后一个命令,其输出显示在 *汇编*缓冲。

Re-run the last command whose output is shown in the *compilation* buffer.

M-x next-error-select-buffer
M-x next-error-select-buffer

next-error选择下次调用和 时要使用的缓冲区previous-error

Select a buffer to be used by next invocation of next-error and previous-error.

要按顺序访问错误,请键入C-x ` ( next-error) 或等效的M-g M-nM-g n。该命令可以从任何缓冲区调用,而不仅仅是编译模式缓冲区。编译后第一次调用它时,它会访问第一条错误消息的位置。随后的每个 错误都会以类似的方式访问下一个错误。如果您使用或单击鼠标 访问特定错误M-g M-nRET*汇编*缓冲区,后续命令从那里前进。当发现不再有错误消息可访问时,它发出错误信号。 再次从编译缓冲区的开头开始,并访问第一个轨迹。 M-g M-nM-g M-nC-u M-g M-n

To visit errors sequentially, type C-x ` (next-error), or equivalently M-g M-n or M-g n. This command can be invoked from any buffer, not just a Compilation mode buffer. The first time you invoke it after a compilation, it visits the locus of the first error message. Each subsequent M-g M-n visits the next error, in a similar fashion. If you visit a specific error with RET or a mouse click in the *compilation* buffer, subsequent M-g M-n commands advance from there. When M-g M-n finds no more error messages to visit, it signals an error. C-u M-g M-n starts again from the beginning of the compilation buffer, and visits the first locus.

M-g M-pM-g p( previous-error) 以相反方向迭代错误。

M-g M-p or M-g p (previous-error) iterates through errors in the opposite direction.

next-error和命令previous-error不仅仅作用于中列出的错误或匹配项*汇编**grep*缓冲器;他们还知道如何迭代其他命令生成的错误或匹配列表,例如M-x occur (请参阅其他搜索和循环命令)。如果当前缓冲区包含错误消息或匹配项,这些命令将迭代它们;否则,Emacs 会在所选帧的窗口中查找包含错误消息或匹配项的缓冲区(如果将变量 next-error-find-buffer-function自定义为值 ),然后查找或next-error-buffer-on-selected-frame之前使用的缓冲区,最后查找所有其他缓冲区。这些命令循环访问的任何当前未显示在窗口中的缓冲区都将被显示。您可以使用该命令切换到不同的缓冲区以供后续调用使用 。 next-errorprevious-errornext-error-select-buffernext-error

The next-error and previous-error commands don’t just act on the errors or matches listed in *compilation* and *grep* buffers; they also know how to iterate through error or match lists produced by other commands, such as M-x occur (see Other Search-and-Loop Commands). If the current buffer contains error messages or matches, these commands will iterate through them; otherwise, Emacs looks for a buffer containing error messages or matches amongst the windows of the selected frame (if the variable next-error-find-buffer-function is customized to the value next-error-buffer-on-selected-frame), then for a buffer used previously by next-error or previous-error, and finally all other buffers. Any buffer these commands iterate through that is not currently displayed in a window will be displayed. You can use the next-error-select-buffer command to switch to a different buffer to be used by the subsequent invocation of next-error.

默认情况下,next-errorprevious-error命令会跳过不太重要的消息。变量 compilation-skip-threshold控制这一点。默认值 1 表示跳过任何比警告不太重要的内容。值 2 表示跳过任何比错误不太重要的内容,而 0 表示不跳过任何消息。

By default, the next-error and previous-error commands skip less important messages. The variable compilation-skip-threshold controls this. The default value, 1, means to skip anything less important than a warning. A value of 2 means to skip anything less important than an error, while 0 means not to skip any messages.

当 Emacs 访问错误消息的位置时,它会立即突出显示相关的源代码行。该突出显示的持续时间由next-error-highlight所选缓冲区中的轨迹的变量和next-error-highlight-no-select非所选缓冲区中的轨迹的变量确定。您还可以自定义变量 next-error-message-highlight,该变量定义如何突出显示包含消息的缓冲区中的当前错误消息。

When Emacs visits the locus of an error message, it momentarily highlights the relevant source line. The duration of this highlight is determined by the variable next-error-highlight for the locus in the selected buffer, and next-error-highlight-no-select for the locus in non-selected buffers. Also you can customize the variable next-error-message-highlight that defines how to highlight the current error message in the buffer that contains messages.

如果*汇编*缓冲区显示在带有左边缘的窗口中(请参阅窗口边缘),轨迹访问命令在边缘中放置一个箭头,指向当前的错误消息。如果窗口没有左边缘,例如在文本终端上,这些命令会滚动窗口,使当前消息位于窗口顶部。如果将变量更改compilation-context-linest,则会在零列之前插入一个可见的箭头。如果将变量更改为整数值n,这些命令将滚动窗口,以便当前错误消息从顶部开始n行,无论是否有边缘;默认值nil给出了上述行为。

If the *compilation* buffer is shown in a window with a left fringe (see Window Fringes), the locus-visiting commands put an arrow in the fringe, pointing to the current error message. If the window has no left fringe, such as on a text terminal, these commands scroll the window so that the current message is at the top of the window. If you change the variable compilation-context-lines to t, a visible arrow is inserted before column zero instead. If you change the variable to an integer value n, these commands scroll the window so that the current error message is n lines from the top, whether or not there is a fringe; the default value, nil, gives the behavior described above.

编译输出有时可能非常冗长,并且其中大部分内容并不是用户特别感兴趣的。用户 compilation-hidden-output选项应该是正则表达式或正则表达式列表,并且匹配的输出将变得不可见。例如,要隐藏递归 makefile 的详细输出,您可以这样说:

Compilation output can sometimes be very verbose, and much of it isn’t of particular interest to a user. The compilation-hidden-output user option should either be a regexp or a list of regexps, and output that matches will be made invisible. For instance, to hide the verbose output from recursive makefiles, you can say something like:

(setq 编译-隐藏-输出
      '("^make[^\n]+\n"))
(setq compilation-hidden-output
      '("^make[^\n]+\n"))

为了解析来自编译器的消息,编译模式使用列出各种错误消息格式的变量compilation-error-regexp-alist,并告诉 Emacs 如何从每种格式中提取轨迹。类似的变量grep-regexp-alist告诉 Emacs 如何解析grep命令的输出(请参阅Emacs 下的使用 Grep 进行搜索)。

To parse messages from the compiler, Compilation mode uses the variable compilation-error-regexp-alist which lists various error message formats and tells Emacs how to extract the locus from each. A similar variable, grep-regexp-alist, tells Emacs how to parse output from a grep command (see Searching with Grep under Emacs).

编译模式还定义了按键SPCDEL逐屏滚动;M-n( compilation-next-error) 和 M-p( compilation-previous-error) 移至下一条或上一条错误消息;和M-{( compilation-next-file) 和M-}( compilation-previous-file) 移动到不同源文件的下一个或上一个错误消息。

Compilation mode also defines the keys SPC and DEL to scroll by screenfuls; M-n (compilation-next-error) and M-p (compilation-previous-error) to move to the next or previous error message; and M-{ (compilation-next-file) and M-} (compilation-previous-file) to move to the next or previous error message for a different source file.

您可以键入C-c C-f来切换下一个错误跟随模式。在这种次要模式下,编译缓冲区中的普通光标移动会自动更新源缓冲区,即,将光标移动到错误消息上会导致显示该错误的位置。

You can type C-c C-f to toggle Next Error Follow mode. In this minor mode, ordinary cursor motion in the compilation buffer automatically updates the source buffer, i.e., moving the cursor over an error message causes the locus of that error to be displayed.

编译模式的功能在称为编译次要模式的次要模式中也可用。这使您可以解析任何缓冲区中的错误消息,而不仅仅是普通的编译输出缓冲区。键入 M-x compilation-minor-mode以启用次要模式。例如,在 Rlogin 缓冲区中(请参阅远程主机 Shell),编译次要模式会自动通过 FTP 访问远程源文件(请参阅文件名)。

The features of Compilation mode are also available in a minor mode called Compilation Minor mode. This lets you parse error messages in any buffer, not just a normal compilation output buffer. Type M-x compilation-minor-mode to enable the minor mode. For instance, in an Rlogin buffer (see Remote Host Shell), Compilation minor mode automatically accesses remote source files by FTP (see File Names).


28.3 编译子shell

28.3 Subshells for Compilation

本节包括在编译缓冲区中使用 shell 及其功能的各种技术和建议。本材料特定于本地编译,并且很可能无法在默认目录位于远程主机上的编译缓冲区中工作(或与之无关)。

This section includes various techniques and advice for using a shell and its features in compilation buffers. This material is specific to local compilations, and will most probably not work in (or be irrelevant to) compilation buffers whose default directory is on remote hosts.

M-x compile命令使用 shell 运行编译命令,但指定非交互式 shell 的选项。这尤其意味着 shell 应该在没有提示的情况下启动。如果您发现常用的 shell 提示符在 *汇编*buffer,这意味着你在 shell 的 init 文件中无条件设置提示符时犯了一个错误。 (这个初始化文件可能被命名为.bashrc,。轮廓,.cshrc, .shrc等,具体取决于您使用的 shell。)shell 初始化文件应仅在已有提示时设置提示。在 bash 中执行此操作的方法如下:

The M-x compile command uses a shell to run the compilation command, but specifies the option for a noninteractive shell. This means, in particular, that the shell should start with no prompt. If you find your usual shell prompt making an unsightly appearance in the *compilation* buffer, it means you have made a mistake in your shell’s init file by setting the prompt unconditionally. (This init file may be named .bashrc, .profile, .cshrc, .shrc, etc., depending on what shell you use.) The shell init file should set the prompt only if there already is a prompt. Here’s how to do it in bash:

if [ "${PS1+set}" = 设置 ]
那么 PS1=...
菲
if [ "${PS1+set}" = set ]
then PS1=…
fi

以下是在 csh 中执行此操作的方法:

And here’s how to do it in csh:

if ($?prompt) 设置提示 = ...
if ($?prompt) set prompt = …

如果要自定义TERM传递到编译子 shell 的环境变量的值,请自定义该变量 comint-terminfo-terminal(请参阅Shell 模式选项)。

If you want to customize the value of the TERM environment variable passed to the compilation subshell, customize the variable comint-terminfo-terminal (see Shell Mode Options).

Emacs 不期望编译器进程启动异步子进程;如果是这样,并且它们在主编译器进程终止后继续运行,Emacs 可能会杀死它们,或者它们的输出可能不会到达 Emacs。为了避免此问题,请让主编译进程等待其子进程完成。在 shell 脚本中,您可以使用 '$!' 和 '等待', 像这样:

Emacs does not expect a compiler process to launch asynchronous subprocesses; if it does, and they keep running after the main compiler process has terminated, Emacs may kill them or their output may not arrive in Emacs. To avoid this problem, make the main compilation process wait for its subprocesses to finish. In a shell script, you can do this using ‘$!’ and ‘wait’, like this:

(睡眠 10;回显 2nd)& pid=$! #记录子进程的pid
回显第一条消息
wait $pid #等待子进程
(sleep 10; echo 2nd)& pid=$!  # Record pid of subprocess
echo first message
wait $pid                     # Wait for subprocess

如果后台进程没有输出到编译缓冲区,那么你只需要防止它在主编译进程终止时被杀死,这就足够了:

If the background process does not output to the compilation buffer, so you only need to prevent it from being killed when the main compilation process terminates, this is sufficient:

nohup命令;睡觉 1
nohup command; sleep 1

在 MS-DOS 上,不支持异步子进程,因此M-x compile同步运行编译命令(即,必须等到命令完成才能在 Emacs 中执行任何其他操作)。请参阅Emacs 和 MS-DOS

On MS-DOS, asynchronous subprocesses are not supported, so M-x compile runs the compilation command synchronously (i.e., you must wait until the command finishes before you can do anything else in Emacs). See Emacs and MS-DOS.


28.4 Emacs下使用Grep搜索

28.4 Searching with Grep under Emacs

正如您可以从 Emacs 运行编译器然后访问存在编译错误的行一样,您也可以运行grep然后访问找到匹配项的行。这是通过将 报告的匹配视为grep错误来工作的。输出缓冲区使用 Grep 模式,它是编译模式的变体(请参阅编译模式)。

Just as you can run a compiler from Emacs and then visit the lines with compilation errors, you can also run grep and then visit the lines on which matches were found. This works by treating the matches reported by grep as if they were errors. The output buffer uses Grep mode, which is a variant of Compilation mode (see Compilation Mode).

M-x grep
M-x grep
M-x lgrep
M-x lgrep

在 Emacs 下异步运行grep,列出名为的缓冲区中的匹配行*grep*

Run grep asynchronously under Emacs, listing matching lines in the buffer named *grep*.

M-x grep-find
M-x grep-find
M-x find-grep
M-x find-grep
M-x rgrep
M-x rgrep

运行grepvia find,并收集输出 *grep*缓冲。

Run grep via find, and collect output in the *grep* buffer.

M-x zrgrep
M-x zrgrep

运行zgrep并收集输出*grep*缓冲。

Run zgrep and collect output in the *grep* buffer.

M-x kill-grep
M-x kill-grep

杀死正在运行的grep子进程。

Kill the running grep subprocess.

要运行grep,请键入M-x grep,然后输入指定运行方式的命令行grep。使用grep与正常运行时给出的参数相同的参数: grep-style regexp(通常用单引号来引用 shell 的特殊字符),后跟文件名,可以使用通配符。如果为 指定前缀参数,它将在 point 周围的缓冲区中M-x grep查找标识符(请参阅查找标识符引用grep),并将其放入默认命令中。

To run grep, type M-x grep, then enter a command line that specifies how to run grep. Use the same arguments you would give grep when running it normally: a grep-style regexp (usually in single-quotes to quote the shell’s special characters) followed by file names, which may use wildcards. If you specify a prefix argument for M-x grep, it finds the identifier (see Find Identifier References) in the buffer around point, and puts that into the default grep command.

您的命令不需要简单地运行grep;您可以使用任何以相同格式生成输出的 shell 命令。例如,您可以链接grep命令,如下所示:

Your command need not simply run grep; you can use any shell command that produces output in the same format. For instance, you can chain grep commands, like this:

grep -nH -e foo *.el | grep -nH -e foo *.el | grep -nH -e foo *.el | grep 栏 | grep 托托
grep -nH -e foo *.el | grep bar | grep toto

的输出grep进入*grep*缓冲。您可以使用、等在原始文件中找到相应的行,就像编译错误一样。有关命令和键绑定的详细说明,请参阅编译模式。M-g M-nRET*grep*缓冲。

The output from grep goes in the *grep* buffer. You can find the corresponding lines in the original files using M-g M-n, RET, and so forth, just like compilation errors. See Compilation Mode, for detailed description of commands and key bindings available in the *grep* buffer.

一些 grep 程序接受 '- 颜色' 选项在匹配项周围输出特殊标记以突出显示。您可以通过设置grep-highlight-matches为 来 使用此功能t。当在源缓冲区中显示匹配项时,将突出显示完全匹配的项,而不是整个源代码行。通过匹配 发出的ANSI转义序列来提供突出显示grep。序列的匹配由 控制grep-match-regexp,可以定制以适应不同的grep程序。

Some grep programs accept a ‘--color’ option to output special markers around matches for the purpose of highlighting. You can make use of this feature by setting grep-highlight-matches to t. When displaying a match in the source buffer, the exact match will be highlighted, instead of the entire source line. Highlighting is provided via matching the ANSI escape sequences emitted by grep. The matching of the sequences is controlled by grep-match-regexp, which can be customized to accommodate different grep programs.

与编译命令一样(请参阅Emacs 下的运行编译),当 grep 命令运行时,模式行显示到目前为止找到并突出显示的匹配项的运行数量。

As with compilation commands (see Running Compilations under Emacs), while the grep command runs, the mode line shows the running number of matches found and highlighted so far.

这些grep命令将在运行前保存缓冲区。这是由grep-save-buffers变量控制的。可能的值是nil(不保存)、ask (保存前询问)或将用作谓词的函数(并且以文件名作为参数调用,并且nil如果要保存缓冲区,则应返回非)已保存)。任何其他非nil值意味着所有缓冲区都应在不询问的情况下保存。默认为ask.

The grep commands will offer to save buffers before running. This is controlled by the grep-save-buffers variable. The possible values are either nil (don’t save), ask (ask before saving), or a function which will be used as a predicate (and is called with the file name as the parameter and should return non-nil if the buffer is to be saved). Any other non-nil value means that all buffers should be saved without asking. The default is ask.

该命令M-x grep-find(也可用作M-x find-grep)与 类似M-x grep,但它为该命令提供了不同的初始默认值 - 一个同时运行find和 的命令grep,以便搜索目录树中的每个文件。另请参阅Dired 和find-grep-dired中的命令。 find

The command M-x grep-find (also available as M-x find-grep) is similar to M-x grep, but it supplies a different initial default for the command—one that runs both find and grep, so as to search every file in a directory tree. See also the find-grep-dired command, in Dired and find.

命令M-x lgrep(local grep) 和(recursive grep) 是和 M-x rgrep 的更用户友好的版本,它们分别提示要匹配的正则表达式、要搜索的文件以及搜索的基目录。搜索的区分大小写由 的当前值控制 。该命令类似于 ,但它调用而不是 搜索 gzip 压缩文件的内容。 grepgrep-findcase-fold-searchM-x zrgrepM-x rgrepzgrepgrep

The commands M-x lgrep (local grep) and M-x rgrep (recursive grep) are more user-friendly versions of grep and grep-find, which prompt separately for the regular expression to match, the files to search, and the base directory for the search. Case sensitivity of the search is controlled by the current value of case-fold-search. The command M-x zrgrep is similar to M-x rgrep, but it calls zgrep instead of grep to search the contents of gzipped files.

这些命令基于变量 grep-template(for lgrep) 和grep-find-template (for rgrep) 构建 shell 命令。要搜索的文件可以使用变量中定义的别名grep-files-aliases

These commands build the shell commands based on the variables grep-template (for lgrep) and grep-find-template (for rgrep). The files to search can use aliases defined in the variable grep-files-aliases.

变量中列出的目录 grep-find-ignored-directories会自动跳过 M-x rgrep。默认值包括各种版本控制系统使用的数据目录。

Directories listed in the variable grep-find-ignored-directories are automatically skipped by M-x rgrep. The default value includes the data directories used by various version control systems.

lgrep默认情况下,为、 rgrep和构建的 shell 命令zgrep会通过隐藏包含要忽略的一长串文件和目录的部分来缩写显示。您可以通过单击代表它们的带有省略号的按钮来显示隐藏的部分。您还可以通过键入 来交互式切换查看隐藏部分M-x grep-find-toggle-abbreviation。要禁用 shell 命令的此缩写,请将该选项自定义grep-find-abbreviate为一个 nil值。

By default, the shell commands constructed for lgrep, rgrep, and zgrep are abbreviated for display by concealing the part that contains a long list of files and directories to ignore. You can reveal the concealed part by clicking on the button with ellipsis, which represents them. You can also interactively toggle viewing the concealed part by typing M-x grep-find-toggle-abbreviation. To disable this abbreviation of the shell commands, customize the option grep-find-abbreviate to a nil value.


28.5 动态查找语法错误

28.5 Finding Syntax Errors On The Fly

Flymake 模式是一种次要模式,可为许多编程和标记语言(包括 C、C++、Perl、HTML 和 TeX/LaTeX)执行即时语法检查。它有点类似于 Flyspell 模式,后者以类似的方式对普通人类语言执行拼写检查(请参阅检查和纠正拼写)。当您编辑文件时,Flymake 模式会使用缓冲区的临时副本在后台运行适当的语法检查工具。然后它解析错误和警告消息,并突出显示缓冲区中的错误行。使用的语法检查工具取决于语言;例如,对于 C/C++ 文件,这通常是 C 编译器。 Flymake 还可以使用构建工具,例如make检查复杂的项目。

Flymake mode is a minor mode that performs on-the-fly syntax checking for many programming and markup languages, including C, C++, Perl, HTML, and TeX/LaTeX. It is somewhat analogous to Flyspell mode, which performs spell checking for ordinary human languages in a similar fashion (see Checking and Correcting Spelling). As you edit a file, Flymake mode runs an appropriate syntax checking tool in the background, using a temporary copy of the buffer. It then parses the error and warning messages, and highlights the erroneous lines in the buffer. The syntax checking tool used depends on the language; for example, for C/C++ files this is usually the C compiler. Flymake can also use build tools such as make for checking complicated projects.

要启用 Flymake 模式,请输入M-x flymake-mode。您可以使用和跳转到它发现的错误。要显示当前缓冲区诊断的详细概述,请使用命令;要显示整个项目的类似诊断概述(请参阅使用项目),请使用。 M-x flymake-goto-next-errorM-x flymake-goto-prev-errorM-x flymake-show-buffer-diagnosticsM-x flymake-show-project-diagnostics

To enable Flymake mode, type M-x flymake-mode. You can jump to the errors that it finds by using M-x flymake-goto-next-error and M-x flymake-goto-prev-error. To display a detailed overview of the diagnostics for the current buffer, use the command M-x flymake-show-buffer-diagnostics; to display a similar overview of diagnostics for the entire project (see Working with Projects), use M-x flymake-show-project-diagnostics.

有关使用 Flymake 的更多详细信息,请参阅Flymake 手册中的Flymake

For more details about using Flymake, see Flymake in The Flymake Manual.


28.6 在Emacs下运行调试器

28.6 Running Debuggers Under Emacs

GUD(Grand Unified Debugger)库为各种符号调试器提供了 Emacs 接口。它可以运行 GNU 调试器 (GDB),以及 DBX、SDB、XDB、Guile REPL 调试命令、Perl 调试模式、Python 调试器 PDB 和 Java 调试器 JDB。

The GUD (Grand Unified Debugger) library provides an Emacs interface to a wide variety of symbolic debuggers. It can run the GNU Debugger (GDB), as well as DBX, SDB, XDB, Guile REPL debug commands, Perl’s debugging mode, the Python debugger PDB, and the Java Debugger JDB.

Emacs 为 GDB 提供了一个特殊的接口,它使用额外的 Emacs 窗口来显示被调试程序的状态。请参阅GDB 图形界面

Emacs provides a special interface to GDB, which uses extra Emacs windows to display the state of the debugged program. See GDB Graphical Interface.

Emacs 还具有用于 Emacs Lisp 程序的内置调试器。请参阅Emacs Lisp 参考手册中的Lisp 调试器

Emacs also has a built-in debugger for Emacs Lisp programs. See The Lisp Debugger in the Emacs Lisp Reference Manual.


28.6.1 启动GUD

28.6.1 Starting GUD

有多个用于启动调试器子进程的命令,每个命令对应于一个特定的调试器程序。

There are several commands for starting a debugger subprocess, each corresponding to a particular debugger program.

M-x gdb
M-x gdb

将 GDB 作为子进程运行,并通过类似 IDE 的 Emacs 界面与其交互。有关此命令的更多信息, 请参阅GDB 图形界面。

Run GDB as a subprocess, and interact with it via an IDE-like Emacs interface. See GDB Graphical Interface, for more information about this command.

M-x gud-gdb
M-x gud-gdb

运行 GDB,使用 GUD 交互缓冲区进行 GDB 子进程的输入和输出(请参阅调试器操作)。如果这样的缓冲区已经存在,则切换到它;否则,创建缓冲区并切换到它。

对于其他调试器程序,此列表中的其他命令执行相同的操作。

Run GDB, using a GUD interaction buffer for input and output to the GDB subprocess (see Debugger Operation). If such a buffer already exists, switch to it; otherwise, create the buffer and switch to it.

The other commands in this list do the same, for other debugger programs.

M-x perldb
M-x perldb

在调试模式下运行 Perl 解释器。

Run the Perl interpreter in debug mode.

M-x jdb
M-x jdb

运行 Java 调试器。

Run the Java debugger.

M-x pdb
M-x pdb

运行 Python 调试器。

Run the Python debugger.

M-x guiler
M-x guiler

运行 Guile REPL 来调试 Guile Scheme 程序。

Run Guile REPL for debugging Guile Scheme programs.

M-x dbx
M-x dbx

运行 DBX 调试器。

Run the DBX debugger.

M-x xdb
M-x xdb

运行 XDB 调试器。

Run the XDB debugger.

M-x sdb
M-x sdb

运行 SDB 调试器。

Run the SDB debugger.

这些命令中的每一个都使用迷你缓冲区读取命令行来调用调试器。迷你缓冲区的初始内容包含标准可执行文件名称和调试器选项,有时还包含对要调试的可执行文件名称的猜测。此命令行中不允许使用 Shell 通配符和变量。 Emacs 假定第一个命令参数不以 ' 开头-' 是可执行文件名。

Each of these commands reads a command line to invoke the debugger, using the minibuffer. The minibuffer’s initial contents contain the standard executable name and options for the debugger, and sometimes also a guess for the name of the executable file you want to debug. Shell wildcards and variables are not allowed in this command line. Emacs assumes that the first command argument which does not start with a ‘-’ is the executable file name.

TRAMP 提供了远程调试的工具,调试器和被调试的程序都位于同一远程主机上。有关详细信息,请参阅The Tramp Manual中的在远程主机上运行调试器。这与 GDB 的远程调试功能是分开的,其中程序和调试器在不同的机器上运行(请参阅GNU 调试器中的调试远程程序)。

Tramp provides a facility for remote debugging, whereby both the debugger and the program being debugged are on the same remote host. See Running a debugger on a remote host in The Tramp Manual, for details. This is separate from GDB’s remote debugging feature, where the program and the debugger run on different machines (see Debugging Remote Programs in The GNU debugger).


28.6.2 调试器操作

28.6.2 Debugger Operation

GUD交互缓冲区是一个 Emacs 缓冲区,用于将文本命令发送到调试器子进程,并记录其输出。这是与调试器交互的基本接口,由 启动 GUDM-x gud-gdb中列出的命令和其他命令 使用。该命令使用额外的专用缓冲区扩展了此接口,用于控制断点、堆栈帧和调试器状态的其他方面(请参阅GDB 图形界面)。 M-x gdb

The GUD interaction buffer is an Emacs buffer which is used to send text commands to a debugger subprocess, and record its output. This is the basic interface for interacting with a debugger, used by M-x gud-gdb and other commands listed in Starting GUD. The M-x gdb command extends this interface with additional specialized buffers for controlling breakpoints, stack frames, and other aspects of the debugger state (see GDB Graphical Interface).

GUD 交互缓冲区使用 Shell 模式的变体,因此 Shell 模式定义的 Emacs 命令可用(请参阅Shell 模式)。大多数调试器命令都可以完成(请参阅完成),并且您可以使用常用的 Shell 模式历史命令来重复它们。有关可在 GUD 交互缓冲区中使用的特殊命令, 请参阅GUD 的命令。

The GUD interaction buffer uses a variant of Shell mode, so the Emacs commands defined by Shell mode are available (see Shell Mode). Completion is available for most debugger commands (see Completion), and you can use the usual Shell mode history commands to repeat them. See Commands of GUD, for special commands that can be used in the GUD interaction buffer.

当您调试程序时,Emacs 通过访问 Emacs 缓冲区中的相关源文件来显示它们,左边缘有一个箭头指示当前执行行。 (在文本终端上,箭头显示为“=>',覆盖在前两个文本列上。)在此类缓冲区中移动点不会移动箭头。您可以自由编辑这些源文件,但请注意,插入或删除行会偏离箭头的位置,因为 Emacs 无法确定哪个编辑的源文件行对应于调试器子进程报告的行。要更新此信息,您通常必须重新编译并重新启动程序。

As you debug a program, Emacs displays the relevant source files by visiting them in Emacs buffers, with an arrow in the left fringe indicating the current execution line. (On a text terminal, the arrow appears as ‘=>’, overlaid on the first two text columns.) Moving point in such a buffer does not move the arrow. You are free to edit these source files, but note that inserting or deleting lines will throw off the arrow’s positioning, as Emacs has no way to figure out which edited source line corresponds to the line reported by the debugger subprocess. To update this information, you typically have to recompile and restart the program.

GUD Tooltip 模式是一种全局次要模式,为 GUD 添加了工具提示支持。要切换此模式,请键入M-x gud-tooltip-mode。默认情况下它是禁用的。如果启用,您可以将鼠标指针移动到变量、函数或宏(统称为 标识符)上,以在工具提示中显示它们的值(请参阅工具提示)。如果仅将鼠标指针放在表达式上并不能显示您想要的表达式的值,您可以通过将鼠标拖动到表达式上,然后将鼠标留在标记区域内,更明确地告诉 Emacs 要计算哪个表达式。 GUD 工具提示模式在 GUD 交互缓冲区以及变量 中列出的主要模式的所有源缓冲区中生效gud-tooltip-modes。如果关闭工具提示模式,则值将显示在回显区域而不是工具提示中。

GUD Tooltip mode is a global minor mode that adds tooltip support to GUD. To toggle this mode, type M-x gud-tooltip-mode. It is disabled by default. If enabled, you can move the mouse pointer over a variable, a function, or a macro (collectively called identifiers) to show their values in tooltips (see Tooltips). If just placing the mouse pointer over an expression doesn’t show the value of the expression you had in mind, you can tell Emacs more explicitly what expression to evaluate by dragging the mouse over the expression, then leaving the mouse inside the marked area. The GUD Tooltip mode takes effect in the GUD interaction buffer, and in all source buffers with major modes listed in the variable gud-tooltip-modes. If you turned off the tooltip mode, values are shown in the echo area instead of a tooltip.

当使用 GUD Tooltip 模式时M-x gud-gdb,在 GDB 中显示表达式的值有时会扩展宏,从而可能在调试的程序中造成副作用。因此,gud-gdb禁用了使用工具提示。如果使用M-x gdb 接口,就不会出现这个问题,因为有特殊的代码来避免副作用;此外,您可以在程序未执行时显示与标识符关联的宏定义。

When using GUD Tooltip mode with M-x gud-gdb, displaying an expression’s value in GDB can sometimes expand a macro, potentially causing side effects in the debugged program. For that reason, using tooltips in gud-gdb is disabled. If you use the M-x gdb interface, this problem does not occur, as there is special code to avoid side-effects; furthermore, you can display macro definitions associated with an identifier when the program is not executing.


28.6.3 GUD命令

28.6.3 Commands of GUD

GUD 提供用于设置和清除断点、选择堆栈帧以及单步执行程序的命令。

GUD provides commands for setting and clearing breakpoints, selecting stack frames, and stepping through the program.

C-x C-a C-b
C-x C-a C-b

在该点所在的源代码行上设置一个断点。

Set a breakpoint on the source line that point is on.

C-x C-a C-b( gud-break) 在源缓冲区中调用时,会在当前源代码行上设置调试器断点。该命令仅在启动GUD后才可用。如果在不与任何调试器子进程关联的缓冲区中调用它,则会发出错误信号。

C-x C-a C-b (gud-break), when called in a source buffer, sets a debugger breakpoint on the current source line. This command is available only after starting GUD. If you call it in a buffer that is not associated with any debugger subprocess, it signals an error.

以下命令在 GUD 交互缓冲区和全局中均可用,但具有不同的键绑定。以 开头的键C-c仅在 GUD 交互缓冲区中可用,而以 开头的键则C-x C-a全局可用。其中一些命令也可以通过工具栏使用;某些调试器不支持某些。

The following commands are available both in the GUD interaction buffer and globally, but with different key bindings. The keys starting with C-c are available only in the GUD interaction buffer, while those starting with C-x C-a are available globally. Some of these commands are also available via the tool bar; some are not supported by certain debuggers.

C-c C-l
C-c C-l
C-x C-a C-l
C-x C-a C-l

在另一个窗口中显示 GUD 交互缓冲区 ( gud-refresh) 中引用的最后一个源代码行。

Display, in another window, the last source line referred to in the GUD interaction buffer (gud-refresh).

C-c C-s
C-c C-s
C-x C-a C-s
C-x C-a C-s

执行下一行代码 ( gud-step)。如果该行包含函数调用,则执行在进入被调用函数后停止。

Execute the next single line of code (gud-step). If the line contains a function call, execution stops after entering the called function.

C-c C-n
C-c C-n
C-x C-a C-n
C-x C-a C-n

执行下一行代码,单步执行函数调用,而不在函数内部停止 ( gud-next)。

Execute the next single line of code, stepping across function calls without stopping inside the functions (gud-next).

C-c C-i
C-c C-i
C-x C-a C-i
C-x C-a C-i

执行单条机器指令(gud-stepi)。

Execute a single machine instruction (gud-stepi).

C-c C-p
C-c C-p
C-x C-a C-p
C-x C-a C-p

计算点 ( ) 处的表达式gud-print。如果 Emacs 没有打印出您想要的确切表达式,请先将其标记为区域。

Evaluate the expression at point (gud-print). If Emacs does not print the exact expression that you want, mark it as a region first.

C-c C-r
C-c C-r
C-x C-a C-r
C-x C-a C-r

继续执行而不指定任何停止点。程序将一直运行,直到遇到断点、终止或收到调试器正在检查的信号 ( gud-cont)。

Continue execution without specifying any stopping point. The program will run until it hits a breakpoint, terminates, or gets a signal that the debugger is checking for (gud-cont).

C-c C-d
C-c C-d
C-x C-a C-d
C-x C-a C-d

删除当前源代码行上的断点(如果有)( gud-remove)。如果在 GUD 交互缓冲区中使用此命令,它将应用于程序上次停止的行。

Delete the breakpoint(s) on the current source line, if any (gud-remove). If you use this command in the GUD interaction buffer, it applies to the line where the program last stopped.

C-c C-t
C-c C-t
C-x C-a C-t
C-x C-a C-t

在当前源代码行上设置临时断点(如果有)( gud-tbreak)。如果在 GUD 交互缓冲区中使用此命令,它将应用于程序上次停止的行。

Set a temporary breakpoint on the current source line, if any (gud-tbreak). If you use this command in the GUD interaction buffer, it applies to the line where the program last stopped.

C-c <
C-c <
C-x C-a <
C-x C-a <

选择下一个封闭的堆栈帧 ( gud-up)。这相当于 GDB 命令 '向上'。

Select the next enclosing stack frame (gud-up). This is equivalent to the GDB command ‘up’.

C-c >
C-c >
C-x C-a >
C-x C-a >

选择下一个内部堆栈帧 ( gud-down)。这相当于 GDB 命令 '向下'。

Select the next inner stack frame (gud-down). This is equivalent to the GDB command ‘down’.

C-c C-u
C-c C-u
C-x C-a C-u
C-x C-a C-u

继续执行到当前行 ( gud-until)。程序将一直运行,直到遇到断点、终止、获得调试器正在检查的信号或到达光标当前所在的行。

Continue execution to the current line (gud-until). The program will run until it hits a breakpoint, terminates, gets a signal that the debugger is checking for, or reaches the line on which the cursor currently sits.

C-c C-f
C-c C-f
C-x C-a C-f
C-x C-a C-f

运行程序,直到选定的堆栈帧返回或由于其他原因停止 ( gud-finish)。

Run the program until the selected stack frame returns or stops for some other reason (gud-finish).

如果您使用 GDB,则可以使用以下附加键绑定:

If you are using GDB, these additional key bindings are available:

C-x C-a C-j
C-x C-a C-j

仅在源缓冲区中有用,gud-jump将程序的执行点传输到当前行。换句话说,程序执行的下一行将是您发出命令的行。如果新的执行行与前一个执行行位于不同的函数中,GDB 会提示确认,因为结果可能会很奇怪。jump详细信息 请参见 GDB 手册条目。

Only useful in a source buffer, gud-jump transfers the program’s execution point to the current line. In other words, the next line that the program executes will be the one where you gave the command. If the new execution line is in a different function from the previously one, GDB prompts for confirmation since the results may be bizarre. See the GDB manual entry regarding jump for details.

TAB
TAB

使用 GDB,完成符号名称 ( gud-gdb-complete-command)。该键仅在 GUD 交互缓冲区中可用。

With GDB, complete a symbol name (gud-gdb-complete-command). This key is available only in the GUD interaction buffer.

当有意义时,这些命令将数字参数解释为重复计数。

These commands interpret a numeric argument as a repeat count, when that makes sense.

因为TAB用作完成命令,所以您不能使用它来输入选项卡作为您正在使用 GDB 调试的程序的输入。相反,请键入以输入选项卡。 C-q TAB

Because TAB serves as a completion command, you can’t use it to enter a tab as input to the program you are debugging with GDB. Instead, type C-q TAB to enter a tab.


28.6.4 GUD定制

28.6.4 GUD Customization

启动时,GUD 运行以下挂钩之一: gdb-mode-hook,如果您使用的是 GDB;dbx-mode-hook,如果您使用 DBX;sdb-mode-hook,如果您使用的是 SDB; xdb-mode-hook,如果您使用的是 XDB;guiler-mode-hook 用于 Guile REPL 调试;perldb-mode-hook, 用于 Perl 调试模式;pdb-mode-hook,对于PDB;jdb-mode-hook,对于加多宝。请参阅钩子

On startup, GUD runs one of the following hooks: gdb-mode-hook, if you are using GDB; dbx-mode-hook, if you are using DBX; sdb-mode-hook, if you are using SDB; xdb-mode-hook, if you are using XDB; guiler-mode-hook for Guile REPL debugging; perldb-mode-hook, for Perl debugging mode; pdb-mode-hook, for PDB; jdb-mode-hook, for JDB. See Hooks.

Lispgud-def宏(请参阅Emacs Lisp 参考手册中的定义宏)提供了一种方便的方法来定义将特定命令字符串发送到调试器的 Emacs 命令,并在 GUD 交互缓冲区中设置键绑定:

The gud-def Lisp macro (see Defining Macros in the Emacs Lisp Reference Manual) provides a convenient way to define an Emacs command that sends a particular command string to the debugger, and set up a key binding for in the GUD interaction buffer:

(gud-def函数 cmdstring 绑定 docstring
(gud-def function cmdstring binding docstring)

这定义了一个名为function的命令,它将cmdstring发送 到调试器进程,并为其提供文档字符串docstring。然后您可以在任何缓冲区中使用命令函数。如果绑定为非nilgud-def则还将命令绑定到GUD 缓冲区的模式和 一般情况下。 C-c bindingC-x C-a binding

This defines a command named function which sends cmdstring to the debugger process, and gives it the documentation string docstring. You can then use the command function in any buffer. If binding is non-nil, gud-def also binds the command to C-c binding in the GUD buffer’s mode and to C-x C-a binding generally.

命令字符串cmdstring可能包含某些 '%'-代表调用函数时要填充的数据的序列 :

The command string cmdstring may contain certain ‘%’-sequences that stand for data to be filled in at the time function is called:

'%F'
%f

当前源文件的名称。如果当前缓冲区是GUD缓冲区,则当前源文件是程序停止的文件。

The name of the current source file. If the current buffer is the GUD buffer, then the current source file is the file that the program stopped in.

'%l'
%l

当前源代码行号。如果当前缓冲区是 GUD 缓冲区,则当前源行是程序停止的行。

The number of the current source line. If the current buffer is the GUD buffer, then the current source line is the line that the program stopped in.

'%e'
%e

在瞬态标记模式下,区域中的文本(如果处于活动状态)。否则为点处或邻近点处的 C 左值或函数调用表达式的文本。

In transient-mark-mode the text in the region, if it is active. Otherwise the text of the C lvalue or function-call expression at or adjacent to point.

'%A'
%a

点处或邻近点的十六进制地址的文本。

The text of the hexadecimal address at or adjacent to point.

'%p'
%p

被调用函数的数字参数,为十进制数。如果使用该命令时不带数字参数,'%p' 代表空字符串。

如果你不使用'%p' 在命令字符串中,您定义的命令会忽略任何数字参数。

The numeric argument of the called function, as a decimal number. If the command is used without a numeric argument, ‘%p’ stands for the empty string.

If you don’t use ‘%p’ in the command string, the command you define ignores any numeric argument.

'%d'
%d

当前源文件的目录名称。

The name of the directory of the current source file.

'%C'
%c

从周围点的表达式派生的完全限定类名(仅限 jdb)。

Fully qualified class name derived from the expression surrounding point (jdb only).


28.6.5 GDB图形界面

28.6.5 GDB Graphical Interface

该命令M-x gdb在类似 IDE 的界面中启动 GDB,并使用专门的缓冲区来控制断点、堆栈帧和调试器状态的其他方面。它还提供了使用鼠标控制调试会话的其他方法,例如单击源缓冲区的边缘以在此处设置断点。

The command M-x gdb starts GDB in an IDE-like interface, with specialized buffers for controlling breakpoints, stack frames, and other aspects of the debugger state. It also provides additional ways to control the debugging session with the mouse, such as clicking in the fringe of a source buffer to set a breakpoint there.

要仅使用 GUD 交互缓冲区接口运行 GDB,而不使用这些附加功能,请使用M-x gud-gdb(请参阅启动 GUD)。

To run GDB using just the GUD interaction buffer interface, without these additional features, use M-x gud-gdb (see Starting GUD).

在内部,M-x gdb通知GDB其屏幕大小不受限制;为了正确操作,在调试会话期间不得更改 GDB 的屏幕高度和宽度值。

Internally, M-x gdb informs GDB that its screen size is unlimited; for correct operation, you must not change GDB’s screen height and width values during the debugging session.


28.6.5.1 GDB 用户界面布局

28.6.5.1 GDB User Interface Layout

如果该变量gdb-many-windowsnil(默认值),则 M-x gdb通常仅显示 GUD 交互缓冲区。但是,如果变量gdb-show-main也是非- nil,则它会以两个窗口开始:一个显示GUD交互缓冲区,另一个显示main您正在调试的程序的函数的源代码。

If the variable gdb-many-windows is nil (the default), M-x gdb normally displays only the GUD interaction buffer. However, if the variable gdb-show-main is also non-nil, it starts with two windows: one displaying the GUD interaction buffer, and the other showing the source for the main function of the program you are debugging.

如果gdb-many-windows为非nil,则M-x gdb 显示以下框架布局:

If gdb-many-windows is non-nil, then M-x gdb displays the following frame layout:

+--------------------------------+---------------- ----------------+
| GUD交互缓冲区|本地/寄存器缓冲区 |
|--------------------------------+---------------- ----------------+
|主要源缓冲区|用于调试 pgm 的 I/O 缓冲区 |
|--------------------------------+---------------- ----------------+
|堆栈缓冲区|断点/线程缓冲区 |
+--------------------------------+---------------- ----------------+
+--------------------------------+--------------------------------+
|   GUD interaction buffer       |   Locals/Registers buffer      |
|--------------------------------+--------------------------------+
|   Primary Source buffer        |   I/O buffer for debugged pgm  |
|--------------------------------+--------------------------------+
|   Stack buffer                 |   Breakpoints/Threads buffer   |
+--------------------------------+--------------------------------+

您可以根据上面的布局自定义窗口布局,并使用 将该布局保存到文件中gdb-save-window-configuration。然后您可以稍后使用 加载此布局 gdb-load-window-configuration。 (在内部,Emacs 使用术语“窗口配置”而不是“窗口布局”。)您可以将自定义布局设置为gdb-many-windowscustomizing 所使用的默认布局gdb-default-window-configuration-file。如果不是绝对文件名,GDB 会在下面查找 gdb-window-configuration-directory该文件。 gdb-window-configuration-directory默认为 user-emacs-directory(请参阅Emacs 如何查找您的初始化文件)。

You can customize the window layout based on the one above and save that layout to a file using gdb-save-window-configuration. Then you can later load this layout back using gdb-load-window-configuration. (Internally, Emacs uses the term window configuration instead of window layout.) You can set your custom layout as the default one used by gdb-many-windows by customizing gdb-default-window-configuration-file. If it is not an absolute file name, GDB looks under gdb-window-configuration-directory for the file. gdb-window-configuration-directory defaults to user-emacs-directory (see How Emacs Finds Your Init File).

如果您更改了窗口布局,可以通过键入 来恢复默认布局M-x gdb-restore-windows。要在多窗口布局和仅包含 GUD 交互缓冲区和源文件的简单布局之间切换,请键入M-x gdb-many-windows

If you ever change the window layout, you can restore the default layout by typing M-x gdb-restore-windows. To toggle between the many windows layout and a simple layout with just the GUD interaction buffer and a source file, type M-x gdb-many-windows.

如果您有一个复杂的窗口设置,并且不想 gdb-many-windows破坏它,最好 M-x gdb首先在单独的框架中调用,然后原始框架上的窗口排列将不会受到影响。如果您在文本模式终端上工作,那么用于 GDB 会话的单独框架会特别方便,因为窗口的屏幕空间可能非常宝贵。如果选择在同一帧中启动GDB,请考虑设置gdb-restore-window-configuration-after-quit为非值nil。 GDB 退出后,您的原始布局将恢复。用于t始终恢复;仅当非时才用于 if-gdb-many-windows恢复 ;仅当为非时才用于 恢复。 gdb-many-windowsnilif-gdb-show-maingdb-show-mainnil

If you have an elaborate window setup, and don’t want gdb-many-windows to disrupt that, it is better to invoke M-x gdb in a separate frame to begin with, then the arrangement of windows on your original frame will not be affected. A separate frame for GDB sessions can come in especially handy if you work on a text-mode terminal, where the screen estate for windows could be at a premium. If you choose to start GDB in the same frame, consider setting gdb-restore-window-configuration-after-quit to a non-nil value. Your original layout will then be restored after GDB quits. Use t to always restore; use if-gdb-many-windows to restore only when gdb-many-windows is non-nil; use if-gdb-show-main to restore only when gdb-show-main is non-nil.

您还可以指定要在同一帧或不同帧中显示的其他 GDB 相关缓冲区。通过键入或 选择所需的缓冲区,其中buffertype是相关的缓冲区类型,例如 'M-x gdb-display-buffertype-bufferM-x gdb-frame-buffertype-buffer断点' 或者 'io'。您可以从菜单栏执行相同的操作,使用 'GDB-Windows' 和 'GDB 框架' 的子菜单古德' 菜单。

You may also specify additional GDB-related buffers to display, either in the same frame or a different one. Select the buffers you want by typing M-x gdb-display-buffertype-buffer or M-x gdb-frame-buffertype-buffer, where buffertype is the relevant buffer type, such as ‘breakpoints’ or ‘io’. You can do the same from the menu bar, with the ‘GDB-Windows’ and ‘GDB-Frames’ sub-menus of the ‘GUD’ menu.

默认情况下,GDB最多使用一个窗口来显示源文件。您可以通过自定义使其使用更多窗口 gdb-max-source-window-count。您还可以自定义 gdb-display-source-buffer-action来控制 GDB 如何显示源文件。

By default, GDB uses at most one window to display the source file. You can make it use more windows by customizing gdb-max-source-window-count. You can also customize gdb-display-source-buffer-action to control how GDB displays source files.

完成调试后,使用 终止 GUD 交互缓冲区 C-x k,这也会终止与会话关联的所有缓冲区。但是,如果在 Emacs 中编辑并重新编译源代码后希望继续调试,则无需执行此操作。当您重新启动执行时,GDB 会自动查找新的可执行文件。保留 GUD 交互缓冲区的优点是可以保留 shell 历史记录以及 GDB 的断点。您确实需要检查最近编辑的源文件中的断点是否仍然位于正确的位置。

When you finish debugging, kill the GUD interaction buffer with C-x k, which will also kill all the buffers associated with the session. However you need not do this if, after editing and re-compiling your source code within Emacs, you wish to continue debugging. When you restart execution, GDB automatically finds the new executable. Keeping the GUD interaction buffer has the advantage of keeping the shell history as well as GDB’s breakpoints. You do need to check that the breakpoints in recently edited source files are still in the right places.


28.6.5.2 源缓冲区

28.6.5.2 Source Buffers

mouse-1(在边缘)
mouse-1 (in fringe)

在该行 ( ) 上设置或清除断点gdb-mouse-set-clear-breakpoint

Set or clear a breakpoint on that line (gdb-mouse-set-clear-breakpoint).

C-mouse-1(在边缘)
C-mouse-1 (in fringe)

启用或禁用该行上的断点 ( gdb-mouse-toggle-breakpoint-margin)。

Enable or disable a breakpoint on that line (gdb-mouse-toggle-breakpoint-margin).

mouse-3(在边缘)
mouse-3 (in fringe)

继续执行到该行 ( gdb-mouse-until)。

Continue execution to that line (gdb-mouse-until).

C-mouse-3(在边缘)
C-mouse-3 (in fringe)

跳转到该行 ( gdb-mouse-jump)。

Jump to that line (gdb-mouse-jump).

在图形显示上,您可以单击mouse-1源缓冲区的边缘,以在该行上设置断点(请参阅窗口边缘)。您单击的位置边缘会出现一个红点。如果那里已经存在断点,则单击会将其删除。单击C-mouse-1可启用或禁用现有断点;已禁用但未取消设置的断点由灰点表示。

On a graphical display, you can click mouse-1 in the fringe of a source buffer, to set a breakpoint on that line (see Window Fringes). A red dot appears in the fringe, where you clicked. If a breakpoint already exists there, the click removes it. A C-mouse-1 click enables or disables an existing breakpoint; a breakpoint that is disabled, but not unset, is indicated by a gray dot.

在文本终端上,或者当边缘被禁用时,启用的断点用 ' 指示' 字符位于窗口的左边距。禁用的断点用 ' 表示'。 (仅当存在断点时才显示边距。)

On a text terminal, or when fringes are disabled, enabled breakpoints are indicated with a ‘B’ character in the left margin of the window. Disabled breakpoints are indicated with ‘b’. (The margin is only displayed if a breakpoint is present.)

源缓冲区左边缘的实线箭头表示调试程序停止的最内帧的行。空心箭头表示更高层框架的当前执行线。如果您使用 拖动边缘中的箭头mouse-1,则会导致执行前进到您释放按钮的行。或者,您可以单击mouse-3边缘以前进到该行。您可以单击C-mouse-3边缘跳到该行,而不执行中间行。此命令允许您向后运行,这对于运行已执行的代码非常有用,以便更详细地检查其执行情况。

A solid arrow in the left fringe of a source buffer indicates the line of the innermost frame where the debugged program has stopped. A hollow arrow indicates the current execution line of a higher-level frame. If you drag the arrow in the fringe with mouse-1, that causes execution to advance to the line where you release the button. Alternatively, you can click mouse-3 in the fringe to advance to that line. You can click C-mouse-3 in the fringe to jump to that line without executing the intermediate lines. This command allows you to go backwards, which can be useful for running through code that has already executed, in order to examine its execution in more detail.

默认情况下,正在调试的程序中的源文件名和非 ASCII 字符串使用默认编码系统进行解码。如果您喜欢不同的解码,可能是因为正在调试的程序使用不同的字符编码,请将变量设置 gdb-mi-decode-strings为适当的编码系统,或者将 nil非 ASCII 字符保留为未解码的八进制转义符。

By default, source file names and non-ASCII strings in the program being debugged are decoded using the default coding-system. If you prefer a different decoding, perhaps because the program being debugged uses a different character encoding, set the variable gdb-mi-decode-strings to the appropriate coding-system, or to nil to leave non-ASCII characters as undecoded octal escapes.


28.6.5.3 断点缓冲区

28.6.5.3 Breakpoints Buffer

GDB 断点缓冲区显示调试器会话中的断点、观察点和捕获点。请参阅GNU 调试器中的断点。它提供了以下命令,主要适用于当前断点(该点所在的断点):

The GDB Breakpoints buffer shows the breakpoints, watchpoints and catchpoints in the debugger session. See Breakpoints in The GNU debugger. It provides the following commands, which mostly apply to the current breakpoint (the breakpoint which point is on):

SPC
SPC

启用/禁用当前断点 ( gdb-toggle-breakpoint)。在图形显示上,这会更改该行源缓冲区边缘中点的颜色。当断点启用时,该点为红色;当断点禁用时,该点为灰色。

Enable/disable current breakpoint (gdb-toggle-breakpoint). On a graphical display, this changes the color of the dot in the fringe of the source buffer at that line. The dot is red when the breakpoint is enabled, and gray when it is disabled.

D
D

删除当前断点 ( gdb-delete-breakpoint)。

Delete the current breakpoint (gdb-delete-breakpoint).

RET
RET

访问当前断点 ( gdb-goto-breakpoint) 的源代码行。

Visit the source line for the current breakpoint (gdb-goto-breakpoint).

mouse-2
mouse-2

访问您单击的断点 ( gdb-goto-breakpoint) 的源代码行。

Visit the source line for the breakpoint you click on (gdb-goto-breakpoint).

gdb-many-windows为非时nil,GDB 断点缓冲区与 GDB 线程缓冲区共享其窗口。要从一种切换到另一种,请单击mouse-1标题行中的相关按钮。如果gdb-show-threads-by-default为 non- nil,则 GDB 线程缓冲区是默认显示的缓冲区。

When gdb-many-windows is non-nil, the GDB Breakpoints buffer shares its window with the GDB Threads buffer. To switch from one to the other click with mouse-1 on the relevant button in the header line. If gdb-show-threads-by-default is non-nil, the GDB Threads buffer is the one shown by default.


28.6.5.4 线程缓冲区

28.6.5.4 Threads Buffer

GDB 线程缓冲区显示被调试程序中线程的摘要。请参阅GNU 调试器中的调试具有多个线程的程序。要选择线程,请将点移至此处并按( ),或使用 单击它。这还会显示关联的源缓冲区,并更新其他 GDB 缓冲区的内容。 RETgdb-select-threadmouse-2

The GDB Threads buffer displays a summary of the threads in the debugged program. See Debugging programs with multiple threads in The GNU debugger. To select a thread, move point there and press RET (gdb-select-thread), or click on it with mouse-2. This also displays the associated source buffer, and updates the contents of the other GDB buffers.

您可以自定义gdb-buffers组中的变量以选择 GDB 线程缓冲区中包含的字段。

You can customize variables in the gdb-buffers group to select fields included in GDB Threads buffer.

gdb-thread-buffer-verbose-names
gdb-thread-buffer-verbose-names

显示长线程名称,例如 '线程 0x4e2ab70 (LWP 1983)'。

Show long thread names like ‘Thread 0x4e2ab70 (LWP 1983)’.

gdb-thread-buffer-arguments
gdb-thread-buffer-arguments

显示线程顶部框架的参数。

Show arguments of thread top frames.

gdb-thread-buffer-locations
gdb-thread-buffer-locations

显示文件信息或库名称。

Show file information or library names.

gdb-thread-buffer-addresses
gdb-thread-buffer-addresses

显示线程缓冲区中线程帧的地址。

Show addresses for thread frames in threads buffer.

要同时查看多个线程的信息,请从 GDB 线程缓冲区使用以下命令。

To view information for several threads simultaneously, use the following commands from the GDB Threads buffer.

d
d

显示当前行 ( ) 处线程的反汇编缓冲区gdb-display-disassembly-for-thread

Display disassembly buffer for the thread at current line (gdb-display-disassembly-for-thread).

f
f

显示当前行 ( ) 处线程的 GDB 堆栈缓冲区gdb-display-stack-for-thread

Display the GDB Stack buffer for the thread at current line (gdb-display-stack-for-thread).

l
l

显示当前行 ( ) 处线程的 GDB 本地缓冲区gdb-display-locals-for-thread

Display the GDB Locals buffer for the thread at current line (gdb-display-locals-for-thread).

r
r

显示当前行 ( ) 处线程的 GDB 寄存器缓冲区gdb-display-registers-for-thread

Display the GDB Registers buffer for the thread at current line (gdb-display-registers-for-thread).

它们的大写字母 、、D和,在新帧中显示相应的缓冲区。 FLR

Their upper-case counterparts, D, F ,L and R, display the corresponding buffer in a new frame.

当您创建一个显示有关某个特定线程的信息的缓冲区时,它会绑定到该线程,并在您调试程序时不断显示实际信息。每个 GDB 缓冲区的模式指示器显示该缓冲区显示其信息的线程数。线程号也包含在每个绑定缓冲区的名称中。

When you create a buffer showing information about some specific thread, it becomes bound to that thread and keeps showing actual information while you debug your program. The mode indicator for each GDB buffer shows the number of the thread whose information that buffer displays. The thread number is also included in the name of each bound buffer.

GDB 线程缓冲区中提供了更多命令,这些命令取决于用于控制程序执行的 GDB 模式。请参阅多线程调试

Further commands are available in the GDB Threads buffer which depend on the mode of GDB that is used for controlling execution of your program. See Multithreaded Debugging.


28.6.5.5 堆栈缓冲区

28.6.5.5 Stack Buffer

GDB 堆栈缓冲区显示一个调用堆栈,其中一行用于调试器会话中的每个嵌套子例程调用(堆栈帧)。请参阅GNU 调试器中的回溯

The GDB Stack buffer displays a call stack, with one line for each of the nested subroutine calls (stack frames) in the debugger session. See Backtraces in The GNU debugger.

在图形显示上,选定的堆栈帧由边缘中的箭头指示。在文本终端上,或者当禁用边缘时,所选堆栈帧将以相反的对比度显示。要选择堆栈框架,请移动其行中的点并键入RET ( gdb-frames-select),或单击mouse-2它。这样做还会更新本地缓冲区(请参阅其他 GDB 缓冲区)。

On graphical displays, the selected stack frame is indicated by an arrow in the fringe. On text terminals, or when fringes are disabled, the selected stack frame is displayed in reverse contrast. To select a stack frame, move point in its line and type RET (gdb-frames-select), or click mouse-2 on it. Doing so also updates the Locals buffer (see Other GDB Buffers).

如果您希望每个堆栈帧都显示帧地址,请将变量自定义gdb-stack-buffer-addresses为非值nil

If you want the frame address to be shown each stack frame, customize the variable gdb-stack-buffer-addresses to a non-nil value.


28.6.5.6 其他 GDB 缓冲区

28.6.5.6 Other GDB Buffers

M-x gdb您可以选择请求显示器 提供的其他缓冲区包括:

Other buffers provided by M-x gdb whose display you can optionally request include:

当地人缓冲区
Locals Buffer

此缓冲区显示简单数据类型的当前堆栈帧的局部变量的值(请参阅GNU 调试器中的有关帧的信息)。如果您想编辑该值, 请按或单击该值。RETmouse-2

数组和结构体仅显示其类型。使用 GDB 6.4 或更高版本,您可以通过键入RET或单击来检查此时局部变量的值 mouse-2。对于早期版本的 GDB,请在类型描述上使用RET或('mouse-2[结构/联合]' 或者 '[大批]')。请参阅观察表达式

要显示本地缓冲区,请键入M-x gdb-display-locals-buffer

This buffer displays the values of local variables of the current stack frame for simple data types (see Information on a frame in The GNU debugger). Press RET or click mouse-2 on the value if you want to edit it.

Arrays and structures display their type only. With GDB 6.4 or later, you can examine the value of the local variable at point by typing RET, or with a mouse-2 click. With earlier versions of GDB, use RET or mouse-2 on the type description (‘[struct/union]’ or ‘[array]’). See Watch Expressions.

To display the Locals buffer, type M-x gdb-display-locals-buffer.

输入/输出缓冲器
I/O Buffer

如果您正在调试的程序使用标准输入和输出流与用户交互,或者向其标准输出发出大量输出,您可能希望将其 I/O 与与 GDB 的交互分开。使用该命令显示一个带有缓冲区的窗口,Emacs 将您正在调试的程序的输入和输出重定向到该缓冲区。 M-x gdb-display-io-buffer

If the program you are debugging uses standard input and output streams for interaction with the user, or emits a significant amount of output to its standard output, you may wish to separate its I/O from interaction with GDB. Use the command M-x gdb-display-io-buffer to show a window with a buffer to which Emacs redirects the input and output from the program you are debugging.

寄存器缓冲区
Registers Buffer

该缓冲区显示寄存器保存的值(请参阅GNU 调试器中的寄存器)。使用命令请求显示该缓冲区。如果您想编辑其值,请按或单击寄存器。对于 GDB 6.4 或更高版本,最近更改的寄存器值显示为。 M-x gdb-display-registers-bufferRETmouse-2font-lock-warning-face

This buffer displays the values held by the registers (see Registers in The GNU debugger). Request the display of this buffer with the command M-x gdb-display-registers-buffer. Press RET or click mouse-2 on a register if you want to edit its value. With GDB 6.4 or later, recently changed register values display with font-lock-warning-face.

汇编缓冲区
Assembler Buffer

汇编器缓冲区将当前帧显示为机器代码。箭头指向当前指令,您可以像在源缓冲区中一样设置和删除断点。断点图标也会出现在边缘或页边距中。要请求显示此缓冲区,请使用 M-x gdb-display-disassembly-buffer

The assembler buffer displays the current frame as machine code. An arrow points to the current instruction, and you can set and remove breakpoints as in a source buffer. Breakpoint icons also appear in the fringe or margin. To request the display of this buffer, use M-x gdb-display-disassembly-buffer.

内存缓冲区
Memory Buffer

内存缓冲区允许您检查程序内存的各个部分(请参阅GNU 调试器中的检​​查内存)。单击标题行的相应部分可更改缓冲区显示的起始地址或数据项数。或者,分别使用或。单击 标题行可以选择这些数据项的显示格式或单位大小。用于请求显示该缓冲区。 mouse-1SNmouse-3M-x gdb-display-memory-buffer

The memory buffer lets you examine sections of program memory (see Examining memory in The GNU debugger). Click mouse-1 on the appropriate part of the header line to change the starting address or number of data items that the buffer displays. Alternatively, use S or N respectively. Click mouse-3 on the header line to select the display format or unit size for these data items. Use M-x gdb-display-memory-buffer to request display of this buffer.

gdb-many-windows为非时nil,本地缓冲区与寄存器缓冲区共享其窗口,就像断点和线程缓冲区一样。要从一种切换到另一种,请单击 mouse-1标题行中的相关按钮。

When gdb-many-windows is non-nil, the locals buffer shares its window with the registers buffer, just like breakpoints and threads buffers. To switch from one to the other, click with mouse-1 on the relevant button in the header line.


28.6.5.7 观察表达式

28.6.5.7 Watch Expressions

如果您想查看每次程序停止时变量如何变化,请将点移至变量名称中,然后单击工具栏中的监视图标 ( gud-watch) 或键入C-x C-a C-w。如果指定前缀参数,则可以在微型缓冲区中输入变量名称。

If you want to see how a variable changes each time your program stops, move point into the variable name and click on the watch icon in the tool bar (gud-watch) or type C-x C-a C-w. If you specify a prefix argument, you can enter the variable name in the minibuffer.

每个监视表达式都显示在速度栏中(请参阅速度栏框架)。复杂的数据类型,例如数组、结构和联合,以树格式表示。叶子和简单数据类型显示表达式的名称及其值,并且当选择速度栏框架时,将类型显示为工具提示。较高级别显示指针的名称、类型和地址值,否则仅显示名称和类型。根表达式还将帧地址显示为工具提示,以帮助识别定义它们的帧。

Each watch expression is displayed in the speedbar (see Speedbar Frames). Complex data types, such as arrays, structures and unions are represented in a tree format. Leaves and simple data types show the name of the expression and its value and, when the speedbar frame is selected, display the type as a tooltip. Higher levels show the name, type and address value for pointers and just the name and type otherwise. Root expressions also display the frame address as a tooltip to help identify the frame in which they were defined.

要扩展或收缩复杂数据类型,请单击mouse-2SPC按表达式左侧的标签。如果表达式的直接子级数超过变量的值gdb-max-children, Emacs 会在扩展​​表达式之前要求确认。

To expand or contract a complex data type, click mouse-2 or press SPC on the tag to the left of the expression. Emacs asks for confirmation before expanding the expression if its number of immediate children exceeds the value of the variable gdb-max-children.

要删除复杂的监视表达式,请将点移至速度栏中的根表达式并键入D( gdb-var-delete)。

To delete a complex watch expression, move point to the root expression in the speedbar and type D (gdb-var-delete).

要编辑具有简单数据类型的变量或复杂数据类型的简单元素,请将点移至速度栏中并键入RET ( gdb-edit-value)。或者您可以单击mouse-2一个值进行编辑。无论哪种方式,这都会使用迷你缓冲区读取新值。

To edit a variable with a simple data type, or a simple element of a complex data type, move point there in the speedbar and type RET (gdb-edit-value). Or you can click mouse-2 on a value to edit it. Either way, this reads the new value using the minibuffer.

如果将变量设置gdb-show-changed-values为非nil(默认值),Emacs 将突出 font-lock-warning-face显示最近更改的值,并shadow让超出范围的变量不那么明显。当变量超出范围时,您无法编辑其值。

If you set the variable gdb-show-changed-values to non-nil (the default value), Emacs uses font-lock-warning-face to highlight values that have recently changed and shadow face to make variables which have gone out of scope less noticeable. When a variable goes out of scope you can’t edit its value.

如果变量gdb-delete-out-of-scope是非nil (默认值),Emacs 会自动删除超出范围的监视表达式。有时,当您的程序多次重新进入同一函数时,将此值设置为 可能很有用, nil这样您就不需要重新创建监视表达式。

If the variable gdb-delete-out-of-scope is non-nil (the default value), Emacs automatically deletes watch expressions which go out of scope. Sometimes, when your program re-enters the same function many times, it may be useful to set this value to nil so that you don’t need to recreate the watch expression.

如果变量gdb-use-colon-colon-notation不是 - nil,Emacs 使用 '函数::变量' 格式。这允许用户显示共享相同变量名的监视表达式。默认值为nil

If the variable gdb-use-colon-colon-notation is non-nil, Emacs uses the ‘function::variable’ format. This allows the user to display watch expressions which share the same variable name. The default value is nil.

要在每次监视表达式显示更新时自动升高速度栏,请设置gdb-speedbar-auto-raise为非nil。如果您使用全屏 Emacs 框架进行调试,这会很有用。

To automatically raise the speedbar every time the display of watch expressions updates, set gdb-speedbar-auto-raise to non-nil. This can be useful if you are debugging with a full screen Emacs frame.


28.6.5.8 多线程调试

28.6.5.8 Multithreaded Debugging

在GDB的全停止模式下,每当你的程序停止时,所有执行线程都会停止。同样,每当您重新启动程序时,所有线程都会开始执行。请参阅GNU 调试器中的全停止模式。对于某些多线程目标,GDB 支持另一种操作模式,称为不间断模式,在这种模式下,您可以在调试器中检查停止的程序线程,而其他线程继续自由执行。请参阅GNU 调试器中的不间断模式。 7.0 之前的 GDB 版本不支持不间断模式,并且它不适用于所有目标。

In GDB’s all-stop mode, whenever your program stops, all execution threads stop. Likewise, whenever you restart the program, all threads start executing. See All-Stop Mode in The GNU debugger. For some multi-threaded targets, GDB supports a further mode of operation, called non-stop mode, in which you can examine stopped program threads in the debugger while other threads continue to execute freely. See Non-Stop Mode in The GNU debugger. Versions of GDB prior to 7.0 do not support non-stop mode, and it does not work on all targets.

该变量gdb-non-stop-setting决定 Emacs 是以全停止模式还是非停止模式运行 GDB。默认值为t,这意味着它会尝试使用不间断模式(如果可用)。如果将该值更改为nil,或者不间断模式不可用,Emacs 将在全停止模式下运行 GDB。该变量在 Emacs 开始调试会话时生效;如果更改其值,则应重新启动任何活动的调试会话。

The variable gdb-non-stop-setting determines whether Emacs runs GDB in all-stop mode or non-stop mode. The default is t, which means it tries to use non-stop mode if that is available. If you change the value to nil, or if non-stop mode is unavailable, Emacs runs GDB in all-stop mode. The variable takes effect when Emacs begins a debugging session; if you change its value, you should restart any active debugging session.

当线程以不间断模式停止时,Emacs 通常会切换到该线程。如果您不希望 Emacs 在已选择另一个停止的线程的情况下执行此切换,请将变量更改 gdb-switch-when-another-stoppednil

When a thread stops in non-stop mode, Emacs usually switches to that thread. If you don’t want Emacs to do this switch if another stopped thread is already selected, change the variable gdb-switch-when-another-stopped to nil.

Emacs 可以根据导致停止的原因决定是否切换到停止的线程。自定义变量 gdb-switch-reasons来选择导致线程切换的停止原因。

Emacs can decide whether or not to switch to the stopped thread depending on the reason which caused the stop. Customize the variable gdb-switch-reasons to select the stop reasons which will cause a thread switch.

该变量gdb-stopped-functions允许您在某个线程停止时执行您的函数。

The variable gdb-stopped-functions allows you to execute your functions whenever some thread stops.

在不停机模式下,可以切换不同的模式来执行GUD控制命令。

In non-stop mode, you can switch between different modes for GUD execution control commands.

不间断/A
Non-stop/A

gdb-gud-control-all-threads为(默认值)时,中断和继续命令适用于所有线程,因此您可以分别使用和,t通过一个命令停止或继续所有线程 。这 'gud-stop-subjobgud-cont当至少一个线程停止时,工具栏上会显示 ' 按钮,而 '停止' 按钮在至少一个线程正在运行时显示。

When gdb-gud-control-all-threads is t (the default value), interruption and continuation commands apply to all threads, so you can halt or continue all your threads with one command using gud-stop-subjob and gud-cont, respectively. The ‘Go’ button is shown on the tool bar when at least one thread is stopped, whereas ‘Stop’ button is shown when at least one thread is running.

直达/T
Non-stop/T

gdb-gud-control-all-threadsis时nil,仅停止/继续当前线程。 '' 和 '停止GUD 工具栏上的按钮根据当前线程的状态显示。

When gdb-gud-control-all-threads is nil, only the current thread is stopped/continued. ‘Go’ and ‘Stop’ buttons on the GUD tool bar are shown depending on the state of current thread.

gdb-gud-control-all-threads 您可以从工具栏或从 '更改当前值GUD->GDB-MI' 菜单。

You can change the current value of gdb-gud-control-all-threads from the tool bar or from ‘GUD->GDB-MI’ menu.

步进命令始终适用于当前线程。

Stepping commands always apply to the current thread.

在不间断模式下,您可以中断/继续线程而不选择它们。i命中线程缓冲区会中断点下的线程,继续c执行,s逐步执行。将来可能会添加更多此类命令。

In non-stop mode, you can interrupt/continue your threads without selecting them. Hitting i in threads buffer interrupts thread under point, c continues it, s steps through. More such commands may be added in the future.

请注意,当您中断线程时,它会以 ' 停止收到信号' 原因。如果该原因包含在您的线程中 gdb-switch-reasons(默认情况下),Emacs 将切换到该线程。

Note that when you interrupt a thread, it stops with the ‘signal received’ reason. If that reason is included in your gdb-switch-reasons (it is by default), Emacs will switch to that thread.


28.7 执行Lisp表达式

28.7 Executing Lisp Expressions

Emacs 具有适用于多种 Lisp 变体的主要模式。它们使用与其他编程语言模式相同的编辑命令(请参阅编辑程序)。此外,它们还提供用于执行 Lisp 表达式的特殊命令。

Emacs has major modes for several variants of Lisp. They use the same editing commands as other programming language modes (see Editing Programs). In addition, they provide special commands for executing Lisp expressions.

Emacs Lisp 模式
Emacs Lisp mode

编辑 Emacs Lisp 源文件的模式。它定义C-M-x 评估当前顶级 Lisp 表达式。请参阅评估 Emacs Lisp 表达式

The mode for editing Emacs Lisp source files. It defines C-M-x to evaluate the current top-level Lisp expression. See Evaluating Emacs Lisp Expressions.

Lisp交互模式
Lisp Interaction mode

交互式 Emacs Lisp 会话的模式。它定义C-j 计算 point 之前的表达式并将其值插入缓冲区。请参阅Lisp 交互缓冲区

The mode for an interactive Emacs Lisp session. It defines C-j to evaluate the expression before point and insert its value in the buffer. See Lisp Interaction Buffers.

口齿不清模式
Lisp mode

用于编辑在除 Emacs Lisp 之外的 Lisp 中运行的程序的源文件的模式。它定义C-M-x评估外部 Lisp 中的当前顶级表达式。请参阅运行外部 Lisp

The mode for editing source files of programs that run in Lisps other than Emacs Lisp. It defines C-M-x to evaluate the current top-level expression in an external Lisp. See Running an External Lisp.

劣质 Lisp 模式
Inferior Lisp mode

与外部 Lisp 进行交互会话的模式,该外部 Lisp 作为Emacs 的子进程(或下级进程)运行。请参阅运行外部 Lisp

The mode for an interactive session with an external Lisp which is being run as a subprocess (or inferior process) of Emacs. See Running an External Lisp.

方案模式
Scheme mode

与 Lisp 模式类似,但适用于Scheme 程序。

Like Lisp mode, but for Scheme programs.

劣方案模式
Inferior Scheme mode

与 Inferior Lisp 模式类似,但针对的是 Scheme。

Like Inferior Lisp mode, but for Scheme.


28.8 Emacs 的 Lisp 代码库

28.8 Libraries of Lisp Code for Emacs

Emacs Lisp 代码存储在名称通常以以下结尾的文件中 .el。在 Emacs Lisp 模式下会自动访问此类文件。

Emacs Lisp code is stored in files whose names conventionally end in .el. Such files are automatically visited in Emacs Lisp mode.

Emacs Lisp 代码可以编译为字节码,加载速度更快,占用空间更少,执行速度更快。按照惯例,编译后的 Emacs Lisp 代码会放在一个单独的文件中,该文件的名称以 ' 结尾.elc'。例如,编译后的代码为foo.el进去 foo.elc。请参阅Emacs Lisp 参考手册中的字节编译

Emacs Lisp code can be compiled into byte-code, which loads faster, takes up less space, and executes faster. By convention, compiled Emacs Lisp code goes in a separate file whose name ends in ‘.elc’. For example, the compiled code for foo.el goes in foo.elc. See Byte Compilation in the Emacs Lisp Reference Manual.

Emacs Lisp 代码也可以编译为本机代码:机器代码与 C 或 Fortran 编译器生成的机器代码没有什么不同。本机代码的运行速度甚至比字节码还要快。本机编译的 Emacs Lisp 代码存储在名称以 ' 结尾的文件中.eln'。请参阅Emacs Lisp 参考手册中的本机编译

Emacs Lisp code can also be compiled into native code: machine code not unlike the one produced by a C or Fortran compiler. Native code runs even faster than byte-code. Natively-compiled Emacs Lisp code is stored in files whose names end in ‘.eln’. See Native Compilation in the Emacs Lisp Reference Manual.

加载Emacs Lisp 文件,请键入M-x load-file.此命令使用迷你缓冲区读取文件名,并将该文件的内容作为 Emacs Lisp 代码执行。不必先访问该文件;该命令直接从磁盘读取文件,而不是从现有的 Emacs 缓冲区中读取。

To load an Emacs Lisp file, type M-x load-file. This command reads a file name using the minibuffer, and executes the contents of that file as Emacs Lisp code. It is not necessary to visit the file first; this command reads the file directly from disk, not from an existing Emacs buffer.

如果 Emacs Lisp 文件安装在 Emacs Lisp加载路径 (定义如下)中,您可以通过键入 来加载它M-x load-library,而不是使用M-x load-file。该M-x load-library 命令提示输入库名称而不是文件名;它会搜索 Emacs Lisp 加载路径中的每个目录,尝试找到与该库名称匹配的文件。如果库名称是 '',它尝试查找名为的文件 foo.elc,foo.el, 和。 (如果 Emacs 是在启用本机编译的情况下构建的,load-library 则查找 '.eln' 对应的文件foo.el 并加载它而不是foo.elc.) 默认行为是加载找到的第一个文件。该命令更喜欢.eln 文件结束.elc文件,并且更喜欢.elc文件结束 .el文件,因为编译后的文件加载和运行速度更快。如果发现.el.elc,如果有人更改了,它会发出警告.el文件并忘记重新编译它,但加载了.elc无论如何都要归档。 (由于这种行为,您可以将未完成的编辑保存到 Emacs Lisp 源文件中,并且在您的更改可供使用之前不重新编译。)但是,如果您将该选项设置load-prefer-newer为非值nil ,则不需要执行上述过程, Emacs 加载该文件的最新版本。如果 Emacs 是用原生编译构建的,它找不到 '.eln' 对应的文件.el,它将加载一个 .elc并开始本地编译 .el在后台,然后加载 '.eln' 完成编译后的文件。

If an Emacs Lisp file is installed in the Emacs Lisp load path (defined below), you can load it by typing M-x load-library, instead of using M-x load-file. The M-x load-library command prompts for a library name rather than a file name; it searches through each directory in the Emacs Lisp load path, trying to find a file matching that library name. If the library name is ‘foo’, it tries looking for files named foo.elc, foo.el, and foo. (If Emacs was built with native compilation enabled, load-library looks for a ‘.eln’ file that corresponds to foo.el and loads it instead of foo.elc.) The default behavior is to load the first file found. This command prefers .eln files over .elc files, and prefers .elc files over .el files, because compiled files load and run faster. If it finds that lib.el is newer than lib.elc, it issues a warning, in case someone made changes to the .el file and forgot to recompile it, but loads the .elc file anyway. (Due to this behavior, you can save unfinished edits to Emacs Lisp source files, and not recompile until your changes are ready for use.) If you set the option load-prefer-newer to a non-nil value, however, then rather than the procedure described above, Emacs loads whichever version of the file is newest. If Emacs was built with native compilation, and it cannot find the ‘.eln’ file corresponding to lib.el, it will load a lib.elc and start native compilation of lib.el in the background, then load the ‘.eln’ file when it finishes compilation.

Emacs Lisp 程序通常使用该 load函数加载 Emacs Lisp 文件。这与 类似load-library,但级别较低并且接受额外的参数。请参阅Emacs Lisp 参考手册中的程序如何加载

Emacs Lisp programs usually load Emacs Lisp files using the load function. This is similar to load-library, but is lower-level and accepts additional arguments. See How Programs Do Loading in the Emacs Lisp Reference Manual.

Emacs Lisp 加载路径由变量 指定 load-path。它的值应该是目录列表(字符串)。这些目录将按指定的顺序由M-x load-library命令、较低级别的load 函数以及查找 Emacs Lisp 库的其他 Emacs 函数进行搜索。中的条目load-path也可以具有特殊值 ,它代表当前默认目录,但使用它几乎总是一个坏主意,因为它的含义将取决于Emacs 使用nil时当前的缓冲区。 load-path(如果您发现自己希望将其nil包含在列表中,那么很可能您真正想要的是使用M-x load-file。)

The Emacs Lisp load path is specified by the variable load-path. Its value should be a list of directories (strings). These directories are searched, in the specified order, by the M-x load-library command, the lower-level load function, and other Emacs functions that find Emacs Lisp libraries. An entry in load-path can also have the special value nil, which stands for the current default directory, but it is almost always a bad idea to use this, because its meaning will depend on the buffer that is current when load-path is used by Emacs. (If you find yourself wishing that nil were in the list, most likely what you really want is to use M-x load-file.)

的默认值load-path是存储 Emacs 本身的 Lisp 代码的目录列表。如果您在另一个目录中有自己的库,则可以将该目录添加到加载路径。与本手册中描述的大多数其他变量不同, load-path无法通过自定义界面进行更改(请参阅轻松自定义界面),但您可以通过在 init 文件中添加如下行来向其添加目录(请参阅Emacs 初始化文件):

The default value of load-path is a list of directories where the Lisp code for Emacs itself is stored. If you have libraries of your own in another directory, you can add that directory to the load path. Unlike most other variables described in this manual, load-path cannot be changed via the Customize interface (see Easy Customization Interface), but you can add a directory to it by putting a line like this in your init file (see The Emacs Initialization File):

(添加到列表'加载路径“/path/to/my/lisp/library”)
(add-to-list 'load-path "/path/to/my/lisp/library")

通常将本地安装的库放在 站点 Lisp已经在 的默认值中的目录 load-path,或者在 的某个子目录中站点 Lisp。这样,您就不需要修改 的默认值load-path

It is customary to put locally installed libraries in the site-lisp directory that is already in the default value of load-path, or in some subdirectory of site-lisp. This way, you don’t need to modify the default value of load-path.

与 类似load-path,Emacs 查找的目录列表*.eln包含本机编译的 Lisp 代码的文件由变量 指定native-comp-eln-load-path

Similarly to load-path, the list of directories where Emacs looks for *.eln files with natively-compiled Lisp code is specified by the variable native-comp-eln-load-path.

一些命令是自动加载的;当您运行它们时,Emacs 首先自动加载关联的库。例如, M-x compile命令(请参阅Emacs 下的运行编译)是自动加载的;如果您调用它,Emacscompile首先会自动加载该库。相反,该命令M-x recompile不会自动加载,因此在加载compile库之前它不可用。

Some commands are autoloaded; when you run them, Emacs automatically loads the associated library first. For instance, the M-x compile command (see Running Compilations under Emacs) is autoloaded; if you call it, Emacs automatically loads the compile library first. In contrast, the command M-x recompile is not autoloaded, so it is unavailable until you load the compile library.

当您查找自动加载命令的文档时(请参阅命令或变量名帮助),如果文档引用其库中的其他函数和变量(加载库可以让 Emacs 正确设置超链接),自动加载也可能发生。*帮助* 缓冲)。要禁用此功能,请将变量更改 help-enable-autoloadnil

Automatic loading can also occur when you look up the documentation of an autoloaded command (see Help by Command or Variable Name), if the documentation refers to other functions and variables in its library (loading the library lets Emacs properly set up the hyperlinks in the *Help* buffer). To disable this feature, change the variable help-enable-autoload to nil.

根据正在完成的前缀,完成describe-variable和 的名称时也会发生自动加载 。describe-function要禁用此功能,请将变量更改 help-enable-completion-autoloadnil

Automatic loading also occurs when completing names for describe-variable and describe-function, based on the prefix being completed. To disable this feature, change the variable help-enable-completion-autoload to nil.

将库放入 Emacs 可以找到并加载它的目录后,您可能希望使其在启动时可用。当库定义了应按需自动可用的功能并且手动加载库不方便时,这非常有用。在这些情况下,请确保通过向 init 文件添加合适的形式来加载库:或者loadrequire如果您总是需要在启动时加载库),或者 autoload如果您需要 Emacs 在某些命令或函数被执行时加载库。调用。例如:

Once you put your library in a directory where Emacs can find and load it, you may wish to make it available at startup. This is useful when the library defines features that should be available automatically on demand, and manually loading the library is thus inconvenient. In these cases, make sure the library will be loaded by adding suitable forms to your init file: either load or require (if you always need to load the library at startup), or autoload if you need Emacs to load the library when some command or function is invoked. For example:

;;负载我的闪亮包.elc无条件地。
 (需要“我的闪亮包”)
 ;; Loads my-shining-package.elc unconditionally.
 (require 'my-shining-package)
;;将加载我的闪亮包.elc何时my-func被调用。
 (自动加载'my-func“my-shining-package”)
 ;; Will load my-shining-package.elc when my-func is invoked.
 (autoload 'my-func "my-shining-package")

请注意,使用package-install (请参阅包安装)安装包会负责将包的 Lisp 文件放置在 Emacs 可以找到它的目录中,并将必要的初始化代码写入 init 文件中,从而无需进行上述手动自定义。

Note that installing a package using package-install (see Package Installation) takes care of placing the package’s Lisp files in a directory where Emacs will find it, and also writes the necessary initialization code into your init files, making the above manual customizations unnecessary.


28.9 评估 Emacs Lisp 表达式

28.9 Evaluating Emacs Lisp Expressions

Emacs Lisp 模式是编辑 Emacs Lisp 的主要模式。其模式命令为M-x emacs-lisp-mode.

Emacs Lisp mode is the major mode for editing Emacs Lisp. Its mode command is M-x emacs-lisp-mode.

Emacs 提供了几个用于计算 Emacs Lisp 表达式的命令。您可以在 Emacs Lisp 模式下使用这些命令来测试正在编写的 Emacs Lisp 代码。例如,重写函数后,可以对函数定义进行求值,使其对后续函数调用生效。这些命令也是全局可用的,并且可以在 Emacs Lisp 模式之外使用。

Emacs provides several commands for evaluating Emacs Lisp expressions. You can use these commands in Emacs Lisp mode, to test your Emacs Lisp code as it is being written. For example, after re-writing a function, you can evaluate the function definition to make it take effect for subsequent function calls. These commands are also available globally, and can be used outside Emacs Lisp mode.

M-:
M-:

读取迷你缓冲区中的单个 Emacs Lisp 表达式,对其求值,然后在回显区域 ( eval-expression) 中打印该值。

Read a single Emacs Lisp expression in the minibuffer, evaluate it, and print the value in the echo area (eval-expression).

C-x C-e
C-x C-e

计算 point 之前的 Emacs Lisp 表达式,并在回显区域 ( eval-last-sexp) 中打印该值。

Evaluate the Emacs Lisp expression before point, and print the value in the echo area (eval-last-sexp).

C-M-x (在 Emacs Lisp 模式下)
C-M-x (in Emacs Lisp mode)
M-x eval-defun
M-x eval-defun

评估包含或之后的 defun 点,并在回显区域 ( eval-defun) 中打印该值。

Evaluate the defun containing or after point, and print the value in the echo area (eval-defun).

M-x eval-region
M-x eval-region

评估该区域中的所有 Emacs Lisp 表达式。

Evaluate all the Emacs Lisp expressions in the region.

M-x eval-buffer
M-x eval-buffer

计算缓冲区中的所有 Emacs Lisp 表达式。

Evaluate all the Emacs Lisp expressions in the buffer.

M-:( eval-expression) 使用迷你缓冲区读取表达式并对其求值。 (在计算表达式之前,当前缓冲区会切换回您键入 时的当前缓冲区M-:,而不是您在其中键入表达式的迷你缓冲区。)

M-: (eval-expression) reads an expression using the minibuffer, and evaluates it. (Before evaluating the expression, the current buffer switches back to the buffer that was current when you typed M-:, not the minibuffer into which you typed the expression.)

命令C-x C-e( eval-last-sexp) 计算缓冲区中前一点的 Emacs Lisp 表达式,并将该值显示在回显区域中。当评估结果是整数时,它与其他格式的值(八进制、十六进制和字符 eval-expression-print-maximum-character,如果允许的话,如下所述)一起显示。

The command C-x C-e (eval-last-sexp) evaluates the Emacs Lisp expression preceding point in the buffer, and displays the value in the echo area. When the result of an evaluation is an integer, it is displayed together with the value in other formats (octal, hexadecimal, and character if eval-expression-print-maximum-character, described below, allows it).

如果给M-:C-x C-e一个前缀参数,它会将值插入当前缓冲区中的点,而不是将其显示在回显区域中。如果前缀参数为零,则任何整数输出都会与其其他格式(八进制、十六进制和字符)的值一起插入。这样的前缀参数还可以防止根据变量eval-expression-print-level和 来缩写输出 eval-expression-print-length(见下文)。类似地, 的前缀参数-1会覆盖 的效果 eval-expression-print-length

If M-: or C-x C-e is given a prefix argument, it inserts the value into the current buffer at point, rather than displaying it in the echo area. If the prefix argument is zero, any integer output is inserted together with its value in other formats (octal, hexadecimal, and character). Such a prefix argument also prevents abbreviation of the output according to the variables eval-expression-print-level and eval-expression-print-length (see below). Similarly, a prefix argument of -1 overrides the effect of eval-expression-print-length.

C-x C-e( eval-last-sexp) 对defvar 表达式进行特殊处理。通常,defvar 如果表达式定义的变量已经有值,则计算表达式不会执行任何操作。但该命令无条件地将变量重置为defvar;指定的初始值。这对于调试 Emacs Lisp 程序很方便。 defcustomdefface 表达式的处理方式类似。请注意,本节中记录的其他命令(除了eval-defun)没有此特殊功能。

C-x C-e (eval-last-sexp) treats defvar expressions specially. Normally, evaluating a defvar expression does nothing if the variable it defines already has a value. But this command unconditionally resets the variable to the initial value specified by the defvar; this is convenient for debugging Emacs Lisp programs. defcustom and defface expressions are treated similarly. Note the other commands documented in this section, except eval-defun, do not have this special feature.

eval-defun命令绑定到C-M-xEmacs Lisp 模式。它计算包含或跟随点的顶级 Lisp 表达式,并在回显区域中打印该值。在这种情况下,顶级表达式被称为“defun”,但它不必是实际的defun(函数定义)。

The eval-defun command is bound to C-M-x in Emacs Lisp mode. It evaluates the top-level Lisp expression containing or following point, and prints the value in the echo area. In this context, a top-level expression is referred to as a “defun”, but it need not be an actual defun (function definition).

该命令以与 //defvar相同 的方式处理表单。 defcustomdeffaceeval-last-sexp

This command handles defvar/defcustom/defface forms the same way that eval-last-sexp does.

使用前缀参数,C-M-x检测 Edebug(Emacs Lisp 调试器)的函数定义。请参阅Emacs Lisp 参考手册中的Edebug 检测

With a prefix argument, C-M-x instruments the function definition for Edebug, the Emacs Lisp Debugger. See Instrumenting for Edebug in the Emacs Lisp Reference Manual.

该命令M-x eval-region将该区域的文本解析为一个或多个 Lisp 表达式,并对其进行一一求值。 M-x eval-buffer类似,但评估整个缓冲区。

The command M-x eval-region parses the text of the region as one or more Lisp expressions, evaluating them one by one. M-x eval-buffer is similar but evaluates the entire buffer.

选项eval-expression-print-leveleval-expression-print-length控制在缩写之前要在评估命令的结果中打印的列表的最大深度和长度。向eval-expression或提供零前缀参数 eval-last-sexp会导致列表被完整打印。 eval-expression-debug-on-error控制使用这些命令时评估错误是否调用调试器;它的默认值是t. eval-expression-print-maximum-character防止大于它的整数显示为字符。

The options eval-expression-print-level and eval-expression-print-length control the maximum depth and length of lists to print in the result of the evaluation commands before abbreviating them. Supplying a zero prefix argument to eval-expression or eval-last-sexp causes lists to be printed in full. eval-expression-debug-on-error controls whether evaluation errors invoke the debugger when these commands are used; its default is t. eval-expression-print-maximum-character prevents integers which are larger than it from being displayed as characters.


28.10 Lisp交互缓冲区

28.10 Lisp Interaction Buffers

当 Emacs 启动时,它包含一个名为*划痕*,它是为交互式评估 Emacs Lisp 表达式而提供的。其主要模式是Lisp交互模式。您还可以通过键入 来启用 Lisp 交互模式M-x lisp-interaction-mode

When Emacs starts up, it contains a buffer named *scratch*, which is provided for evaluating Emacs Lisp expressions interactively. Its major mode is Lisp Interaction mode. You can also enable Lisp Interaction mode by typing M-x lisp-interaction-mode.

如果你杀了*划痕*缓冲区,您可以使用M-x scratch-buffer命令重新创建它。

If you kill the *scratch* buffer, you can recreate it with the M-x scratch-buffer command.

在里面*划痕*buffer 和其他 Lisp 交互模式缓冲区,C-j( eval-print-last-sexp) 计算 point 之前的 Lisp 表达式,并在 point 处插入值。因此,当您在缓冲区中键入表达式并在C-j每个表达式后键入表达式时,缓冲区会记录已计算表达式及其值的副本。 Lisp 交互模式中的所有其他命令与 Emacs Lisp 模式中的相同。

In the *scratch* buffer, and other Lisp Interaction mode buffers, C-j (eval-print-last-sexp) evaluates the Lisp expression before point, and inserts the value at point. Thus, as you type expressions into the buffer followed by C-j after each expression, the buffer records a transcript of the evaluated expressions and their values. All other commands in Lisp Interaction mode are the same as in Emacs Lisp mode.

启动时,*划痕*buffer 包含一条 Lisp 注释形式的短消息,解释了它的用途。该消息由变量 控制initial-scratch-message,该变量应该是文档字符串,或者nil(这意味着抑制该消息)。

At startup, the *scratch* buffer contains a short message, in the form of a Lisp comment, that explains what it is for. This message is controlled by the variable initial-scratch-message, which should be either a documentation string, or nil (which means to suppress the message).

交互式评估 Emacs Lisp 表达式的另一种方法是使用 Inferior Emacs Lisp 模式,该模式提供了一个类似于 Shell 模式(请参阅Shell 模式)的接口来评估 Emacs Lisp 表达式。键入M-x ielm以创建 *伊尔姆*使用此模式的缓冲区。有关更多信息,请参阅该命令的文档。

An alternative way of evaluating Emacs Lisp expressions interactively is to use Inferior Emacs Lisp mode, which provides an interface rather like Shell mode (see Shell Mode) for evaluating Emacs Lisp expressions. Type M-x ielm to create an *ielm* buffer which uses this mode. For more information, see that command’s documentation.


28.11 运行外部 Lisp

28.11 Running an External Lisp

Lisp 模式是编辑用通用 Lisp 方言(例如 Common Lisp)编写的程序的主要模式。其模式命令为M-x lisp-mode. Emacs 自动对名称结尾为的文件使用 Lisp 模式.l,.lsp, 或者.lisp

Lisp mode is the major mode for editing programs written in general-purpose Lisp dialects, such as Common Lisp. Its mode command is M-x lisp-mode. Emacs uses Lisp mode automatically for files whose names end in .l, .lsp, or .lisp.

您可以将外部 Lisp 会话作为 Emacs 的子进程或 下级进程运行,并将表达式传递给它进行计算。要开始外部 Lisp 会话,请输入M-x run-lisp。这将运行名为 的程序lisp,并对其进行设置,以便输入和输出都通过名为 的 Emacs 缓冲区 *下级口齿不清*。要更改运行的 Lisp 程序的名称 M-x run-lisp,请更改变量inferior-lisp-program

You can run an external Lisp session as a subprocess or inferior process of Emacs, and pass expressions to it to be evaluated. To begin an external Lisp session, type M-x run-lisp. This runs the program named lisp, and sets it up so that both input and output go through an Emacs buffer named *inferior-lisp*. To change the name of the Lisp program run by M-x run-lisp, change the variable inferior-lisp-program.

主要模式为*口齿不清*buffer 是 Inferior Lisp 模式,它结合了 Lisp 模式和 Shell 模式的特点(参见Shell 模式)。要将输入发送到 Lisp 会话,请转到*口齿不清*buffer 并键入输入,然后键入 RET. Lisp 会话的终端输出会自动插入到缓冲区中。

The major mode for the *lisp* buffer is Inferior Lisp mode, which combines the characteristics of Lisp mode and Shell mode (see Shell Mode). To send input to the Lisp session, go to the end of the *lisp* buffer and type the input, followed by RET. Terminal output from the Lisp session is automatically inserted in the buffer.

当您在 Lisp 模式下编辑 Lisp 程序时,您可以键入C-M-x ( lisp-eval-defun) 将表达式从 Lisp 模式缓冲区发送到您启动时使用的 Lisp 会话M-x run-lisp。发送的表达式是在该点或该点之后的顶级 Lisp 表达式。结果值照常进入 *下级口齿不清*缓冲。请注意,在 Lisp 模式下的效果C-M-x与在 Emacs Lisp 模式下的效果非常相似(请参阅评估 Emacs Lisp 表达式),只不过表达式被发送到不同的 Lisp 环境而不是在 Emacs 中进行评估。

When you edit a Lisp program in Lisp mode, you can type C-M-x (lisp-eval-defun) to send an expression from the Lisp mode buffer to a Lisp session that you had started with M-x run-lisp. The expression sent is the top-level Lisp expression at or following point. The resulting value goes as usual into the *inferior-lisp* buffer. Note that the effect of C-M-x in Lisp mode is thus very similar to its effect in Emacs Lisp mode (see Evaluating Emacs Lisp Expressions), except that the expression is sent to a different Lisp environment instead of being evaluated in Emacs.

编辑Scheme代码和将表达式发送到Scheme子进程的工具非常相似。方案源文件在方案模式下编辑,可以使用M-x scheme-mode.您可以通过键入来启动Scheme会话M-x run-scheme(与Scheme交互的缓冲区被命名为 *方案*),然后通过键入 向其发送表达式C-M-x

The facilities for editing Scheme code, and for sending expressions to a Scheme subprocess, are very similar. Scheme source files are edited in Scheme mode, which can be explicitly enabled with M-x scheme-mode. You can initiate a Scheme session by typing M-x run-scheme (the buffer for interacting with Scheme is named *scheme*), and send expressions to it by typing C-M-x.


29 维护大型程序

29 Maintaining Large Programs

本章介绍用于维护中型到大型程序和包的 Emacs 功能。这些功能包括:

This chapter describes Emacs features for maintaining medium- to large-size programs and packages. These features include:

  • 支持版本控制系统 ( VCS ) 的统一接口,记录源文件更改的历史记录。
  • Unified interface to Support for Version Control Systems (VCS) that record the history of changes to source files.
  • 用于处理编程项目的命令。
  • Commands for handling programming projects.
  • 专门的维护模式变更日志提供程序更改的时间顺序日志的文件。
  • A specialized mode for maintaining ChangeLog files that provide a chronological log of program changes.
  • Xref,一组用于显示符号定义(也称为“标识符”)及其引用的命令。
  • Xref, a set of commands for displaying definitions of symbols (a.k.a. “identifiers”) and their references.
  • EDE,Emacs 自己的 IDE。
  • EDE, the Emacs’s own IDE.
  • 一种合并在单独的开发分支上对程序源进行的更改的模式。
  • A mode for merging changes to program sources made on separate branches of development.
  • 次要模式,用于突出显示错误引用并访问问题跟踪器中引用的错误报告。
  • A minor-mode for highlighting bug references and visiting the referenced bug reports in their issue tracker.

如果您正在维护一个大型 Lisp 程序,那么除了此处描述的功能之外,您可能会发现 Emacs Lisp 回归测试 ( ERT ) 库很有用(请参阅Emacs Lisp 回归测试中的ERT)。

If you are maintaining a large Lisp program, then in addition to the features described here, you may find the Emacs Lisp Regression Testing (ERT) library useful (see ERT in Emacs Lisp Regression Testing).


29.1 版本控制

29.1 Version Control

版本控制系统是一种可以记录源文件的多个版本的程序,存储每个版本的创建时间、创建者以及更改内容的描述等信息。

A version control system is a program that can record multiple versions of a source file, storing information such as the creation time of each version, who made it, and a description of what was changed.

Emacs 版本控制接口称为VC。 VC 命令可与多种不同的版本控制系统配合使用;目前,它支持 Bazaar、CVS、Git、Mercurial、Monotone、RCS、SRC、SCCS/CSSC 和 Subversion。其中,GNU 项目分发了 CVS、RCS 和 Bazaar。

The Emacs version control interface is called VC. VC commands work with several different version control systems; currently, it supports Bazaar, CVS, Git, Mercurial, Monotone, RCS, SRC, SCCS/CSSC, and Subversion. Of these, the GNU project distributes CVS, RCS, and Bazaar.

每当您访问受版本控制系统控制的文件时,VC 都会自动启用。要完全禁用 VC,请将可自定义变量设置vc-handled-backendsnil (请参阅自定义 VC)。

VC is enabled automatically whenever you visit a file governed by a version control system. To disable VC entirely, set the customizable variable vc-handled-backends to nil (see Customizing VC).

要更新当前缓冲区中访问的文件的 VC 状态信息,请使用命令vc-refresh-state。当您在 Emacs 外部执行版本控制命令(例如,从 shell 提示符),或者如果您将缓冲区的文件置于不同的版本控制系统下,或者将其完全从版本控制中删除时,此命令非常有用。

To update the VC state information for the file visited in the current buffer, use the command vc-refresh-state. This command is useful when you perform version control commands outside Emacs (e.g., from the shell prompt), or if you put the buffer’s file under a different version control system, or remove it from version control entirely.

VC 也会在 Dired 缓冲区中自动启用(请参阅Dired,目录编辑器),显示其文件由 VCS 控制的目录。本节中描述的所有 VC 命令都可以从显示包含 VC 控制文件的目录的任何 Dired 缓冲区调用;在 Dired 缓冲区中标记的任何文件(请参阅Dired 标记与标志)都被视为属于当前文件集,并且 VC 命令对此文件集中的文件进行操作。这允许您构建 VC 文件集,包括您想要的任何文件,无论其 VC 状态如何。 (如果从 Dired 缓冲区调用 VC 命令时没有标记任何文件,则缓冲区中当前行显示的文件被视为文件集中的唯一文件。)

VC is also enabled automatically in Dired buffers (see Dired, the Directory Editor) showing directories whose files are controlled by a VCS. All VC commands described in this section can be invoked from any Dired buffer showing a directory with VC-controlled files; any files that are marked in a Dired buffer (see Dired Marks vs. Flags) are considered to belong to the current fileset, and VC commands operate on the files in this fileset. This allows you to construct VC filesets including any files you want, regardless of their VC state. (If no files are marked when a VC command is invoked from a Dired buffer, the file shown on the current line in the buffer is considered the only file in the fileset.)


29.1.1 版本控制简介

29.1.1 Introduction to Version Control

VC 允许您在 Emacs 中使用版本控制系统,将版本控制操作与编辑顺利集成。它为许多版本控制操作中的常见操作提供了统一的接口。

VC allows you to use a version control system from within Emacs, integrating the version control operations smoothly with editing. It provides a uniform interface for common operations in many version control operations.

VC 不支持一些不常见或复杂的版本控制操作,例如更改存储库设置。您应该在 VC 之外执行此类任务,例如通过命令行。

Some uncommon or intricate version control operations, such as altering repository settings, are not supported in VC. You should perform such tasks outside VC, e.g., via the command line.

本节提供版本控制的总体概述,并描述 VC 支持的版本控制系统。如果您已经熟悉要使用的版本控制系统,则可以跳过本节。

This section provides a general overview of version control, and describes the version control systems that VC supports. You can skip this section if you are already familiar with the version control system you want to use.


29.1.1.1 了解它解决的问题

29.1.1.1 Understanding the Problems it Addresses

版本控制系统为您提供三个重要的功能:

Version control systems provide you with three important capabilities:

  • 可逆性:如果您发现所做的某些修改是错误或坏主意,则能够备份到之前的状态。
  • Reversibility: the ability to back up to a previous state if you discover that some modification you did was a mistake or a bad idea.
  • 并发性:让许多人修改同一文件集合的能力,并且知道可以检测和解决冲突的修改。
  • Concurrency: the ability to have many people modifying the same collection of files knowing that conflicting modifications can be detected and resolved.
  • 历史记录:将历史数据附加到您的数据的能力,例如有关每个更改背后的意图的解释性评论。即使对于单独工作的程序员来说,变更历史记录也是对记忆的重要帮助。对于多人项目来说,它们是开发人员之间极其重要的沟通形式。
  • History: the ability to attach historical data to your data, such as explanatory comments about the intention behind each change. Even for a programmer working solo, change histories are an important aid to memory; for a multi-person project, they are a vitally important form of communication among developers.

29.1.1.2 支持的版本控制系统

29.1.1.2 Supported Version Control Systems

VC 目前可与许多不同的版本控制系统配合使用,这些系统称为后端

VC currently works with many different version control systems, which it refers to as back ends:

  • Git 是一个分散的版本控制系统,最初由 Linus Torvalds 发明,用于支持 Linux(他的内核)的开发。 VC 支持许多常见的 Git 操作,但其他操作(例如存储库同步)必须从命令行完成。
  • Git is a decentralized version control system originally invented by Linus Torvalds to support development of Linux (his kernel). VC supports many common Git operations, but others, such as repository syncing, must be done from the command line.
  • CVS 是免费版本控制系统,直到 2008 年左右,大多数自由软件项目都在使用它。从那时起,它已被更新的系统取代。 CVS 允许在本地或通过网络进行并发多用户开发。与较新的系统不同,它缺乏对原子提交和文件移动/重命名的支持。 VC支持CVS下的所有基本编辑操作。
  • CVS is the free version control system that was, until circa 2008, used by the majority of free software projects. Since then, it has been superseded by newer systems. CVS allows concurrent multi-user development either locally or over the network. Unlike newer systems, it lacks support for atomic commits and file moving/renaming. VC supports all basic editing operations under CVS.
  • Subversion (svn) 是一个免费的版本控制系统,设计与CVS 类似,但没有CVS 的问题(例如,它支持文件集的原子提交,以及目录、符号链接、元数据、重命名、复制和删除的版本控制)。
  • Subversion (svn) is a free version control system designed to be similar to CVS but without its problems (e.g., it supports atomic commits of filesets, and versioning of directories, symbolic links, meta-data, renames, copies, and deletes).
  • SCCS 是有史以来第一个版本控制系统,很久以前就被更先进的版本控制系统所取代。 VC 通过自身实现来补偿 SCCS 中缺少的某些功能(例如,版本的标记名称)。其他 VC 功能(例如多分支)根本不可用。由于 SCCS 不是免费的,我们建议避免使用它。
  • SCCS was the first version control system ever built, and was long ago superseded by more advanced ones. VC compensates for certain features missing in SCCS (e.g., tag names for releases) by implementing them itself. Other VC features, such as multiple branches, are simply unavailable. Since SCCS is non-free, we recommend avoiding it.
  • CSSC 是 SCCS 的免费替代品。仅当由于某种原因无法使用更新且设计更好的版本控制系统时,才应使用 CSSC。
  • CSSC is a free replacement for SCCS. You should use CSSC only if, for some reason, you cannot use a more recent and better-designed version control system.
  • RCS 是免费的版本控制系统,VC 最初是围绕它构建的。它相对原始:它不能通过网络使用,并且在单个文件级别上工作。几乎所有可以用 RCS 完成的事情都可以通过 VC 完成。
  • RCS is the free version control system around which VC was initially built. It is relatively primitive: it cannot be used over the network, and works at the level of individual files. Almost everything you can do with RCS can be done through VC.
  • Mercurial (hg) 是一个分散的版本控制系统,与 Git 大致相似。 VC 支持大多数 Mercurial 命令,但存储库同步操作除外。
  • Mercurial (hg) is a decentralized version control system broadly resembling Git. VC supports most Mercurial commands, with the exception of repository sync operations.
  • Bazaar (bzr) 是一个去中心化版本控制系统,支持基于存储库和去中心化版本控制。 VC支持Bazaar下最基本的编辑操作。
  • Bazaar (bzr) is a decentralized version control system that supports both repository-based and decentralized versioning. VC supports most basic editing operations under Bazaar.
  • SRC (src) 是重新加载的 RCS——一种专门的版本控制系统,专为仅由一个人处理的单文件项目而设计。它允许具有独立版本控制历史的多个文件存在于一个目录中,因此特别适合维护小型文档、脚本和点文件。虽然它使用 RCS 进行修订存储,但它提供了一个现代用户界面,具有无锁操作和整数顺序版本号。 VC支持几乎所有的SRC操作。
  • SRC (src) is RCS, reloaded—a specialized version-control system designed for single-file projects worked on by only one person. It allows multiple files with independent version-control histories to exist in one directory, and is thus particularly well suited for maintaining small documents, scripts, and dotfiles. While it uses RCS for revision storage, it presents a modern user interface featuring lockless operation and integer sequential version numbers. VC supports almost all SRC operations.

29.1.1.3 版本控制的概念

29.1.1.3 Concepts of Version Control

当文件处于版本控制之下时,我们说它已 在版本控制系统中注册。该系统有一个 存储库,用于存储文件的当前状态及其更改历史记录,足以重建当前版本或任何早期版本。该存储库还包含其他信息,例如描述对每个文件所做的更改的 日志条目。

When a file is under version control, we say that it is registered in the version control system. The system has a repository which stores both the file’s present state and its change history—enough to reconstruct the current version or any earlier version. The repository also contains other information, such as log entries that describe the changes made to each file.

您实际编辑的版本控制文件的副本称为工作文件。您可以像更改普通文件一样更改每个工作文件。完成一组更改后,您可以提交(或签入)更改;这记录了存储库中的更改以及描述性日志条目。

The copy of a version-controlled file that you actually edit is called the work file. You can change each work file as you would an ordinary file. After you are done with a set of changes, you may commit (or check in) the changes; this records the changes in the repository, along with a descriptive log entry.

工作文件的目录树称为工作树

A directory tree of work files is called a working tree.

每次提交都会在存储库中创建一个新修订。版本控制系统跟踪所有过去的修订以及每个修订中所做的更改。每个修订版均以修订版 ID命名 ,其格式取决于版本控制系统;在最简单的情况下,它只是一个整数。

Each commit creates a new revision in the repository. The version control system keeps track of all past revisions and the changes that were made in each revision. Each revision is named by a revision ID, whose format depends on the version control system; in the simplest case, it is just an integer.

为了超越这些基本概念,您需要了解版本控制系统不同的三个方面。正如接下来的三节中所解释的,它们可以是基于锁的或基于合并的;基于文件或基于变更集;以及集中式或分散式。 VC 处理所有这些操作模式,但它无法隐藏差异。

To go beyond these basic concepts, you will need to understand three aspects in which version control systems differ. As explained in the next three sections, they can be lock-based or merge-based; file-based or changeset-based; and centralized or decentralized. VC handles all these modes of operation, but it cannot hide the differences.


29.1.1.4 基于合并与基于锁的版本控制

29.1.1.4 Merge-based vs Lock-based Version Control

版本控制系统通常具有某种机制来协调想要更改同一文件的用户。有两种方法可以做到这一点:合并和锁定。

A version control system typically has some mechanism to coordinate between users who want to change the same file. There are two ways to do this: merging and locking.

在使用合并的版本控制系统中,每个用户都可以随时修改工作文件。系统允许您工作文件(可能包含尚未提交的更改)与其他人已提交的最新更改合并。

In a version control system that uses merging, each user may modify a work file at any time. The system lets you merge your work file, which may contain changes that have not been committed, with the latest changes that others have committed.

旧版本控制系统使用锁定方案。在这里,工作文件通常是只读的。要编辑文件,您要求版本控制系统通过锁定它来使其可写 ;在任何给定时间只有一个用户可以锁定给定文件。此过程与 Emacs 用于检测普通文件同时编辑的锁定类似,但又有所不同(请参阅防止同时编辑)。当您提交更改时,文件就会解锁,并且工作文件再次变为只读。然后其他用户可以锁定该文件以进行自己的更改。

Older version control systems use a locking scheme instead. Here, work files are normally read-only. To edit a file, you ask the version control system to make it writable for you by locking it; only one user can lock a given file at any given time. This procedure is analogous to, but different from, the locking that Emacs uses to detect simultaneous editing of ordinary files (see Protection against Simultaneous Editing). When you commit your changes, that unlocks the file, and the work file becomes read-only again. Other users may then lock the file to make their own changes.

当多个用户尝试同时修改同一文件时,锁定和合并系统都可能出现问题。锁定系统存在锁冲突;用户可能尝试检出文件但由于文件被锁定而无法检出。在合并系统中,当您提交的文件更改与其他人在签出后提交的更改发生冲突时,就会发生合并冲突。这两种冲突都必须通过人的判断和沟通来解决。经验表明,合并优于锁定,既方便开发人员,又最大限度地减少实际发生的冲突的数量和严重性。

Both locking and merging systems can have problems when multiple users try to modify the same file at the same time. Locking systems have lock conflicts; a user may try to check a file out and be unable to because it is locked. In merging systems, merge conflicts happen when you commit a change to a file that conflicts with a change committed by someone else after your checkout. Both kinds of conflict have to be resolved by human judgment and communication. Experience has shown that merging is superior to locking, both in convenience to developers and in minimizing the number and severity of conflicts that actually occur.

SCCS 始终使用锁定。 RCS 默认情况下是基于锁的,但可以被告知以合并方式进行操作。 CVS 和 Subversion 默认情况下是基于合并的,但可以被告知以锁定模式运行。去中心化版本控制系统,例如 Git 和 Mercurial,完全基于合并。

SCCS always uses locking. RCS is lock-based by default but can be told to operate in a merging style. CVS and Subversion are merge-based by default but can be told to operate in a locking mode. Decentralized version control systems, such as Git and Mercurial, are exclusively merging-based.

VC模式支持锁定和合并版本控制。术语“提交”和“更新”用于较新的版本控制系统;旧的基于锁的系统使用术语“签入”和“签出”。 VC尽可能地隐藏了它们之间的差异。

VC mode supports both locking and merging version control. The terms “commit” and “update” are used in newer version control systems; older lock-based systems use the terms “check in” and “check out”. VC hides the differences between them as much as possible.


29.1.1.5 基于变更集与基于文件的版本控制

29.1.1.5 Changeset-based vs File-based Version Control

在 SCCS、RCS、CVS 和其他早期版本控制系统(以及 SRC)上,版本控制操作是基于文件的:每个文件都有自己的注释和修订历史记录,与所有其他文件的注释和修订历史记录分开。从 Subversion 开始,较新的系统是 基于变更集的:一次提交可能包括对多个文件的更改,并且整个更改集作为一个单元进行处理。与更改相关的任何注释不属于单个文件,而是属于更改集本身。

On SCCS, RCS, CVS, and other early version control systems (and also in SRC), version control operations are file-based: each file has its own comment and revision history separate from that of all other files. Newer systems, beginning with Subversion, are changeset-based: a commit may include changes to several files, and the entire set of changes is handled as a unit. Any comment associated with the change does not belong to a single file, but to the changeset itself.

基于变更集的版本控制比基于文件的版本控制更灵活、更强大;通常,当必须撤消对多个文件的更改时,能够轻松识别并删除所有文件是件好事。

Changeset-based version control is more flexible and powerful than file-based version control; usually, when a change to multiple files has to be reversed, it’s good to be able to easily identify and remove all of it.


29.1.1.6 分散式与集中式存储库

29.1.1.6 Decentralized vs Centralized Repositories

早期的版本控制系统是围绕 集中式模型设计的,其中每个项目只有一个供所有开发人员使用的存储库。 SCCS、RCS、CVS、Subversion 和 SRC 共享这种模型。它的缺点之一是存储库是可靠性和效率的瓶颈。

Early version control systems were designed around a centralized model in which each project has only one repository used by all developers. SCCS, RCS, CVS, Subversion, and SRC share this kind of model. One of its drawbacks is that the repository is a choke point for reliability and efficiency.

GNU Arch 开创了分布式去中心化版本控制的概念,后来在 Git、Mercurial 和 Bazaar 中实现。一个项目可能有几个不同的存储库,这些系统支持存储库之间的某种超级合并,试图协调它们的更改历史。实际上,每个开发人员都有一个存储库,并且存储库合并取代了提交操作。

GNU Arch pioneered the concept of distributed or decentralized version control, later implemented in Git, Mercurial, and Bazaar. A project may have several different repositories, and these systems support a sort of super-merge between repositories that tries to reconcile their change histories. In effect, there is one repository for each developer, and repository merges take the place of commit operations.

VC 帮助您管理个人工作文件和存储库之间的流量。存储库是单个主存储库还是对等存储库网络之一,都不是 VC 必须关心的事情。

VC helps you manage the traffic between your personal workfiles and a repository. Whether the repository is a single master, or one of a network of peer repositories, is not something VC has to care about.


29.1.1.7 日志文件类型

29.1.1.7 Types of Log File

使用版本控制系统的项目可以有两种类型的更改日志。一种是由版本控制系统维护的日志:每次提交更改时,都会为该更改填写一个日志条目(请参阅日志条目缓冲区的功能)。这称为版本控制日志

Projects that use a version control system can have two types of log for changes. One is the log maintained by the version control system: each time you commit a change, you fill out a log entry for the change (see Features of the Log Entry Buffer). This is called the version control log.

另一种日志是文件变更日志(请参阅更改日志)。它提供了对程序大部分内容(通常是一个目录及其子目录)的所有更改的时间顺序记录。一个小程序会使用一个变更日志文件;一个大的程序可能有一个变更日志每个主要目录中的文件。请参阅更改日志。早在版本控制系统出现之前,程序员就已经使用了变更日志。

The other kind of log is the file ChangeLog (see Change Logs). It provides a chronological record of all changes to a large portion of a program—typically one directory and its subdirectories. A small program would use one ChangeLog file; a large program may have a ChangeLog file in each major directory. See Change Logs. Programmers have used change logs since long before version control systems.

基于变更集的版本系统通常会为整个系统维护一个基于变更集的修改日志,这使得变更日志文件有些冗余。它们保留的一个优点是,有时能够将单个目录的事务历史记录与其他目录的事务历史记录分开查看是很有用的。另一个优点是提交日志在许多版本控制系统中无法修复。

Changeset-based version systems typically maintain a changeset-based modification log for the entire system, which makes change log files somewhat redundant. One advantage that they retain is that it is sometimes useful to be able to view the transaction history of a single directory separately from those of other directories. Another advantage is that commit logs can’t be fixed in many version control systems.

使用版本控制维护的项目可以仅使用版本控制日志,也可以使用两种日志。它可以以一种方式处理某些文件,以另一种方式处理某些文件。每个项目都有其政策,您应该遵循。

A project maintained with version control can use just the version control log, or it can use both kinds of logs. It can handle some files one way and some files the other way. Each project has its policy, which you should follow.

当策略要使用两者时,您通常希望为每个更改只写入一次条目,然后将其放入两个日志中。您可以将条目写入变更日志C-c C-a,然后在提交更改时将其复制到日志缓冲区 (请参阅日志条目缓冲区的功能)。或者,您可以在提交更改时将条目写入日志缓冲区(借助C-c C-w),然后使用C-x v a 命令将其复制到变更日志 (请参阅更改日志和 VC)。

When the policy is to use both, you typically want to write an entry for each change just once, then put it into both logs. You can write the entry in ChangeLog, then copy it to the log buffer with C-c C-a when committing the change (see Features of the Log Entry Buffer). Or you can write the entry in the log buffer while committing the change (with the help of C-c C-w), and later use the C-x v a command to copy it to ChangeLog (see Change Logs and VC).


29.1.2 版本控制和模式行

29.1.2 Version Control and the Mode Line

当您访问受版本控制的文件时,Emacs 在模式行上指示这一点。例如, 'BZR-1223' 表示 Bazaar 用于该文件,当前修订 ID 为 1223。

When you visit a file that is under version control, Emacs indicates this on the mode line. For example, ‘Bzr-1223’ says that Bazaar is used for that file, and the current revision ID is 1223.

后端名称和修订 ID 之间的字符指示工作文件的版本控制状态。在基于合并的版本控制系统中,'-' 字符表示工作文件未修改,并且 ':' 表明它已被修改。 '' 表示该文件因最近的合并操作而包含冲突(请参阅合并分支),或者该文件已从版本控制中删除。最后, '' 表示该文件受版本控制,但在工作树中丢失。

The character between the back-end name and the revision ID indicates the version control status of the work file. In a merge-based version control system, a ‘-’ character indicates that the work file is unmodified, and ‘:’ indicates that it has been modified. ‘!’ indicates that the file contains conflicts as result of a recent merge operation (see Merging Branches), or that the file was removed from the version control. Finally, ‘?’ means that the file is under version control, but is missing from the working tree.

在基于锁的系统中,'-' 表示未锁定的文件,并且 ':' 一个锁定的文件;如果文件被其他用户锁定(例如,'吉姆'),显示为 'RCS:吉姆:1.3'。 '@' 表示该文件已在本地添加,但尚未提交到主存储库。

In a lock-based system, ‘-’ indicates an unlocked file, and ‘:’ a locked file; if the file is locked by another user (for instance, ‘jim’), that is displayed as ‘RCS:jim:1.3’. ‘@’ means that the file was locally added, but not yet committed to the master repository.

在图形显示上,您可以将鼠标移到该模式线指示器上以弹出工具提示,其中显示版本控制状态的更详细描述。按下mouse-1 指示器会弹出 VC 命令菜单,与 '工具/版本控制' 在菜单栏上。

On a graphical display, you can move the mouse over this mode line indicator to pop up a tool-tip, which displays a more verbose description of the version control status. Pressing mouse-1 over the indicator pops up a menu of VC commands, identical to ‘Tools / Version Control’ on the menu bar.

当自动恢复模式(请参阅恢复缓冲区)恢复受版本控制的缓冲区时,它会更新模式行中的版本控制信息。但是,如果版本控制状态在当前 Emacs 会话外部未更改工作文件的情况下发生更改,自动恢复模式可能无法正确更新此信息。如果设置 auto-revert-check-vc-infot,自动恢复模式会每秒更新版本控制状态信息 auto-revert-interval,即使工作文件本身未更改。所产生的 CPU 使用率取决于版本控制系统,但通常不会过多。

When Auto Revert mode (see Reverting a Buffer) reverts a buffer that is under version control, it updates the version control information in the mode line. However, Auto Revert mode may not properly update this information if the version control status changes without changes to the work file, from outside the current Emacs session. If you set auto-revert-check-vc-info to t, Auto Revert mode updates the version control status information every auto-revert-interval seconds, even if the work file itself is unchanged. The resulting CPU usage depends on the version control system, but is usually not excessive.


29.1.3 版本控制下的基本编辑

29.1.3 Basic Editing under Version Control

大多数 VC 命令都对VC 文件集进行操作。 VC 文件集是 VC 操作所作用的一个或多个文件的集合。当您在访问版本控制文件的缓冲区中键入 VC 命令时,VC 文件集就是那个文件。当您在 VC 目录缓冲区中键入它们,并且其中的某些文件被标记时,VC 文件集由标记的文件组成(请参阅VC 目录模式)。同样,当您从 Dired 缓冲区调用 VC 命令时,VC 文件集由标记的文件组成(请参阅Dired 标记与标志),如果没有标记文件,则默认为当前行上显示的文件。

Most VC commands operate on VC filesets. A VC fileset is a collection of one or more files that a VC operation acts upon. When you type VC commands in a buffer visiting a version-controlled file, the VC fileset is simply that one file. When you type them in a VC Directory buffer, and some files in it are marked, the VC fileset consists of the marked files (see VC Directory Mode). Likewise, when you invoke a VC command from a Dired buffer, the VC fileset consists of the marked files (see Dired Marks vs. Flags), defaulting to the file shown on the current line if no files are marked.

通过现代基于变更集的版本控制系统(请参阅基于变更集与基于文件的版本控制),例如 Git、Mercurial 和 Bazaar,VC 命令将多文件 VC 文件集作为一个组进行处理。例如,提交多文件 VC 文件集会生成单个修订版,其中包含对所有这些文件的更改。在旧的基于文件的版本控制系统(例如 CVS)上,多文件 VC 文件集中的每个文件都是单独处理的;因此,提交文件集会为文件集中的每个更改的文件生成一个修订版本。

With modern changeset-based version control systems (see Changeset-based vs File-based Version Control), such as Git, Mercurial, and Bazaar, VC commands handle multi-file VC filesets as a group. For example, committing a multi-file VC fileset generates a single revision, containing the changes to all those files. On older file-based version control systems like CVS, each file in a multi-file VC fileset is handled individually; thus, committing a fileset generates one revision for each changed file in the fileset.

C-x v v
C-x v v

对当前 VC 文件集执行下一个适当的版本控制操作。

Perform the next appropriate version control operation on the current VC fileset.

主要 VC 命令是一个多用途命令C-x v v ( vc-next-action),它对当前 VC 文件集执行最适当的操作:将其注册到版本控制系统,或提交它,或解锁它,或将更改合并到其中。以下小节详细描述了每种情况的具体操作。您可以C-x v v在文件访问缓冲区、Dired 缓冲区或 VC 目录缓冲区中使用;在后两种情况下,该命令对由标记文件组成的文件集进行操作。您还可以C-x v v在 Diff 模式下的带有补丁的缓冲区中使用 , (请参阅Diff 模式),在这种情况下,该命令将对其差异显示在缓冲区中的文件进行操作。

The principal VC command is a multi-purpose command, C-x v v (vc-next-action), which performs the most appropriate action on the current VC fileset: either registering it with a version control system, or committing it, or unlocking it, or merging changes into it. The precise actions for each situation are described in detail in the following subsections. You can use C-x v v either in a file-visiting buffer, in a Dired buffer, or in a VC Directory buffer; in the latter two cases the command operates on the fileset consisting of the marked files. You can also use C-x v v, in a buffer with patches under Diff Mode (see Diff Mode), in which case the command operates on the files whose diffs are shown in the buffer.

请注意,VC 文件集与用于查看和访问功能组中的文件的命名文件集不同(请参阅文件集)。与命名文件集不同,VC 文件集没有命名,并且不会跨会话持续存在。

Note that VC filesets are distinct from the named filesets used for viewing and visiting files in functional groups (see Filesets). Unlike named filesets, VC filesets are not named and don’t persist across sessions.


29.1.3.1 带合并的基本版本控制

29.1.3.1 Basic Version Control with Merging

使用现代基于合并的版本控制系统(例如 Git 和 Hg;请参阅基于合并与基于锁定的版本控制),C-x v v当从访问版本控制文件或 VC Directory 或 Dired 缓冲区的缓冲区调用时,会执行以下操作:

With a modern merging-based version control system (such as Git and Hg; see Merge-based vs Lock-based Version Control), C-x v v does the following when invoked from a buffer that visits a version-controlled file or a VC Directory or Dired buffer:

  • 如果 VC 文件集中存在多个文件,并且这些文件的版本控制状态不一致,则发出错误信号。 (但是请注意,文件集允许包含新添加的文件和修改的文件;请参阅注册文件进行版本控制。)如果文件集中的文件丢失(从文件系统中删除,但仍然存在),也会发出错误信号由版本控制跟踪),或者被版本控制忽略。
  • If there is more than one file in the VC fileset and the files have inconsistent version control statuses, signal an error. (Note, however, that a fileset is allowed to include both newly-added files and modified files; see Registering a File for Version Control.) Also signal an error if the files in the fileset are missing (removed from the filesystem, but still tracked by version control), or are ignored by version control.
  • 如果 VC 文件集中的每个文件均已注册且相对于最新版本未更改,则不执行任何操作。
  • If every file in the VC fileset is registered and unchanged with respect to the last revision, do nothing.
  • 如果VC文件集中没有文件在版本控制系统中注册,则将新添加的文件注册到VC文件集中,即将它们置于版本控制之下。请参阅注册文件以进行版本控制。如果 Emacs 找不到要注册的系统,它会提示输入存储库类型,创建一个新存储库,并向其注册 VC 文件集。您还可以显式指定系统,请参阅中的高级控制C-x v v。请注意,注册文件并不提交它们;而是提交文件。您必须C-x v v再次调用才能提交,请参见下文。
  • If none of the files in the VC fileset are registered with a version control system, register the newly-added files in the VC fileset, i.e., place them under version control. See Registering a File for Version Control. If Emacs cannot find a system to register under, it prompts for a repository type, creates a new repository, and registers the VC fileset with it. You can also specify the system explicitly, see Advanced Control in C-x v v. Note that registering the files doesn’t commit them; you must invoke C-x v v again to commit, see below.
  • 如果 VC 文件集中的每个文件都已新增或修改,则提交更改的文件。为此,Emacs 会弹出一个 *vc-日志*缓冲;键入所需的更改日志条目,然后C-c C-c进行提交。请参阅日志条目缓冲区的功能

    使用现代分散版本控制系统(Git、Mercurial 等),更改会在本地提交,不会自动传播到上游存储库(通常位于远程主机上)。在这些情况下,如果自上次更新以来存储库已更改,则提交可能会失败。在这种情况下,您必须从上游更新,然后重试。为此, 请使用C-x v +(请参阅将更改拉入/推入分支)或C-x v m(请参阅合并分支)。

    使用集中式版本控制系统,如果由于上游更改而提交失败,请C-x v v再次键入以合并上游存储库更改。

  • If every file in the VC fileset has been either newly-added or modified, commit the changed files. To do this, Emacs pops up a *vc-log* buffer; type the desired log entry for the changes, followed by C-c C-c to commit. See Features of the Log Entry Buffer.

    With modern decentralized version control systems (Git, Mercurial, etc.), the changes are committed locally and not automatically propagated to the upstream repository (which is usually on a remote host). In these cases, if the repository has been changed since your last update, the commit may fail. In that case, you must update from upstream and then try again. Use C-x v + (see Pulling/Pushing Changes into/from a Branch) or C-x v m (see Merging Branches) for that.

    With a centralized version control system, if the commit fails due to upstream changes, type C-x v v again to merge in the upstream repository changes.

  • 最后,如果您使用集中式版本控制系统,如果 VC 文件集中的任何文件相对于上游存储库已过时,请主动从存储库更新文件集。
  • Finally, if you are using a centralized version control system, if any file in the VC fileset is outdated with respect to the upstream repository, offer to update the fileset from the repository.

当您在非锁定模式下使用 RCS 时,这些规则也适用,但更改不会自动从存储库合并。自您开始编辑文件以来,如果其他用户在同一文件中提交了更改,则不会通知您;当您提交修订时,其他用户的更改将被删除(但是,它们保留在存储库中,因此不会不可挽回地丢失)。因此,在提交更改之前,您必须验证当前版本是否未更改。此外,即使在这种模式下,RCS 也可以锁定: C-x v v未修改的文件会锁定该文件,就像在正常锁定模式下使用 RCS 一样(请参阅使用锁定进行基本版本控制)。

These rules also apply when you use RCS in its non-locking mode, except that changes are not automatically merged from the repository. Nothing informs you if another user has committed changes in the same file since you began editing it; when you commit your revision, that other user’s changes are removed (however, they remain in the repository and are thus not irrevocably lost). Therefore, you must verify that the current revision is unchanged before committing your changes. In addition, locking is possible with RCS even in this mode: C-x v v with an unmodified file locks the file, just as it does with RCS in its normal locking mode (see Basic Version Control with Locking).

如果C-x v v在 Diff 模式下从缓冲区调用,该命令假定缓冲区保存一个或多个文件的一组补丁。然后,它将更改应用到各个文件,并在弹出窗口后提交更改*vc-日志*缓冲区以允许您键入合适的提交日志消息。

If C-x v v is invoked from a buffer under Diff Mode, the command assumes the buffer holds a set of patches for one or more files. It then applies the changes to the respective files and commits the changes after popping up the *vc-log* buffer to allow you to type a suitable commit log message.


29.1.3.2 带锁定的基本版本控制

29.1.3.2 Basic Version Control with Locking

使用基于锁定的版本控制系统(例如默认模式下的 SCCS 和 RCS),C-x v v执行以下操作:

With a locking-based version control system (such as SCCS, and RCS in its default mode), C-x v v does the following:

  • 如果 VC 文件集中存在多个文件,并且这些文件的版本控制状态不一致,则发出错误信号。如果文件集中的文件丢失(从文件系统中删除,但仍由版本控制跟踪),也会发出错误信号。
  • If there is more than one file in the VC fileset and the files have inconsistent version control statuses, signal an error. Also signal an error if the files in the fileset are missing (removed from the filesystem, but still tracked by version control).
  • 如果 VC 文件集中的每个文件都未在版本控制系统中注册,请在文件集中注册新添加的文件。请参阅注册文件以进行版本控制。如果 Emacs 找不到要注册的系统,它会提示输入存储库类型,创建一个新存储库,并向其注册 VC 文件集。您还可以显式指定系统,请参阅中的高级控制C-x v v
  • If each file in the VC fileset is not registered with a version control system, register the newly-added files in the fileset. See Registering a File for Version Control. If Emacs cannot find a system to register under, it prompts for a repository type, creates a new repository, and registers the VC fileset with it. You can also specify the system explicitly, see Advanced Control in C-x v v.
  • 如果每个文件都已注册并解锁,请检出文件:锁定每个文件并使其可写,以便您可以开始编辑它。
  • If each file is registered and unlocked, check the files out: lock each one and make it writable, so that you can begin to edit it.
  • 如果每个文件都被您锁定并包含更改,请提交(也称为“签入”)更改。为此,Emacs 会弹出一个 *vc-日志*缓冲;键入新版本所需的日志条目,然后C-c C-c进行提交(请参阅日志条目缓冲区的功能)。
  • If each file is locked by you and contains changes, commit (a.k.a. “check-in”) the changes. To do this, Emacs pops up a *vc-log* buffer; type the desired log entry for the new revision, followed by C-c C-c to commit (see Features of the Log Entry Buffer).
  • 如果每个文件都被您锁定,但您没有更改它,请释放锁定并再次使该文件变为只读。这将撤消先前对自签出以来未更改的文件的签出操作。
  • If each file is locked by you, but you have not changed it, release the lock and make the file read-only again. This undoes previous check-out operation for files that were not changed since the checkout.
  • 如果每个文件都被其他用户锁定,请询问您是否要窃取该锁。如果您选择“是”,该文件将被您锁定,并向之前锁定该文件的用户发送一条警告消息。
  • If each file is locked by another user, ask whether you want to steal the lock. If you say yes, the file becomes locked by you, and a warning message is sent to the user who had formerly locked the file.
  • 如果文件集中的文件已解锁,但相对于其上次修订版有所更改,请提出为每个此类文件申请锁定或将文件恢复到上次签入的修订版。 (这种情况是特殊情况,通常不应发生。)
  • If files in the fileset are unlocked, but have changes with respect to their last revision, offer to claim the lock for each such file or to revert the file to the last checked-in revision. (This situation is exceptional and should not normally happen.)

当您在锁定模式下使用 CVS 时,这些规则也适用,只不过 CVS 不支持窃取锁。

These rules also apply when you use CVS in locking mode, except that CVS does not support stealing locks.


29.1.3.3 高级控制C-x v v

29.1.3.3 Advanced Control in C-x v v

vc-next-action当您为( )提供前缀参数时C-u C-x v v,它仍然执行下一个逻辑版本控制操作,但接受其他参数来精确指定如何执行该操作。

When you give a prefix argument to vc-next-action (C-u C-x v v), it still performs the next logical version control operation, but accepts additional arguments to specify precisely how to do the operation.

  • 您可以指定版本控制系统的名称。如果文件集可以由多个版本控制系统管理,并且 Emacs 无法检测到正确的版本控制系统,那么这一点很有用。
  • You can specify the name of a version control system. This is useful if the fileset can be managed by more than one version control system, and Emacs fails to detect the correct one.
  • 否则,如果使用 CVS、RCS 或 SRC,您可以指定修订 ID。

    如果文件集被修改(或锁定),这会使 Emacs 提交具有该修订 ID 的文件。您可以通过提供适当的修订 ID 来创建新分支(请参阅版本控制分支)。

    如果文件集未修改(且未锁定),则会将指定的修订检出到工作树中。您还可以通过给出另一个分支的修订版或分支 ID 来指定其修订版(请参阅在分支之间切换)。空参数(即)检查当前分支上的最新(也称为“head”)修订。 C-u C-x v v RET

    以这种方式指定修订 ID 会被分散的版本控制系统默默地忽略。这些系统不允许您指定自己的修订 ID,也不使用签出单个文件的概念。

  • Otherwise, if using CVS, RCS or SRC, you can specify a revision ID.

    If the fileset is modified (or locked), this makes Emacs commit the files with that revision ID. You can create a new branch by supplying an appropriate revision ID (see Version Control Branches).

    If the fileset is unmodified (and unlocked), this checks out the specified revision into the working tree. You can also specify a revision on another branch by giving its revision or branch ID (see Switching between Branches). An empty argument (i.e., C-u C-x v v RET) checks out the latest (a.k.a. “head”) revision on the current branch.

    Specifying revision ID in this manner is silently ignored by a decentralized version control system. Those systems do not let you specify your own revision IDs, nor do they use the concept of checking out individual files.


29.1.4 日志条目缓冲区的特性

29.1.4 Features of the Log Entry Buffer

当你告诉 VC 提交更改时,它会弹出一个名为 *vc-日志*。在此缓冲区中,您应该编写一个日志条目 来描述您所做的更改(请参阅了解它解决的问题)。完成后,键入C-c C-c( log-edit-done) 退出缓冲区并提交更改以及日志条目。

When you tell VC to commit a change, it pops up a buffer named *vc-log*. In this buffer, you should write a log entry describing the changes you have made (see Understanding the Problems it Addresses). After you are done, type C-c C-c (log-edit-done) to exit the buffer and commit the change, together with your log entry.

主要模式为*vc-日志*buffer 是日志编辑模式,是文本模式的变体(请参阅文本模式)。进入日志编辑模式后,Emacs 运行钩子text-mode-hookvc-log-mode-hook (请参阅Hooks)。

The major mode for the *vc-log* buffer is Log Edit mode, a variant of Text mode (see Text Mode). On entering Log Edit mode, Emacs runs the hooks text-mode-hook and vc-log-mode-hook (see Hooks).

在里面*vc-日志*缓冲区中,您可以写入一个或多个标题行,指定要提供给版本控制系统的附加信息。每个标题行必须在缓冲区顶部占据一行;非标题行的第一行被视为日志条目的开始。例如,以下标题行表明当前更改不是由您编写的,而是由其他开发人员编写的:

In the *vc-log* buffer, you can write one or more header lines, specifying additional information to be supplied to the version control system. Each header line must occupy a single line at the top of the buffer; the first line that is not a header line is treated as the start of the log entry. For example, the following header line states that the present change was not written by you, but by another developer:

作者:JR Hacker <jrh@example.com>
Author: J. R. Hacker <jrh@example.com>

除了'作者' 标头,Emacs 识别标头 '概括'(变更集的一行摘要),'日期' (手动指定的提交时间),和 '修复'(对通过更改修复的错误的引用)。并非所有版本控制系统都能识别所有标头。如果您为不支持的系统指定标头,则该标头将被视为日志条目的一部分。

Apart from the ‘Author’ header, Emacs recognizes the headers ‘Summary’ (a one-line summary of the changeset), ‘Date’ (a manually-specified commit time), and ‘Fixes’ (a reference to a bug fixed by the change). Not all version control systems recognize all headers. If you specify a header for a system that does not support it, the header is treated as part of the log entry.

当在*vc-日志*buffer,当前的 VC 文件集被认为是如果您键入 则将提交的文件集 。要查看 VC 文件集中的文件列表,请键入( )。要查看 VC 文件集与您开始编辑的版本之间的更改差异(请参阅检查和比较旧版本),请键入 ( )。 C-c C-cC-c C-flog-edit-show-filesC-c C-dlog-edit-show-diff

While in the *vc-log* buffer, the current VC fileset is considered to be the fileset that will be committed if you type C-c C-c. To view a list of the files in the VC fileset, type C-c C-f (log-edit-show-files). To view a diff of changes between the VC fileset and the version from which you started editing (see Examining And Comparing Old Revisions), type C-c C-d (log-edit-show-diff).

为了帮助生成 ChangeLog 条目,请键入C-c C-w ( log-edit-generate-changelog-from-diff),以生成骨架 ChangeLog 条目,并根据 VC 文件集的差异列出所有已更改的文件和函数名称。留空的连续条目将通过M-q( )合并fill-paragraph。默认情况下,框架仅包含文件名,没有任何前导目录。如果您希望将前导目录添加到 VC 根目录之前,请自定义diff-add-log-use-relative-names.

To help generate ChangeLog entries, type C-c C-w (log-edit-generate-changelog-from-diff), to generate skeleton ChangeLog entries, listing all changed file and function names based on the diff of the VC fileset. Consecutive entries left empty will be combined by M-q (fill-paragraph). By default the skeleton will just include the file name, without any leading directories. If you wish to prepend the leading directories up to the VC root, customize diff-add-log-use-relative-names.

如果 VC 文件集包含一个或多个变更日志文件(请参阅更改日志),键入C-c C-a ( log-edit-insert-changelog) 将相关条目拉入*vc-日志*缓冲。如果每个中最上面的项目 变更日志是在当前日期以您的用户名创建的,此命令会搜索该项目以查找与要提交的文件匹配的条目,然后插入它们。如果您使用 CVS 或 RCS,请参阅更改日志和 VC,了解相反的工作方式 - 从日志编辑缓冲区生成更改日志条目。

If the VC fileset includes one or more ChangeLog files (see Change Logs), type C-c C-a (log-edit-insert-changelog) to pull the relevant entries into the *vc-log* buffer. If the topmost item in each ChangeLog was made under your user name on the current date, this command searches that item for entries matching the file(s) to be committed, and inserts them. If you are using CVS or RCS, see Change Logs and VC, for the opposite way of working—generating ChangeLog entries from the Log Edit buffer.

要中止提交,只需不要C-c C-c在该缓冲区中键入即可。您可以切换缓冲区并进行其他编辑。只要您不尝试进行另一次提交,您正在编辑的条目就会保留在*vc-日志*缓冲区,您可以随时返回该缓冲区以完成提交。

To abort a commit, just don’t type C-c C-c in that buffer. You can switch buffers and do other editing. As long as you don’t try to make another commit, the entry you were editing remains in the *vc-log* buffer, and you can go back to that buffer at any time to complete the commit.

您还可以浏览以前日志条目的历史记录以复制提交评论。当您想要使用类似的注释进行多次提交时,这会很有用。用于执行此操作的命令M-nM-pM-sM-r迷你缓冲区历史命令(请参阅迷你缓冲区历史记录)一样工作,只不过它们在迷你缓冲区之外使用。

You can also browse the history of previous log entries to duplicate a commit comment. This can be useful when you want to make several commits with similar comments. The commands M-n, M-p, M-s and M-r for doing this work just like the minibuffer history commands (see Minibuffer History), except that they are used outside the minibuffer.


29.1.5 注册文件进行版本控制

29.1.5 Registering a File for Version Control

C-x v i
C-x v i

注册访问的文件以进行版本控制。

Register the visited file for version control.

命令C-x v i( vc-register)在当前 VC 文件集中注册每个文件,将其置于版本控制之下。这本质上相当于对C-x v v未注册的 VC 文件集执行的操作(请参阅版本控制下的基本编辑),但如果 VC 文件集已注册,C-x v i则会发出错误信号,同时C-x v v执行其他操作。

The command C-x v i (vc-register) registers each file in the current VC fileset, placing it under version control. This is essentially equivalent to the action of C-x v v on an unregistered VC fileset (see Basic Editing under Version Control), except that if the VC fileset is already registered, C-x v i signals an error whereas C-x v v performs some other action.

要注册文件,Emacs 必须选择版本控制系统。对于多文件 VC 文件集,VC 目录缓冲区指定要使用的系统(请参阅VC 目录模式)。对于单文件 VC 文件集,如果该文件的目录已包含在版本控制系统中注册的文件,或者该目录是由版本控制系统控制的目录树的一部分,则 Emacs 将选择该系统。如果有多个版本控制系统适用,Emacs 将使用变量中第一个出现的版本控制系统 vc-handled-backends(请参阅自定义 VC)。如果 Emacs 找不到版本控制系统来注册文件,它会提示输入存储库类型,创建一个新存储库,并将文件注册到该存储库中。

To register a file, Emacs must choose a version control system. For a multi-file VC fileset, the VC Directory buffer specifies the system to use (see VC Directory Mode). For a single-file VC fileset, if the file’s directory already contains files registered in a version control system, or if the directory is part of a directory tree controlled by a version control system, Emacs chooses that system. In the event that more than one version control system is applicable, Emacs uses the one that appears first in the variable vc-handled-backends (see Customizing VC). If Emacs cannot find a version control system to register the file under, it prompts for a repository type, creates a new repository, and registers the file into that repository.

对于大多数版本控制系统,将文件注册到 工作树C-x v iC-x v v将其添加到工作树,但不提交它,即不将其添加到存储库。此类文件被标记为已添加到 VC 目录缓冲区中,并且访问此类文件的缓冲区的模式行显示修订 ID '@@'。要使注册在存储库中生效,您必须提交新添加的文件(请参阅版本控制下的基本编辑)。请注意,单个提交可以包括文件添加和对 VCS 已知文件的编辑。

With most version control systems, registering a file with C-x v i or C-x v v adds it to the working tree, but does not commit it, i.e., doesn’t add it to the repository. Such files are labeled as added in the VC Directory buffer, and the mode line of the buffers visiting such files shows a revision ID of ‘@@’. To make the registration take effect in the repository, you must commit the newly-added files (see Basic Editing under Version Control). Note that a single commit can include both file additions and edits to files already known to the VCS.

使用基于锁定的版本控制系统(请参阅基于合并与基于锁定的版本控制),注册文件会使其处于解锁状态且只读。键入C-x v v以签出文件并开始编辑它。

With a locking-based version control system (see Merge-based vs Lock-based Version Control), registering a file leaves it unlocked and read-only. Type C-x v v to check-out the file and start editing it.


29.1.6 检查和比较旧版本

29.1.6 Examining And Comparing Old Revisions

C-x v =
C-x v =

将当前 VC 文件集中的工作文件与您开始的版本进行比较 ( vc-diff)。使用前缀参数,提示当前 VC 文件集的两个修订版本并比较它们。您还可以从 Dired 缓冲区调用此命令(请参阅Dired,目录编辑器)。

Compare the work files in the current VC fileset with the versions you started from (vc-diff). With a prefix argument, prompt for two revisions of the current VC fileset and compare them. You can also call this command from a Dired buffer (see Dired, the Directory Editor).

M-x vc-ediff
M-x vc-ediff

类似C-x v =,但使用 Ediff。请参阅Ediff 手册中的Ediff

Like C-x v =, but using Ediff. See Ediff in The Ediff Manual.

C-x v D
C-x v D

将整个工作树与您从 ( vc-root-diff) 开始的修订版本进行比较。使用前缀参数,提示两个修订并比较它们的树。

Compare the entire working tree to the revision you started from (vc-root-diff). With a prefix argument, prompt for two revisions and compare their trees.

C-x v ~
C-x v ~

提示对当前文件进行修订,并在单独的缓冲区 ( vc-revision-other-window) 中访问它。

Prompt for a revision of the current file, and visit it in a separate buffer (vc-revision-other-window).

C-x v g
C-x v g

显示当前文件的带注释版本:对于每一行,显示对其进行修改的最新版本 ( vc-annotate)。

Display an annotated version of the current file: for each line, show the latest revision in which it was modified (vc-annotate).

C-x v =( vc-diff) 显示差异,它将当前 VC 文件集中的每个工作文件与您开始编辑的版本进行比较。差异显示在另一个窗口中的差异模式缓冲区中(请参阅差异模式),名为*vc-差异*。常用的 Diff 模式命令在此缓冲区中可用。特别地,g( revert-buffer) 命令再次执行文件比较,生成新的差异。

C-x v = (vc-diff) displays a diff which compares each work file in the current VC fileset to the version(s) from which you started editing. The diff is displayed in another window, in a Diff mode buffer (see Diff Mode) named *vc-diff*. The usual Diff mode commands are available in this buffer. In particular, the g (revert-buffer) command performs the file comparison again, generating a new diff.

要比较当前 VC 文件集的两个任意修订版,请 vc-diff使用前缀参数进行调用:C-u C-x v =.这会提示输入两个修订 ID(请参阅版本控制的概念),并显示文件集的这些版本之间的差异。如果版本控制系统是基于文件而不是基于变更集(例如,CVS),这对于多文件 VC 文件集将无法可靠地工作,因为不同文件的修订 ID 将不会以任何有意义的方式相关。

To compare two arbitrary revisions of the current VC fileset, call vc-diff with a prefix argument: C-u C-x v =. This prompts for two revision IDs (see Concepts of Version Control), and displays a diff between those versions of the fileset. This will not work reliably for multi-file VC filesets, if the version control system is file-based rather than changeset-based (e.g., CVS), since then revision IDs for different files would not be related in any meaningful way.

某些版本控制系统允许您以其他格式指定修订版本,而不是修订版本 ID。例如,在 Bazaar 下您可以输入 '日期:昨天' 的参数C-u C-x v = (以及相关命令)指定昨天之后提交的第一个修订。详细信息请参见版本控制系统的文档。

Instead of the revision ID, some version control systems let you specify revisions in other formats. For instance, under Bazaar you can enter ‘date:yesterday’ for the argument to C-u C-x v = (and related commands) to specify the first revision committed after yesterday. See the documentation of the version control system for details.

如果您从 Dired 缓冲区调用C-x v =或(请参阅Dired,目录编辑器),则当前行列出的文件将被视为当前 VC 文件集。 VC 文件集还可以包含多个标记文件。 C-u C-x v =

If you invoke C-x v = or C-u C-x v = from a Dired buffer (see Dired, the Directory Editor), the file listed on the current line is treated as the current VC fileset. The VC fileset can also include several marked files.

M-x vc-ediff工作方式与 类似C-x v =,只是它使用 Ediff 会话。请参阅Ediff 手册中的Ediff

M-x vc-ediff works like C-x v =, except that it uses an Ediff session. See Ediff in The Ediff Manual.

C-x v D( vc-root-diff) 与 类似C-x v =,但它显示整个当前工作树(即包含当前 VC 文件集的工作树)中的更改。如果从 Dired 缓冲区调用此命令,它将应用于包含该目录的工作树。

C-x v D (vc-root-diff) is similar to C-x v =, but it displays the changes in the entire current working tree (i.e., the working tree containing the current VC fileset). If you invoke this command from a Dired buffer, it applies to the working tree containing the directory.

要比较整个树的两个任意修订版,请 vc-root-diff使用前缀参数进行调用:C-u C-x v D。这会提示输入两个修订 ID(请参阅版本控制的概念),并显示整个版本控制目录树的这些版本之间的差异(RCS、SCCS、CVS 和 SRC 不支持此功能)。

To compare two arbitrary revisions of the whole trees, call vc-root-diff with a prefix argument: C-u C-x v D. This prompts for two revision IDs (see Concepts of Version Control), and displays a diff between those versions of the entire version-controlled directory trees (RCS, SCCS, CVS, and SRC do not support this feature).

您可以自定义用于 生成差异diff的选项。使用的选项按顺序取自变量 、和 (请参阅比较文件)中的第一个非值。这里, 后端代表相关的版本控制系统,例如Bazaar。由于意味着检查序列中的下一个变量,因此前两个变量中的任何一个都可以使用该值来表示根本没有切换。大多数 变量默认为,但有些默认为;这些用于版本控制系统,其实现不接受常见的 diff 选项,例如 Subversion。 C-x v =C-x v Dnilvc-backend-diff-switchesvc-diff-switchesdiff-switchesbzrniltvc-backend-diff-switchesniltdiff

You can customize the diff options that C-x v = and C-x v D use for generating diffs. The options used are taken from the first non-nil value amongst the variables vc-backend-diff-switches, vc-diff-switches, and diff-switches (see Comparing Files), in that order. Here, backend stands for the relevant version control system, e.g., bzr for Bazaar. Since nil means to check the next variable in the sequence, either of the first two may use the value t to mean no switches at all. Most of the vc-backend-diff-switches variables default to nil, but some default to t; these are for version control systems whose diff implementations do not accept common diff options, such as Subversion.

要直接检查文件的旧版本,请访问工作文件并键入 ( )。这将检索与revision相对应的文件版本,并将其保存到 C-x v ~ revision RETvc-revision-other-window文件名.~修订版~,并在单独的窗口中访问它。

To directly examine an older version of a file, visit the work file and type C-x v ~ revision RET (vc-revision-other-window). This retrieves the file version corresponding to revision, saves it to filename.~revision~, and visits it in a separate window.

许多版本控制系统允许您通过键入( )查看 带有每行修订信息注释的文件。这将创建一个新的“注释”缓冲区,显示文件的文本,每行都用颜色显示它有多旧。红色文本是新的,蓝色是旧的,中间颜色表示中间年龄。默认情况下,颜色在整个年龄范围内缩放,最旧的更改为蓝色,最新的更改为红色。如果变量 为 non- ,则表示每行年龄的颜色将应用于背景颜色,使前景色保持默认颜色。 C-x v gvc-annotatevc-annotate-background-modenil

Many version control systems allow you to view files annotated with per-line revision information, by typing C-x v g (vc-annotate). This creates a new “annotate” buffer displaying the file’s text, with each line colored to show how old it is. Red text is new, blue is old, and intermediate colors indicate intermediate ages. By default, the color is scaled over the full range of ages, such that the oldest changes are blue, and the newest changes are red. If the variable vc-annotate-background-mode is non-nil, the colors expressing the age of each line are applied to the background color, leaving the foreground at its default color.

您可以 通过自定义和 来自定义使用的annotate选项。它们的功能与上面描述的和类似 。 C-x v gvc-backend-annotate-switchesvc-annotate-switchesvc-backend-diff-switchesvc-diff-switches

You can customize the annotate options that C-x v g uses by customizing vc-backend-annotate-switches and vc-annotate-switches. They function similarly to vc-backend-diff-switches and vc-diff-switches, described above.

当您为 提供前缀参数时C-x v g,Emacs 使用迷你缓冲区读取两个参数:要显示和注释的修订版本(而不是当前文件内容),以及颜色范围应覆盖的时间跨度(以天为单位)。

When you give a prefix argument to C-x v g, Emacs reads two arguments using the minibuffer: the revision to display and annotate (instead of the current file contents), and the time span in days the color range should cover.

从“注释”缓冲区中,可以从“VC注释' 菜单。在此缓冲区中,您还可以使用以下键来浏览过去修订的注释、查看差异或查看日志条目:

From the “annotate” buffer, these and other color scaling options are available from the ‘VC-Annotate’ menu. In this buffer, you can also use the following keys to browse the annotations of past revisions, view diffs, or view log entries:

p
p

注释前一修订版,即当前注释修订版之前的修订版。数字前缀参数是重复计数,因此 C-u 10 p会返回 10 个修订。

Annotate the previous revision, i.e., the revision before the one currently annotated. A numeric prefix argument is a repeat count, so C-u 10 p would take you back 10 revisions.

n
n

注释下一个修订版,即当前注释修订版之后的修订版。数字前缀参数是重复计数。

Annotate the next revision, i.e., the revision after the one currently annotated. A numeric prefix argument is a repeat count.

j
j

注释当前行指示的修订。

Annotate the revision indicated by the current line.

a
a

在当前行指示的版本之前注释修订版本。这对于查看当前行发生更改之前文件所处的状态很有用。

Annotate the revision before the one indicated by the current line. This is useful to see the state the file was in before the change on the current line was made.

f
f

在缓冲区中显示当前行指示的文件修订版本。

Show in a buffer the file revision indicated by the current line.

d
d

显示当前行的修订版与上一修订版之间的差异。这对于查看文件中当前行的修订版实际更改的内容很有用。

Display the diff between the current line’s revision and the previous revision. This is useful to see what the current line’s revision actually changed in the file.

D
D

显示变更集中所有文件的当前行修订版与上一修订版之间的差异(对于支持变更集的 VC 系统)。这对于查看树中当前行的修订版实际更改的内容很有用。

Display the diff between the current line’s revision and the previous revision for all files in the changeset (for VC systems that support changesets). This is useful to see what the current line’s revision actually changed in the tree.

l
l

显示当前行的修订日志。这对于查看作者对当前行修订版本的更改的描述很有用。

Show the log of the current line’s revision. This is useful to see the author’s description of the changes in the revision on the current line.

w
w

对工作修订版(您正在编辑的修订版)进行注释。如果您使用 pn浏览其他版本,请使用此键返回到您的工作版本。

Annotate the working revision—the one you are editing. If you used p and n to browse to other revisions, use this key to return to your working revision.

v
v

切换注释可见性。这对于仅查看文件内容而不用分心注释非常有用。

Toggle the annotation visibility. This is useful for looking just at the file contents without distraction from the annotations.


29.1.7 VC 变更日志

29.1.7 VC Change Log

C-x v l
C-x v l

显示当前文件集的更改历史记录 ( vc-print-log)。

Display the change history for the current fileset (vc-print-log).

C-x v L
C-x v L

显示当前存储库的更改历史记录 ( vc-print-root-log)。

Display the change history for the current repository (vc-print-root-log).

C-x v b l
C-x v b l

显示另一个分支的更改历史记录 ( vc-print-branch-log)。

Display the change history for another branch (vc-print-branch-log).

C-x v I
C-x v I

显示“拉”操作将检索的更改 ( vc-log-incoming)。

Display the changes that a “pull” operation will retrieve (vc-log-incoming).

C-x v O
C-x v O

显示下一次“推送”操作将发送的更改 ( vc-log-outgoing)。

Display the changes that will be sent by the next “push” operation (vc-log-outgoing).

C-x v h
C-x v h

显示当前缓冲区 ( ) 访问的文件区域中所做更改的历史记录vc-region-history

Display the history of changes made in the region of file visited by the current buffer (vc-region-history).

M-x vc-log-search RET
M-x vc-log-search RET

搜索指定模式的更改历史记录。

Search the change history for a specified pattern.

C-x v l( vc-print-log) 显示名为的缓冲区 *vc-更改日志*,以长格式显示对当前文件集所做的更改历史记录,包括谁进行了更改、日期以及每次更改的日志条目(这些日志条目与您通过*vc-日志*缓冲;请参阅日志条目缓冲区的功能)。当从访问文件的缓冲区调用时,当前文件集由该单个文件组成,并指向显示的 *vc-更改日志*缓冲区以该文件的修订版本为中心。当从 VC 目录缓冲区(请参阅VC 目录模式)或 Dired 缓冲区(请参阅Dired,目录编辑器)调用时,文件集由所有标记的文件组成,默认为目录缓冲区中当前行显示的文件,如果没有标记任何文件。

C-x v l (vc-print-log) displays a buffer named *vc-change-log*, showing the history of changes made to the current fileset in the long form, including who made the changes, the dates, and the log entry for each change (these are the same log entries you would enter via the *vc-log* buffer; see Features of the Log Entry Buffer). When invoked from a buffer visiting a file, the current fileset consists of that single file, and point in the displayed *vc-change-log* buffer is centered at the revision of that file. When invoked from a VC Directory buffer (see VC Directory Mode) or from a Dired buffer (see Dired, the Directory Editor), the fileset consists of all the marked files, defaulting to the file shown on the current line in the directory buffer if no file is marked.

如果文件集包含一个或多个目录,则结果 *vc-更改日志*缓冲区显示一小段更改日志(每个更改一行),如果 VC 后端支持的话;否则它会以长格式显示日志。

If the fileset includes one or more directories, the resulting *vc-change-log* buffer shows a short log of changes (one line for each change), if the VC backend supports that; otherwise it shows the log in the long form.

使用前缀参数,该命令会提示修订版在*vc-更改日志*缓冲区和要显示的最大修订数量。

With a prefix argument, the command prompts for the revision to center on in the *vc-change-log* buffer and for the maximum number of revisions to display.

C-x v L( vc-print-root-log) 显示 *vc-更改日志*显示整个版本控制目录树的历史记录的缓冲区(RCS、SCCS、CVS 和 SRC 不支持此功能)。使用前缀参数,该命令会提示输入要显示的最大修订版本数。数字前缀参数指定不提示的最大修订次数。当数字前缀参数为 1 时(如或 中),该命令会提示输入修订 ID,并显示该修订的日志条目及其引入的更改(差异)。 (一些功能较差的版本控制系统,例如 RCS 和 CVS,没有命令来显示修订日志及其差异;对于它们来说,该命令仅显示日志条目,您可以通过键入或 来请求显示差异,见下文。) C-1 C-x v LC-u 1 C-x v LdD

C-x v L (vc-print-root-log) displays a *vc-change-log* buffer showing the history of the entire version-controlled directory tree (RCS, SCCS, CVS, and SRC do not support this feature). With a prefix argument, the command prompts for the maximum number of revisions to display. A numeric prefix argument specifies the maximum number of revisions without prompting. When the numeric prefix argument is 1, as in C-1 C-x v L or C-u 1 C-x v L, the command prompts for the revision ID, and displays the log entry of that revision together with the changes (diffs) it introduced. (Some less capable version control systems, such as RCS and CVS, don’t have commands to show a revision log with its diffs; for them the command displays only the log entry, and you can request to show the diffs by typing d or D, see below.)

历史C-x v L记录以紧凑的形式显示,通常仅显示每个日志条目的第一行。但是 ,您可以 RETlog-view-toggle-entry-display*vc-更改日志*缓冲区以显示当时修订的整个日志条目。一秒钟RET又把它隐藏起来。

The C-x v L history is shown in a compact form, usually showing only the first line of each log entry. However, you can type RET (log-view-toggle-entry-display) in the *vc-change-log* buffer to reveal the entire log entry for the revision at point. A second RET hides it again.

C-x v b l branch-name RET( vc-print-branch-log) 显示*vc-更改日志*buffer 显示版本控制目录树的历史记录,与此类似vc-print-root-log,但它显示当前分支以外的分支的历史记录;它提示要显示历史记录的分支。

C-x v b l branch-name RET (vc-print-branch-log) displays a *vc-change-log* buffer showing the history of the version-controlled directory tree, like vc-print-root-log does, but it shows the history of a branch other than the current one; it prompts for the branch whose history to display.

在分散版本控制系统上,C-x v I ( vc-log-incoming) 命令会显示一个日志缓冲区,其中显示下次运行版本控制系统的 pull 命令以从另一个远程位置获取新修订时将应用的更改(请参阅将更改拉入/推送到/来自分支机构)。根据版本控制系统的定义,另一个远程位置是从中提取更改的默认位置;使用前缀参数,vc-log-incoming提示输入特定的远程位置。同样,C-x v O ( vc-log-outgoing) 显示下次运行推送命令时将发送到另一个远程位置的更改;使用前缀参数,它会提示特定的目的地,在某些版本控制系统的情况下可以是分支名称。

On a decentralized version control system, the C-x v I (vc-log-incoming) command displays a log buffer showing the changes that will be applied, the next time you run the version control system’s pull command to get new revisions from another remote location (see Pulling/Pushing Changes into/from a Branch). This other remote location is the default one from which changes are pulled, as defined by the version control system; with a prefix argument, vc-log-incoming prompts for a specific remote location. Similarly, C-x v O (vc-log-outgoing) shows the changes that will be sent to another remote location, the next time you run the push command; with a prefix argument, it prompts for a specific destination that in case of some version control system can be a branch name.

在里面*vc-更改日志*缓冲区中,您可以使用以下键在修订日志和文件日志之间移动,并检查和比较过去的修订(请参阅检查和比较旧修订):

In the *vc-change-log* buffer, you can use the following keys to move between the logs of revisions and of files, and to examine and compare past revisions (see Examining And Comparing Old Revisions):

p
p

移至上一个修订条目。 (日志缓冲区中的修订条目通常按时间倒序排列,因此前一个修订项通常对应于较新的修订版。)数字前缀参数是重复计数。

Move to the previous revision entry. (Revision entries in the log buffer are usually in reverse-chronological order, so the previous revision-item usually corresponds to a newer revision.) A numeric prefix argument is a repeat count.

n
n

移至下一个修订条目。数字前缀参数是重复计数。

Move to the next revision entry. A numeric prefix argument is a repeat count.

a
a

在当前行注释修订(请参阅检查和比较旧修订)。

Annotate the revision on the current line (see Examining And Comparing Old Revisions).

e
e

修改此时显示的变更注释。请注意,并非所有 VC 系统都支持修改更改注释。

Modify the change comment displayed at point. Note that not all VC systems support modifying change comments.

f
f

访问当前行指示的修订版本。

Visit the revision indicated at the current line.

d
d

显示特定文件的当前版本与下一个早期版本之间的差异。

Display a diff between the revision at point and the next earlier revision, for the specific file.

D
D

显示当前版本与下一个早期版本之间的变更集差异。这显示了该修订版中对所有文件所做的更改。

Display the changeset diff between the revision at point and the next earlier revision. This shows the changes to all files made in that revision.

RET
RET

在紧凑型日志缓冲区(例如,由C-x v L)创建的日志缓冲区中,在显示和隐藏当前修订的完整日志条目之间切换。

In a compact-style log buffer (e.g., the one created by C-x v L), toggle between showing and hiding the full log entry for the revision at point.

因为获取许多日志条目可能会很慢, *vc-更改日志*buffer 默认显示不超过 2000 个修订。变量vc-log-show-limit指定这个限制;如果将该值设置为零,则会消除限制。您还可以增加现有版本中显示的修订数量 *vc-更改日志*通过单击 ' 进行缓冲显示 2X 条目' 或者 '显示无限条目' 按钮位于缓冲区末尾。但是,RCS、SCCS、CVS 和 SRC 不支持此功能。

Because fetching many log entries can be slow, the *vc-change-log* buffer displays no more than 2000 revisions by default. The variable vc-log-show-limit specifies this limit; if you set the value to zero, that removes the limit. You can also increase the number of revisions shown in an existing *vc-change-log* buffer by clicking on the ‘Show 2X entries’ or ‘Show unlimited entries’ buttons at the end of the buffer. However, RCS, SCCS, CVS, and SRC do not support this feature.

命令提供了检查更改历史记录的一个有用变体 vc-region-history(默认绑定到C-x v h),该命令显示*VC历史*buffer 包含当前缓冲区文件区域中点和标记之间所做更改的历史记录(请参阅标记和区域)。更改历史记录包括提交日志消息以及 Diff 格式的更改本身。

A useful variant of examining history of changes is provided by the command vc-region-history (by default bound to C-x v h), which shows a *VC-history* buffer with the history of changes made in the region of the current buffer’s file between point and the mark (see The Mark and the Region). The history of changes includes the commit log messages and also the changes themselves in the Diff format.

在当前缓冲区中标记您感兴趣的更改区域后调用此命令。在里面*VC历史*缓冲区它弹出,您可以使用所有可用的命令 *vc-更改日志*上面描述的 buffer,以及 Diff 模式定义的命令(参见Diff 模式)。

Invoke this command after marking in the current buffer the region in whose changes you are interested. In the *VC-history* buffer it pops up, you can use all of the commands available in the *vc-change-log* buffer described above, and also the commands defined by Diff mode (see Diff Mode).

此命令当前仅适用于 Git 和 Mercurial (hg)。

This command is currently available only with Git and Mercurial (hg).

该命令vc-log-search允许在更改日志中搜索模式。它提示输入模式(正则表达式),并显示更改历史记录中日志消息与该模式匹配的所有条目。当使用前缀参数调用时,该命令还将提示为此目的运行特定的 VCS shell 命令。

The command vc-log-search allows searching for a pattern in the log of changes. It prompts for a pattern (a regular expression), and displays all entries in the change history whose log messages match the pattern. When invoked with a prefix argument, the command will also prompt for a specific VCS shell command to run for this purpose.


29.1.8 撤消版本控制操作

29.1.8 Undoing Version Control Actions

C-x v u
C-x v u

将当前 VC 文件集中的工作文件恢复到最新版本 ( vc-revert)。

Revert the work file(s) in the current VC fileset to the last revision (vc-revert).

如果要放弃对当前 VC 文件集所做的所有更改,请键入C-x v u( vc-revert)。这将要求您在放弃更改之前进行确认。如果您同意,文件集将被恢复。

If you want to discard all the changes you have made to the current VC fileset, type C-x v u (vc-revert). This will ask you for confirmation before discarding the changes. If you agree, the fileset is reverted.

如果vc-revert-show-diff是非- nil,此命令将显示工作文件和您开始编辑的修订版本之间的差异。之后,差异缓冲区将被终止(如果该变量为kill),或者缓冲区将被埋葬(任何其他非nil值)。如果您不想C-x v u显示差异,请将此变量设置为nil(您仍然可以直接使用查看差异C-x v =;请参阅检查和比较旧版本)。

If vc-revert-show-diff is non-nil, this command will show you a diff between the work file(s) and the revision from which you started editing. Afterwards, the diff buffer will either be killed (if this variable is kill), or the buffer will be buried (any other non-nil value). If you don’t want C-x v u to show a diff, set this variable to nil (you can still view the diff directly with C-x v =; see Examining And Comparing Old Revisions).

在基于锁定的版本控制系统上,C-x v u使文件保持解锁状态;您必须再次锁定才能继续编辑。C-x v u如果您锁定文件然后决定不更改它, 您还可以使用它 来解锁文件。

On locking-based version control systems, C-x v u leaves files unlocked; you must lock again to resume editing. You can also use C-x v u to unlock a file if you lock it and then decide not to change it.


29.1.9 忽略版本控制文件

29.1.9 Ignore Version Control Files

C-x v G
C-x v G

忽略当前版本控制系统下的文件。 ( vc-ignore)。

Ignore a file under current version control system. (vc-ignore).

许多源代码树包含一些不需要版本控制的文件,例如编辑器备份、对象或字节码文件以及构建的程序。您可以简单地不添加它们,但它们总是会以未知文件的形式出现。您还可以通过将这些文件添加到树顶部的忽略文件中来告诉版本控制系统忽略这些文件。 C-x v G( vc-ignore) 可以帮助您做到这一点。当使用前缀参数调用时,您可以从忽略文件列表中删除文件。

Many source trees contain some files that do not need to be versioned, such as editor backups, object or bytecode files, and built programs. You can simply not add them, but then they’ll always crop up as unknown files. You can also tell the version control system to ignore these files by adding them to the ignore file at the top of the tree. C-x v G (vc-ignore) can help you do this. When called with a prefix argument, you can remove a file from the ignored file list.


29.1.10 VC 目录模式

29.1.10 VC Directory Mode

VC目录缓冲区是一个专门的缓冲区,用于查看目录树中文件的版本控制状态,并对这些文件执行版本控制操作。特别是,它用于为要 C-x v v执行的命令指定多文件 VC 文件集(请参阅VC 目录命令)。

The VC Directory buffer is a specialized buffer for viewing the version control statuses of the files in a directory tree, and performing version control operations on those files. In particular, it is used to specify multi-file VC filesets for commands like C-x v v to act on (see VC Directory Commands).

要使用 VC 目录缓冲区,请键入C-x v d( vc-dir)。这将使用微型缓冲区读取目录名称,并切换到该目录的 VC Directory 缓冲区。默认情况下,缓冲区命名为 *vc-dir*。其内容在VC Directory Buffer中进行了描述。

To use the VC Directory buffer, type C-x v d (vc-dir). This reads a directory’s name using the minibuffer, and switches to a VC Directory buffer for that directory. By default, the buffer is named *vc-dir*. Its contents are described in The VC Directory Buffer.

vc-dir命令自动检测指定目录中要使用的版本控制系统。如果目录中使用多个系统,则应使用前缀参数 ; 调用该命令C-u C-x v d。这会提示 VC 目录缓冲区应使用的版本控制系统。

The vc-dir command automatically detects the version control system to be used in the specified directory. In the event that more than one system is being used in the directory, you should invoke the command with a prefix argument, C-u C-x v d; this prompts for the version control system which the VC Directory buffer should use.

除了 VC Directory 缓冲区之外,Emacs 还有一个类似的工具,称为 PCL-CVS,专门用于 CVS。请参阅PCL-CVS — CVS 的 Emacs 前端的关于 PCL-CVS

In addition to the VC Directory buffer, Emacs has a similar facility called PCL-CVS which is specialized for CVS. See About PCL-CVS in PCL-CVS—The Emacs Front-End to CVS.

您还可以从 Dired 缓冲区调用 VC 命令(请参阅Dired,目录编辑器)。在这种情况下,您调用的任何 VC 命令都会将标记的文件视为当前文件集(请参阅版本控制下的基本编辑),如果没有标记文件,则默认为当前行上的文件。

You can also invoke VC commands from Dired buffers (see Dired, the Directory Editor). In that case, any VC command you invoke considers the marked files as the current fileset (see Basic Editing under Version Control), defaulting to the file on the current line if no files are marked.


29.1.10.1 VC 目录缓冲区

29.1.10.1 The VC Directory Buffer

VC 目录缓冲区包含版本控制文件及其版本控制状态的列表。它列出当前目录(调用时指定的目录C-x v d)及其子目录中的文件,但仅列出那些具有值得注意状态的文件。最新的文件(即与存储库中的文件相同)将被省略。如果子目录中的所有文件都是最新的,则也不会列出该子目录。作为例外,如果文件由于 VC 命令的直接结果而变为最新,则会列出该文件。

The VC Directory buffer contains a list of version-controlled files and their version control statuses. It lists files in the current directory (the one specified when you called C-x v d) and its subdirectories, but only those with a noteworthy status. Files that are up-to-date (i.e., the same as in the repository) are omitted. If all the files in a subdirectory are up-to-date, the subdirectory is not listed either. As an exception, if a file has become up-to-date as a direct result of a VC command, it is listed.

以下是 VC 目录缓冲区列表的示例:

Here is an example of a VC Directory buffer listing:

                     ./
    编辑configure.ac
* 添加了自述文件
    未注册的 temp.txt
                     源代码/
* 编辑 src/main.c
                     ./
    edited           configure.ac
*   added            README
    unregistered     temp.txt
                     src/
*   edited           src/main.c

两个工作文件已修改但未提交: 配置文件在当前目录中,并且主程序在里面 源代码/子目录。该文件名为自述文件已添加但尚未提交,同时临时文件.txt不受版本控制(请参阅注册文件以进行版本控制)。

Two work files have been modified but not committed: configure.ac in the current directory, and main.c in the src/ subdirectory. The file named README has been added but is not yet committed, while temp.txt is not under version control (see Registering a File for Version Control).

这 '*' 条目旁边的字符自述文件src/main.c指示用户已将这些文件标记为当前 VC 文件集(请参阅VC 目录命令)。

The ‘*’ characters next to the entries for README and src/main.c indicate that the user has marked these files as the current VC fileset (see VC Directory Commands).

上面的示例是 Bazaar、Git 或 Mercurial 等去中心化版本控制系统的典型示例。其他系统可以显示其他状态。例如,CVS 显示 '需求更新' 状态(如果存储库有尚未应用于工作文件的更改)。 RCS 和 SCCS 显示锁定文件的用户名作为其状态。

The above example is typical for a decentralized version control system like Bazaar, Git, or Mercurial. Other systems can show other statuses. For instance, CVS shows the ‘needs-update’ status if the repository has changes that have not been applied to the work file. RCS and SCCS show the name of the user locking a file as its status.

在 CVS 上,该vc-dir命令通常会联系存储库(可能位于远程计算机上)以检查更新。如果您将变量更改vc-cvs-stay-localnil(请参阅CVS 特定的选项),则 Emacs 在生成 VC 目录缓冲区时将避免联系远程存储库(必要时(例如,在进行提交时)仍会联系它)。如果您脱机工作或网络速度较慢,这可能是理想的选择。

On CVS, the vc-dir command normally contacts the repository, which may be on a remote machine, to check for updates. If you change the variable vc-cvs-stay-local to nil (see Options specific for CVS), then Emacs avoids contacting a remote repository when generating the VC Directory buffer (it will still contact it when necessary, e.g., when doing a commit). This may be desirable if you are working offline or the network is slow.

VC 目录缓冲区忽略变量中列出的子目录 vc-directory-exclusion-list。它的默认值包含版本控制系统内部使用的目录。

The VC Directory buffer omits subdirectories listed in the variable vc-directory-exclusion-list. Its default value contains directories that are used internally by version control systems.


29.1.10.2 VC 目录命令

29.1.10.2 VC Directory Commands

Emacs 提供了几个用于导航 VC 目录缓冲区以及将文件标记为属于当前 VC 文件集的命令。

Emacs provides several commands for navigating the VC Directory buffer, and for marking files as belonging to the current VC fileset.

n
n
SPC
SPC

将点移至下一个条目 ( vc-dir-next-line)。

Move point to the next entry (vc-dir-next-line).

p
p

将点移至上一个条目 ( vc-dir-previous-line)。

Move point to the previous entry (vc-dir-previous-line).

TAB
TAB

移至下一个目录条目 ( vc-dir-next-directory)。

Move to the next directory entry (vc-dir-next-directory).

S-TAB
S-TAB

移至上一个目录条目 ( vc-dir-previous-directory)。

Move to the previous directory entry (vc-dir-previous-directory).

RET
RET
f
f

访问当前行 ( vc-dir-find-file) 列出的文件或目录。

Visit the file or directory listed on the current line (vc-dir-find-file).

o
o

vc-dir-find-file-other-window在单独的窗口 ( ) 中访问当前行上的文件或目录。

Visit the file or directory on the current line, in a separate window (vc-dir-find-file-other-window).

m
m

标记当前行 ( ) 上的文件或目录vc-dir-mark,将其放入当前 VC 文件集中。如果该区域处于活动状态,则标记该区域中的所有文件。

如果文件已位于标记目录或其子目录之一中,则无法使用此命令对其进行标记。同样,如果标记了树中的任何文件,则无法使用此命令标记目录。

Mark the file or directory on the current line (vc-dir-mark), putting it in the current VC fileset. If the region is active, mark all files in the region.

A file cannot be marked with this command if it is already in a marked directory, or one of its subdirectories. Similarly, a directory cannot be marked with this command if any file in its tree is marked.

M
M

如果点位于文件条目上,则将所有文件标记为相同状态;如果点位于目录条目上,则标记该目录树中的所有文件 ( vc-dir-mark-all-files)。使用前缀参数,标记所有列出的文件和目录。

If point is on a file entry, mark all files with the same status; if point is on a directory entry, mark all files in that directory tree (vc-dir-mark-all-files). With a prefix argument, mark all listed files and directories.

% m
% m
* %
* %

您可以使用此命令通过 regexp ( ) 来标记文件vc-dir-mark-by-regexp。如果给定前缀,则取消标记文件。

You can use this command to mark files by regexp (vc-dir-mark-by-regexp). If given a prefix, unmark files instead.

* r
* r

您可以使用此命令来标记处于注册状态之一的文件,包括编辑、添加或删除。 ( vc-dir-mark-registered-files)。

You can use this command to mark files that are in one of registered states, including edited, added or removed. (vc-dir-mark-registered-files).

G
G

将点下的文件添加到 VC 应忽略的文件列表中 ( vc-dir-ignore)。例如,如果 VC 是 Git,它将将此文件附加到.gitignore文件。如果给定前缀,请对所有标记的文件执行此操作。

Add the file under point to the list of files that the VC should ignore (vc-dir-ignore). For instance, if the VC is Git, it will append this file to the .gitignore file. If given a prefix, do this with all the marked files.

q
q

退出 VC 目录缓冲区,并将其埋葬 ( quit-window)。

Quit the VC Directory buffer, and bury it (quit-window).

u
u

取消标记当前行上的文件或目录。如果该区域处于活动状态,请取消标记该区域中的所有文件 ( vc-dir-unmark)。

Unmark the file or directory on the current line. If the region is active, unmark all the files in the region (vc-dir-unmark).

U
U

如果点位于文件条目上,则取消标记具有相同状态的所有文件;如果点位于目录条目上,则取消标记该目录树中的所有文件 ( vc-dir-unmark-all-files)。使用前缀参数,取消标记所有文件和目录。

If point is on a file entry, unmark all files with the same status; if point is on a directory entry, unmark all files in that directory tree (vc-dir-unmark-all-files). With a prefix argument, unmark all files and directories.

x
x

用 ' 隐藏文件最新' 或者 '被忽略' 地位 (vc-dir-hide-up-to-date)。使用前缀参数,隐藏其状态为当前项目状态的项目。

Hide files with ‘up-to-date’ or ‘ignored’ status (vc-dir-hide-up-to-date). With a prefix argument, hide items whose state is that of the item at point.

m在 VC 目录缓冲区中时,用( vc-dir-mark) 或M( )标记的所有文件 vc-dir-mark-all-files都在当前 VC 文件集中。如果用 标记目录条目 m,则该目录树中列出的所有文件都位于当前 VC 文件集中。属于当前 VC 文件集的文件和目录用“*' VC 目录缓冲区中的字符,位于其 VC 状态旁边。通过这种方式,您可以设置一个由 VC 命令操作的多文件 VC 文件集,例如 C-x v v(请参阅版本控制下的基本编辑)、C-x v = (请参阅检查和比较旧版本)和C-x v u(请参阅撤消版本控制操作)。

While in the VC Directory buffer, all the files that you mark with m (vc-dir-mark) or M (vc-dir-mark-all-files) are in the current VC fileset. If you mark a directory entry with m, all the listed files in that directory tree are in the current VC fileset. The files and directories that belong to the current VC fileset are indicated with a ‘*’ character in the VC Directory buffer, next to their VC status. In this way, you can set up a multi-file VC fileset to be acted on by VC commands like C-x v v (see Basic Editing under Version Control), C-x v = (see Examining And Comparing Old Revisions), and C-x v u (see Undoing Version Control Actions).

VC 目录缓冲区还为 VC 命令定义了一些带有前缀的单键快捷键C-x v=+liDLGIOv

The VC Directory buffer also defines some single-key shortcuts for VC commands with the C-x v prefix: =, +, l, i, D, L, G, I, O, and v.

例如,您可以通过打开 VC 目录缓冲区来提交一组已编辑的文件,其中文件以“已编辑' 地位;标记文件;并输入vC-x v v ( vc-next-action)。如果版本控制系统是基于变更集的,Emacs 将在单个修订中提交文件。

For example, you can commit a set of edited files by opening a VC Directory buffer, where the files are listed with the ‘edited’ status; marking the files; and typing v or C-x v v (vc-next-action). If the version control system is changeset-based, Emacs will commit the files in a single revision.

在 VC 目录缓冲区中时,您还可以使用以下命令对当前 VC 文件集执行搜索和替换:

While in the VC Directory buffer, you can also perform search and replace on the current VC fileset, with the following commands:

S
S

搜索文件集 ( vc-dir-search)。

Search the fileset (vc-dir-search).

Q
Q

对文件集执行正则表达式查询替换 ( vc-dir-query-replace-regexp)。

Do a regular expression query replace on the fileset (vc-dir-query-replace-regexp).

M-s a C-s
M-s a C-s

对文件集进行增量搜索 ( vc-dir-isearch)。

Do an incremental search on the fileset (vc-dir-isearch).

M-s a C-M-s
M-s a C-M-s

对文件集执行增量正则表达式搜索 ( vc-dir-isearch-regexp)。

Do an incremental regular expression search on the fileset (vc-dir-isearch-regexp).

除了作用于多个文件之外,这些命令的行为与单缓冲区命令非常相似(请参阅搜索和替换)。

Apart from acting on multiple files, these commands behave much like their single-buffer counterparts (see Searching and Replacement).

VC Directory 缓冲区还定义了一些以前缀 开头的与分支相关的命令b

The VC Directory buffer additionally defines some branch-related commands starting with the prefix b:

b c
b c

创建一个新分支 ( vc-create-branch)。请参阅创建新分支

Create a new branch (vc-create-branch). See Creating New Branches.

b l
b l

提示输入分支名称并显示该分支的更改历史记录 ( vc-print-branch-log)。

Prompt for the name of a branch and display the change history of that branch (vc-print-branch-log).

b s
b s

切换到分支(vc-switch-branch)。请参阅在分支之间切换

Switch to a branch (vc-switch-branch). See Switching between Branches.

d
d

删除已标记的文件,如果没有标记则删除当前文件( )vc-dir-clean-delete)。这些文件在版本控制系统中不会被标记为已删除,因此此功能主要针对未注册的文件。

Delete the marked files, or the current file if no marks (vc-dir-clean-delete). The files will not be marked as deleted in the version control system, so this function is mostly useful for unregistered files.

上述命令也可以通过菜单栏以及通过调用的上下文菜单来使用mouse-2。此外,一些 VC 后端使用菜单来提供额外的后端特定命令。例如,Git 和 Bazaar 允许您操作储藏室架子 (这是暂时搁置未提交的更改并在稍后将其恢复的一种方法)。

The above commands are also available via the menu bar, and via a context menu invoked by mouse-2. Furthermore, some VC backends use the menu to provide extra backend-specific commands. For example, Git and Bazaar allow you to manipulate stashes and shelves (which are a way to temporarily put aside uncommitted changes, and bring them back at a later time).


29.1.11 版本控制分支

29.1.11 Version Control Branches

版本控制的用途之一是支持多个独立的开发线,称为分支。除其他外,分支可用于维护程序的单独稳定版本和开发版本,以及用于开发彼此隔离的不相关功能。

One use of version control is to support multiple independent lines of development, which are called branches. Amongst other things, branches can be used for maintaining separate stable and development versions of a program, and for developing unrelated features in isolation from one another.

目前VC对分支机构运营的支持相当有限。对于分散式版本控制系统,它提供了用 另一个分支的内容 更新一个分支的命令,以及合并对两个不同分支所做的更改的命令(请参阅合并分支)。对于集中式版本控制系统,它支持签出不同的分支并提交到新的或不同的分支。

VC’s support for branch operations is currently fairly limited. For decentralized version control systems, it provides commands for updating one branch with the contents of another, and for merging the changes made to two different branches (see Merging Branches). For centralized version control systems, it supports checking out different branches and committing into new or different branches.


29.1.11.1 分支间切换

29.1.11.1 Switching between Branches

各种版本控制系统在分支实现方式上存在差异,而这些差异并不能被VC完全掩盖。

The various version control systems differ in how branches are implemented, and these differences cannot be entirely concealed by VC.

在一些去中心化版本控制系统上,包括正常运行模式下的 Bazaar 和 Mercurial,每个分支都有自己的工作目录树,因此分支之间的切换只涉及目录的切换。在 Git 上,分支通常位于 同一目录中,分支之间的切换是使用命令完成的git checkout,该命令会更改工作树的内容以匹配您切换到的分支。 Bazaar 还支持并置分支,在这种情况下,该bzr switch命令将切换当前目录中的分支。使用 Subversion,您可以使用svn switch命令切换到另一个分支。对于 Mercurial,命令hg update用于切换到另一个分支。

On some decentralized version control systems, including Bazaar and Mercurial in its normal mode of operation, each branch has its own working directory tree, so switching between branches just involves switching directories. On Git, branches are normally co-located in the same directory, and switching between branches is done using the git checkout command, which changes the contents of the working tree to match the branch you switch to. Bazaar also supports co-located branches, in which case the bzr switch command will switch branches in the current directory. With Subversion, you switch to another branch using the svn switch command. With Mercurial, command hg update is used to switch to another branch.

VC中切换到当前目录下的另一个分支的命令是()。 C-x v b s branch-name RETvc-switch-branch

The VC command to switch to another branch in the current directory is C-x v b s branch-name RET (vc-switch-branch).

在集中式版本控制系统上,您还可以通过输入C-u C-x v v最新的工作文件(请参阅中的高级控制C-x v v)并输入另一个分支上的修订版本 ID 在分支之间进行切换。例如,在 CVS 上, 主干(开发的主线)上的修订通常具有 1.1、1.2、1.3 等形式的 ID,而从(例如)修订 1.2 创建的第一个分支的修订 ID 为 1.2.1.1、1.2 .1.2, ...,从修订版 1.2 创建的第二个分支的修订版 ID 为 1.2.2.1、1.2.2.2、...,依此类推。您还可以指定分支 ID,它是省略其最终组件(例如 1.2.1)的分支修订 ID,以切换到该分支上的最新修订。

On centralized version control systems, you can also switch between branches by typing C-u C-x v v in an up-to-date work file (see Advanced Control in C-x v v), and entering the revision ID for a revision on another branch. On CVS, for instance, revisions on the trunk (the main line of development) normally have IDs of the form 1.1, 1.2, 1.3, …, while the first branch created from (say) revision 1.2 has revision IDs 1.2.1.1, 1.2.1.2, …, the second branch created from revision 1.2 has revision IDs 1.2.2.1, 1.2.2.2, …, and so forth. You can also specify the branch ID, which is a branch revision ID omitting its final component (e.g., 1.2.1), to switch to the latest revision on that branch.

在基于锁定的系统上,切换到不同的分支也会解锁(写保护)工作树。

On a locking-based system, switching to a different branch also unlocks (write-protects) the working tree.

一旦您切换到某个分支,VC 命令将应用于该分支,直到您切换离开;例如,您提交的任何 VC 文件集都将提交到该特定分支。

Once you have switched to a branch, VC commands will apply to that branch until you switch away; for instance, any VC filesets that you commit will be committed to that specific branch.


29.1.11.2 将更改拉入分支或从分支中推送更改

29.1.11.2 Pulling/Pushing Changes into/from a Branch

C-x v P
C-x v P

使用分散的版本控制系统,使用当前分支本地提交的更改(也称为 推送更改)更新另一个存储库。集中式版本控制系统不存在这个概念

With a decentralized version control system, update another repository with locally-committed changes from the current branch (a.k.a. push changes). This concept does not exist for centralized version control systems

C-x v +
C-x v +

使用分散版本控制系统,通过从另一个存储库拉更改来更新本地存储库的当前分支。

使用集中版本控制系统,从存储库更新当前的 VC 文件集。

With a decentralized version control system, update the current branch of the local repository by pulling in changes from another repository.

With a centralized version control system, update the current VC fileset from the repository.

在分散版本控制系统上,命令C-x v P ( )使用当前分支本地提交的更改vc-push更新另一个位置(通常称为 上游存储库)。使用前缀参数,它会提示运行确切的版本控制命令,这使您可以指定将更改推送到何处;默认bzr push使用 Bazaar、git push Git 和hg pushMercurial。默认命令始终推送到版本控制系统从分支配置确定的默认位置中的存储库。

On a decentralized version control system, the command C-x v P (vc-push) updates another location, commonly known as the upstream repository, with locally-committed changes from the current branch. With a prefix argument, it prompts for the exact version control command to run, which lets you specify where to push changes; the default is bzr push with Bazaar, git push with Git, and hg push with Mercurial. The default commands always push to the repository in the default location determined by the version control system from your branch configuration.

在推送之前,您可以使用C-x v O( vc-log-outgoing) 查看要发送到上游的更改的日志缓冲区。请参阅VC 更改日志

Prior to pushing, you can use C-x v O (vc-log-outgoing) to view a log buffer of the changes to be sent upstream. See VC Change Log.

目前仅 Bazaar、Git 和 Mercurial 支持此命令。集中式版本控制系统不存在“推送”的概念,该操作是提交变更集的一部分,因此在集中式 VCS 上调用此命令会发出错误信号。当在 Bazaar绑定分支中尝试时,此命令还会发出错误信号 ,其中提交变更集会自动将更改推送到本地分支绑定到的远程存储库。

This command is currently supported only by Bazaar, Git, and Mercurial. The concept of “pushing” does not exist for centralized version control systems, where this operation is a part of committing a changeset, so invoking this command on a centralized VCS signals an error. This command also signals an error when attempted in a Bazaar bound branch, where committing a changeset automatically pushes the changes to the remote repository to which the local branch is bound.

使用分散版本控制系统,命令C-x v +( vc-pull) 会使用上游存储库中所做的更改来更新本地存储库的当前分支及其工作树。它通常用于更新远程分支的副本(也称为克隆)。如果您提供前缀参数,该命令会提示输入要使用的确切版本控制命令,这使您可以指定从何处提取更改。否则,它将从版本控制系统从分支配置确定的默认位置的存储库中提取。

With a decentralized version control system, the command C-x v + (vc-pull) updates the current branch of the local repository and it working tree with changes made in the upstream repository. It is typically used to update a copy (a.k.a. clone) of a remote branch. If you supply a prefix argument, the command prompts for the exact version control command to use, which lets you specify where to pull changes from. Otherwise, it pulls from the repository in the default location determined by the version control system from your branch configuration.

在去中心化版本控制系统中,C-x v +目前只有 Bazaar、Git 和 Mercurial 支持。对于 Bazaar,它bzr pull需要普通分支(从主分支拉取到镜像分支)和bzr update绑定分支(从中央存储库拉取)。使用 Git,它会调用 git pull从远程存储库获取更改并将其合并到当前分支中。使用 Mercurial,它会调用hg pull -u从默认远程存储库获取变更集并更新工作目录。

Amongst decentralized version control systems, C-x v + is currently supported only by Bazaar, Git, and Mercurial. With Bazaar, it calls bzr pull for ordinary branches (to pull from a master branch into a mirroring branch), and bzr update for a bound branch (to pull from a central repository). With Git, it calls git pull to fetch changes from a remote repository and merge it into the current branch. With Mercurial, it calls hg pull -u to fetch changesets from the default remote repository and update the working directory.

在拉取之前,您可以使用C-x v I( vc-log-incoming) 查看要应用的更改的日志缓冲区。请参阅VC 更改日志

Prior to pulling, you can use C-x v I (vc-log-incoming) to view a log buffer of the changes to be applied. See VC Change Log.

使用 CVS 等集中式版本控制系统,C-x v + 从存储库更新当前 VC 文件集。

With a centralized version control system like CVS, C-x v + updates the current VC fileset from the repository.


29.1.11.3 合并分支

29.1.11.3 Merging Branches

C-x v m
C-x v m

使用分散的版本控制系统,将另一个分支的更改合并到当前分支中。

使用集中版本控制系统,将另一个分支的更改合并到当前的 VC 文件集中。

With a decentralized version control system, merge changes from another branch into the current one.

With a centralized version control system, merge changes from another branch into the current VC fileset.

在开发分支时,您有时可能需要合并另一个分支中已进行的更改。这不是一个简单的操作,因为可能对两个分支进行了重叠和冲突的更改。

While developing a branch, you may sometimes need to merge in changes that have already been made in another branch. This is not a trivial operation, as overlapping and conflicting changes may have been made to the two branches.

使用分散版本控制系统,您可以使用命令C-x v m( vc-merge) 合并更改。对于 Bazaar,这会提示输入要传递给命令的确切参数bzr merge ,并在可能的情况下提供合理的默认值。对于 Git,这会提示输入要合并的分支的名称,并完成(基于当前存储库已知的分支名称)。对于 Mercurial,这会提示将参数传递给hg merge.运行合并命令的输出显示在单独的缓冲区中。

With a decentralized version control system, you merge changes with the command C-x v m (vc-merge). With Bazaar, this prompts for the exact arguments to pass to the bzr merge command, offering a sensible default if possible. With Git, this prompts for the name of a branch to merge from, with completion (based on the branch names known to the current repository). With Mercurial, this prompts for argument to pass to hg merge. The output from running the merge command is shown in a separate buffer.

使用像 CVS 这样的集中式版本控制系统,C-x v m 会提示输入分支 ID 或一对修订 ID(请参阅在分支之间切换);然后它会查找该分支中的更改或您指定的两个修订版之间的更改,并将这些更改合并到当前的 VC 文件集中。如果您只是RET在提示符下键入,Emacs 只会合并自您签出文件以来在同一分支上所做的任何更改。

With a centralized version control system like CVS, C-x v m prompts for a branch ID, or a pair of revision IDs (see Switching between Branches); then it finds the changes from that branch, or the changes between the two revisions you specified, and merges those changes into the current VC fileset. If you just type RET at the prompt, Emacs simply merges any changes that were made on the same branch since you checked the file out.

C-x v D执行合并后,仅修改工作树,您可以使用相关命令查看合并产生的更改 (请参阅检查和比较旧修订)。如果两个分支包含重叠的更改,则合并会产生 冲突;合并命令的输出中会出现警告,并且冲突标记会插入到每个受影响的工作文件中,围绕两组冲突的更改。然后,您必须通过编辑冲突的文件来解决冲突;默认情况下,Emacs 会将存在 VC 冲突的缓冲区放置在特殊的 Smerge 模式下,该模式提供了用于解决合并冲突的特殊命令。解决完冲突并保存已解决冲突的文件后,必须以通常的方式提交这些文件才能使合并生效(请参阅版本控制下的基本编辑)。

Immediately after performing a merge, only the working tree is modified, and you can review the changes produced by the merge with C-x v D and related commands (see Examining And Comparing Old Revisions). If the two branches contained overlapping changes, merging produces a conflict; a warning appears in the output of the merge command, and conflict markers are inserted into each affected work file, surrounding the two sets of conflicting changes. You must then resolve the conflict by editing the conflicted files; by default, Emacs will place buffers with VC conflicts in the special Smerge mode, which provides special commands for resolving the merge conflicts. Once you are done with resolving the conflicts and have saved the files with resolved conflicts, those files must be committed in the usual way for the merge to take effect (see Basic Editing under Version Control).


29.1.11.4 创建新分支

29.1.11.4 Creating New Branches

在 CVS 等集中式版本控制系统上,Emacs 支持创建新分支作为提交操作的一部分。提交修改后的 VC 文件集时,请键入C-u C-x v v(vc-next-action 并带有前缀参数;请参阅中的高级控制C-x v v)。然后 Emacs 会提示输入新修订版的修订 ID。您应该为从当前修订版开始的分支指定合适的分支 ID。例如,如果当前修订版本为 2.5,则分支 ID 应为 2.5.1、2.5.2 等,具体取决于此时现有分支的数量。

On centralized version control systems like CVS, Emacs supports creating new branches as part of a commit operation. When committing a modified VC fileset, type C-u C-x v v (vc-next-action with a prefix argument; see Advanced Control in C-x v v). Then Emacs prompts for a revision ID for the new revision. You should specify a suitable branch ID for a branch starting at the current revision. For example, if the current revision is 2.5, the branch ID should be 2.5.1, 2.5.2, and so on, depending on the number of existing branches at that point.

此过程不适用于 git 或 Mercurial 等分布式版本控制系统。对于这些系统,您应该使用命令 vc-create-branch( )。 C-x v b c branch-name RET

This procedure will not work for distributed version control systems like git or Mercurial. For those systems you should use the command vc-create-branch (C-x v b c branch-name RET) instead.

要在旧版本(不再是分支头部的版本)上创建新分支,请首先选择该版本(请参阅在分支之间切换)。然后,您的过程将有所不同,具体取决于您使用的是基于锁定还是基于合并的 VCS。

To create a new branch at an older revision (one that is no longer the head of a branch), first select that revision (see Switching between Branches). Your procedure will then differ depending on whether you are using a locking or merging-based VCS.

在锁定 VCS 上,您需要使用 C-x v v.当您锁定旧版本时,系统会要求您确认您确实打算创建一个新分支 - 如果您拒绝,您将有机会锁定最新版本。在基于合并的 VCS 上,您将跳过此步骤。

On a locking VCS, you will need to lock the old revision branch with C-x v v. You’ll be asked to confirm, when you lock the old revision, that you really mean to create a new branch—if you say no, you’ll be offered a chance to lock the latest revision instead. On a merging-based VCS you will skip this step.

然后进行更改并C-x v v再次键入以提交新修订。这会从选定的修订版本开始创建一个新分支。

Then make your changes and type C-x v v again to commit a new revision. This creates a new branch starting from the selected revision.

创建分支后,后续提交会在该分支上创建新的修订。要离开分支,您必须使用 显式选择不同的修订版本C-u C-x v v

After the branch is created, subsequent commits create new revisions on that branch. To leave the branch, you must explicitly select a different revision with C-u C-x v v.


29.1.12 VC 的其他命令和功能

29.1.12 Miscellaneous Commands and Features of VC

本节介绍 VC 不常用的功能。

This section explains the less-frequently-used features of VC.


29.1.12.1 更改日志和 VC

29.1.12.1 Change Logs and VC

如果您对带有 RCS 或 CVS 的程序使用变更日志文件(请参阅更改日志),您可以从以前提交的版本控制日志条目生成更改日志条目。

If you use RCS or CVS for a program with a ChangeLog file (see Change Logs), you can generate change log entries from the version control log entries of previous commits.

请注意,这仅适用于 RCS 或 CVS。在现代基于变更集的版本控制系统上,此过程尤其不正确,其中对变更日志文件通常会作为变更集的一部分提交。在这种情况下,您应该首先写入更改日志条目,然后将它们拉入“*vc-日志*' 提交时的缓冲区(请参阅日志条目缓冲区的功能)。

Note that this only works with RCS or CVS. This procedure would be particularly incorrect on a modern changeset-based version control system, where changes to the ChangeLog file would normally be committed as part of a changeset. In that case, you should write the change log entries first, then pull them into the ‘*vc-log*’ buffer when you commit (see Features of the Log Entry Buffer).

C-x v a
C-x v a

访问当前目录变更日志文件,并且对于该目录中的已注册文件,为自最近更改日志条目 ( vc-update-change-log) 以来提交的版本创建新条目。

Visit the current directory’s ChangeLog file and, for registered files in that directory, create new entries for versions committed since the most recent change log entry (vc-update-change-log).

C-u C-x v a
C-u C-x v a

如上所述,但仅查找当前缓冲区文件的条目。

As above, but only find entries for the current buffer’s file.

例如,假设第一行变更日志日期为 1999 年 4 月 10 日,此后唯一的登记入住是由纳撒尼尔·鲍迪奇 (Nathaniel Bowditch)rcs2log于 1999-05-22 记录条目 '忽略以“#”开头的日志消息。'。然后C-x v a插入这个 变更日志入口:

For example, suppose the first line of ChangeLog is dated 1999-04-10, and that the only check-in since then was by Nathaniel Bowditch to rcs2log on 1999-05-22 with log entry ‘Ignore log messages that start with '#'.’. Then C-x v a inserts this ChangeLog entry:

1999-05-22 纳撒尼尔·鲍迪奇 <nat@apn.org>

        * rcs2log:忽略以“#”开头的日志消息。
1999-05-22  Nathaniel Bowditch  <nat@apn.org>

        * rcs2log: Ignore log messages that start with '#'.

如果版本控制日志条目指定了函数名称(在行首的括号中),则会反映在 变更日志入口。例如,如果日志条目为vc.el 是 '(vc-do-command):检查呼叫进程状态。', 这 变更日志条目是:

If the version control log entry specifies a function name (in parenthesis at the beginning of a line), that is reflected in the ChangeLog entry. For example, if a log entry for vc.el is ‘(vc-do-command): Check call-process status.’, the ChangeLog entry is:

1999-05-06 纳撒尼尔·鲍迪奇 <nat@apn.org>

        * vc.el (vc-do-command):检查呼叫进程状态。
1999-05-06  Nathaniel Bowditch  <nat@apn.org>

        * vc.el (vc-do-command): Check call-process status.

C-x v a一次添加多个更改日志条目时,如果相关日志条目几乎同时由同一作者签入,则会将它们分组在一起。如果多个此类文件的日志条目都具有相同的文本,则会将它们合并为一个条目。

When C-x v a adds several change log entries at once, it groups related log entries together if they all are checked in by the same author at nearly the same time. If the log entries for several such files all have the same text, it coalesces them into a single entry.


29.1.12.2 删除和重命名版本控制文件

29.1.12.2 Deleting and Renaming Version-Controlled Files

M-x vc-delete-file
M-x vc-delete-file

提示输入文件名,从工作树中删除文件,并安排删除以供提交。

Prompt for a file name, delete the file from the working tree, and schedule the deletion for committing.

M-x vc-rename-file
M-x vc-rename-file

提示输入两个文件名(oldnew),在工作树中重命名它们,并安排重命名以供提交。 如果旧文件在 VC 下,则默认为当前缓冲区的文件 名

Prompt for two file names, old and new, rename them in the working tree, and schedule the renaming for committing. The old file defaults to the current buffer’s file name if it is under VC.

如果您想删除版本控制文件,请使用命令 M-x vc-delete-file。这会提示输入文件名,并通过版本控制系统将其删除。该文件将从工作树中删除,并在 VC 目录缓冲区中(请参阅VC 目录模式)显示为 '已删除' 地位。当您提交它时,删除就会在存储库中生效。

If you wish to delete a version-controlled file, use the command M-x vc-delete-file. This prompts for the file name, and deletes it via the version control system. The file is removed from the working tree, and in the VC Directory buffer (see VC Directory Mode), it is displayed with the ‘removed’ status. When you commit it, the deletion takes effect in the repository.

要重命名版本控制文件,请键入M-x vc-rename-file.这会提示输入两个参数:您要重命名的文件的名称和新名称;然后它通过版本控制系统执行重命名。重命名会立即在工作树中生效,并在提交重命名的文件时在存储库中生效。

To rename a version-controlled file, type M-x vc-rename-file. This prompts for two arguments: the name of the file you wish to rename, and the new name; then it performs the renaming via the version control system. The renaming takes effect immediately in the working tree, and takes effect in the repository when you commit the renamed file.

在内置支持重命名的现代版本控制系统上,重命名的文件保留原始文件的完整更改历史记录。在 CVS 和较旧的版本控制系统上,该 vc-rename-file命令实际上是通过以新名称创建旧文件的副本、注册它并删除旧文件来工作的。在这种情况下,不会保留更改历史记录。

On modern version control systems that have built-in support for renaming, the renamed file retains the full change history of the original file. On CVS and older version control systems, the vc-rename-file command actually works by creating a copy of the old file under the new name, registering it, and deleting the old file. In this case, the change history is not preserved.


29.1.12.3 修订标签

29.1.12.3 Revision Tags

大多数版本控制系统允许您将修订标签 应用于版本控制树的特定版本。在现代基于变更集的版本控制系统上,修订标签只是特定修订的符号名称。在 CVS 等较旧的基于文件的系统上,每个标签都添加到整套版本控制文件中,从而允许将它们作为一个单元进行处理。修订标签通常用于标识分发给用户的版本。

Most version control systems allow you to apply a revision tag to a specific version of a version-controlled tree. On modern changeset-based version control systems, a revision tag is simply a symbolic name for a particular revision. On older file-based systems like CVS, each tag is added to the entire set of version-controlled files, allowing them to be handled as a unit. Revision tags are commonly used to identify releases that are distributed to users.

标签有两个基本命令;一个使用给定名称创建标签,另一个检索命名标签。

There are two basic commands for tags; one makes a tag with a given name, the other retrieves a named tag.

C-x v s name RET
C-x v s name RET

将当前目录中或下的每个注册文件的工作版本定义为名为name ( )的标签vc-create-tag

Define the working revision of every registered file in or under the current directory as a tag named name (vc-create-tag).

C-x v r name RET
C-x v r name RET

对于当前目录级别或当前目录级别以下的所有已注册文件,检索带标记的修订名称。如果name是分支名称并且您的 VCS 将分支与标签区分开来,则此命令将切换到分支。 ( vc-retrieve-tag)。

如果任何文件被锁定在当前目录或当前目录下,则此命令会报告错误,而不进行任何更改;这是为了避免覆盖正在进行的工作。

For all registered files at or below the current directory level, retrieve the tagged revision name. This command will switch to a branch if name is a branch name and your VCS distinguishes branches from tags. (vc-retrieve-tag).

This command reports an error if any files are locked at or below the current directory, without changing anything; this is to avoid overwriting work in progress.

您可以将标签或分支名称作为C-x v =或 的 参数C-x v ~ (请参阅检查和比较旧修订)。因此,您可以使用它来将标记版本与当前文件进行比较,或者将两个标记版本相互进行比较。

You can give a tag or branch name as an argument to C-x v = or C-x v ~ (see Examining And Comparing Old Revisions). Thus, you can use it to compare a tagged version against the current files, or two tagged versions against each other.

在SCCS上,VC自己实现标签;这些标签只能通过 VC 可见。大多数后来的系统(包括 CVS、Subversion、bzr、git 和 hg)都具有本机标记工具,并且 VC 在可用的情况下使用它;即使您绕过 VC,这些标签也将可见。

On SCCS, VC implements tags itself; these tags are visible only through VC. Most later systems (including CVS, Subversion, bzr, git, and hg) have a native tag facility, and VC uses it where available; those tags will be visible even when you bypass VC.

在基于文件的版本控制系统中,当您重命名注册文件时,您需要同时重命名其主文件;该命令 vc-rename-file将自动执行此操作(请参阅删除和重命名版本控制文件)。如果您使用 SCCS,您还必须更新标签的记录,以通过新名称提及该文件(vc-rename-file也是这样做的)。引用已记录名称下不再存在的主文件的旧标签无效; VC 无法再检索它。对 RCS 和 SCCS 进行足够的解释以解释如何手动更新标签超出了本手册的范围。使用 vc-rename-file使得标签对于检索仍然有效,但它并不能解决所有问题。例如,程序中的某些文件可能通过名称引用其他文件。至少,makefile 可能提到了您重命名的文件。如果检索旧标记,则会以其新名称检索重命名的文件,该新名称不是 makefile 期望的名称。所以该程序不会真正按照检索的方式工作。

In file-based version control systems, when you rename a registered file you need to rename its master along with it; the command vc-rename-file will do this automatically (see Deleting and Renaming Version-Controlled Files). If you are using SCCS, you must also update the records of the tag, to mention the file by its new name (vc-rename-file does this, too). An old tag that refers to a master file that no longer exists under the recorded name is invalid; VC can no longer retrieve it. It would be beyond the scope of this manual to explain enough about RCS and SCCS to explain how to update the tags by hand. Using vc-rename-file makes the tag remain valid for retrieval, but it does not solve all problems. For example, some of the files in your program probably refer to others by name. At the very least, the makefile probably mentions the file that you renamed. If you retrieve an old tag, the renamed file is retrieved under its new name, which is not the name that the makefile expects. So the program won’t really work as retrieved.


29.1.12.4 插入版本控制头

29.1.12.4 Inserting Version Control Headers

在 Subversion、CVS、RCS 和 SCCS 上,您可以将某些称为版本标头的特殊字符串放入工作文件中。提交文件时,版本控制系统会自动将修订号、提交用户的名称以及其他相关信息放入版本标头中。

On Subversion, CVS, RCS, and SCCS, you can put certain special strings called version headers into a work file. When the file is committed, the version control system automatically puts the revision number, the name of the user who made the commit, and other relevant information into the version header.

VC 通常不使用版本标头中的信息。作为例外,当使用 RCS 时,Emacs 使用版本标头(如果有)来确定文件版本,因为它通常比 RCS 主文件更可靠。要禁止以这种方式使用版本标头,请将变量更改vc-consult-headersnil。然后,VC 始终使用文件权限(如果应该信任它们),否则检查主文件。

VC does not normally use the information in the version headers. As an exception, when using RCS, Emacs uses the version header, if there is one, to determine the file version, since it is often more reliable than the RCS master file. To inhibit using the version header this way, change the variable vc-consult-headers to nil. VC then always uses the file permissions (if it is supposed to trust them), or else checks the master file.

要将合适的标头字符串插入当前缓冲区,请使用命令M-x vc-insert-headers。此命令仅适用于 Subversion、CVS、RCS 和 SCCS。该变量 包含要插入版本标头的关键字列表;例如,CVS 使用,其默认值为。 (如果使用版本控制来维护定义字符串常量的 Emacs Lisp 文件,则额外的反斜杠可以防止字符串常量被解释为标头。)该 命令将列表中的每个关键字插入到新行中的点处,周围是制表符,并且位于内部如有必要,注释分隔符。 vc-backend-headervc-cvs-header'("\$Id\$")vc-insert-headers

To insert a suitable header string into the current buffer, use the command M-x vc-insert-headers. This command works only on Subversion, CVS, RCS, and SCCS. The variable vc-backend-header contains the list of keywords to insert into the version header; for instance, CVS uses vc-cvs-header, whose default value is '("\$Id\$"). (The extra backslashes prevent the string constant from being interpreted as a header, if the Emacs Lisp file defining it is maintained with version control.) The vc-insert-headers command inserts each keyword in the list on a new line at point, surrounded by tabs, and inside comment delimiters if necessary.

该变量vc-static-header-alist根据缓冲区的名称指定要添加的更多字符串。它的值应该是表单元素的列表。每当 regexp与缓冲区名称匹配时,格式也会作为版本标头的一部分插入。 A '(regexp . format)%s格式中的 '替换为文件的版本控制类型。

The variable vc-static-header-alist specifies further strings to add based on the name of the buffer. Its value should be a list of elements of the form (regexp . format). Whenever regexp matches the buffer name, format is also inserted as part of the version header. A ‘%s’ in format is replaced with the file’s version control type.


29.1.12.5 编辑 VC 命令

29.1.12.5 Editing VC Commands

可以使用C-x v !( vc-edit-next-command)前缀命令来编辑VC要运行的shell命令行。这主要是为了能够向 VCS 命令添加可选的命令行参数,而不会使 VC 命令集及其与后端的接口变得不必要的复杂化。

You can use the C-x v ! (vc-edit-next-command) prefix command to edit the shell command line that VC is about to run. This is primarily intended to make it possible to add optional command-line arguments to VCS commands without unnecessary complications of the VC command set and its interfaces with the backend.

例如,Git 可以生成多个分支的日志,但 C-x v b l( vc-print-branch-log) 只会提示输入一个分支的名称。要获取多个分支的日志,您可以键入附加分支的名称,然后将其附加到“C-x v ! C-x v b lgit 日志' VC 即将运行的命令。

For example, Git can produce logs of more than one branch, but C-x v b l (vc-print-branch-log) prompts for the name of just one branch. To obtain a log of more than one branch, you can type C-x v ! C-x v b l and then append the names of additional branches to the end of the ‘git log’ command that VC is about to run.


29.1.12.6 准备补丁

29.1.12.6 Preparing Patches

在项目协作时,通常通过电子邮件发送补丁以共享更改。您可以使用 VC 的命令来完成此操作 vc-prepare-patch。这将提示您输入想要共享的修订以及要使用的目标电子邮件地址。使用crm-separator的值分隔修订版本 ,默认为逗号。然后,该命令将使用您的MUA (邮件用户代理)准备这些修订供您查看和发送。

When collaborating on projects it is common to send patches via email, to share changes. You can do this using VC with the vc-prepare-patch command. This will prompt you for the revisions you wish to share, and which destination email address(es) to use. Separate the revisions using the value of crm-separator, commas by default. The command will then prepare those revisions using your MUA (Mail User Agent) for you to review and send.

当在带有标记修订的日志视图缓冲区中交互调用时,将使用那些标记的修订。

When invoked interactively in a Log View buffer with marked revisions, those marked revisions will be used.

根据用户选项的值 vc-prepare-patches-separatelyvc-prepare-patch将生成一条或多条消息。默认值t意味着为每个修订准备并依次显示一条消息。值nil表示生成一条消息,并将所有补丁附加在正文中。

Depending on the value of the user option vc-prepare-patches-separately, vc-prepare-patch will generate one or more messages. The default value t means prepare and display a message for each revision, one after another. A value of nil means to generate a single message with all patches attached in the body.

如果您希望定期贡献补丁,您可以将用户选项设置vc-default-patch-addressee为您希望使用的地址。调用时这将用作默认值 vc-prepare-patch。项目维护者可以考虑将其设置为目录局部变量(请参阅每目录局部变量)。

If you expect to contribute patches on a regular basis, you can set the user option vc-default-patch-addressee to the address(es) you wish to use. This will be used as the default value when invoking vc-prepare-patch. Project maintainers may consider setting this as a directory local variable (see Per-Directory Local Variables).


29.1.13 自定义 VC

29.1.13 Customizing VC

该变量vc-handled-backends确定 VC 应处理哪个版本控制系统。默认值为(RCS CVS SVN SCCS SRC Bzr Git Hg),因此包含当前支持的所有版本系统。如果您希望 VC 忽略这些系统中的一个或多个,请从列表中排除其名称。要完全禁用 VC,请将此变量设置为nil

The variable vc-handled-backends determines which version control systems VC should handle. The default value is (RCS CVS SVN SCCS SRC Bzr Git Hg), so it contains all the version systems that are currently supported. If you want VC to ignore one or more of these systems, exclude its name from the list. To disable VC entirely, set this variable to nil.

列表中系统的顺序很重要:当您访问在多个系统中注册的文件时,VC 默认vc-handled-backends情况下使用第一个系统。当您第一次注册文件时,该顺序也很重要(请参阅注册文件以进行版本控制)。

The order of systems in the list is significant: when you visit a file registered in more than one system, VC uses the system that comes first in vc-handled-backends by default. The order is also significant when you register a file for the first time (see Registering a File for Version Control).


29.1.13.1 常规选项

29.1.13.1 General Options

Emacs 通常不会为使用版本控制维护的源文件保存备份文件。如果您甚至想为使用版本控制的文件创建备份文件,请将该变量设置 vc-make-backup-files为非值nil

Emacs normally does not save backup files for source files that are maintained with version control. If you want to make backup files even for files that use version control, set the variable vc-make-backup-files to a non-nil value.

如果您不知道基础文件是版本控制的,则通过符号链接编辑版本控制文件可能会导致意外结果。vc-follow-symlinks如果您尝试访问指向版本控制文件的符号链接,该变量控制 Emacs 执行的操作。如果该值为ask(默认值),Emacs 会要求确认。如果是nil,Emacs 仅显示一条警告消息。如果是t,Emacs 会自动跟踪链接并访问真实文件。

Editing a version-controlled file through a symbolic link may cause unexpected results, if you are unaware that the underlying file is version-controlled. The variable vc-follow-symlinks controls what Emacs does if you try to visit a symbolic link pointing to a version-controlled file. If the value is ask (the default), Emacs asks for confirmation. If it is nil, Emacs just displays a warning message. If it is t, Emacs automatically follows the link and visits the real file instead.

如果vc-suppress-confirm为非nil,则C-x v vC-x v i可以不询问而保存当前缓冲区,并且 C-x v u也可以不询问确认而进行操作。

If vc-suppress-confirm is non-nil, then C-x v v and C-x v i can save the current buffer without asking, and C-x v u also operates without asking for confirmation.

VC 模式通过运行适当版本控制系统的 shell 命令来完成大部分工作。如果vc-command-messages为非nil,VC 将显示消息来指示它运行哪些 shell 命令,并在命令完成时显示其他消息。

VC mode does much of its work by running the shell commands for the appropriate version control system. If vc-command-messages is non-nil, VC displays messages to indicate which shell commands it runs, and additional messages when the commands finish.


29.1.13.2 RCS 和 SCCS 选项

29.1.13.2 Options for RCS and SCCS

默认情况下,RCS 使用锁定来协调多个用户的活动,但有一种称为非严格锁定的模式,您可以在不先锁定文件的情况下签入更改。使用 'rcs-U' 要切换到特定文件的非严格锁定,请参阅rcs手册页了解详细信息。

By default, RCS uses locking to coordinate the activities of several users, but there is a mode called non-strict locking in which you can check-in changes without locking the file first. Use ‘rcs -U’ to switch to non-strict locking for a particular file, see the rcs manual page for details.

在推导 RCS 文件的版本控制状态时,VC 首先在文件中查找 RCS 版本标头字符串(请参阅插入版本控制标头)。如果没有头字符串,VC通常会查看工作文件的文件权限;这很快。但可能存在文件权限不可信的情况。在这种情况下,必须查阅主文件,这是相当昂贵的。此外,主文件只能告诉您文件上 是否有任何锁定,但不能告诉您的工作文件是否确实包含该锁定版本。

When deducing the version control state of an RCS file, VC first looks for an RCS version header string in the file (see Inserting Version Control Headers). If there is no header string, VC normally looks at the file permissions of the work file; this is fast. But there might be situations when the file permissions cannot be trusted. In this case the master file has to be consulted, which is rather expensive. Also the master file can only tell you if there’s any lock on the file, but not whether your work file really contains that locked version.

vc-consult-headers您可以通过设置为 来告诉 VC 不要使用版本标头来确定文件状态nil。然后,VC 始终使用文件权限(如果应该信任它们),否则检查主文件。

You can tell VC not to use version headers to determine the file status by setting vc-consult-headers to nil. VC then always uses the file permissions (if it is supposed to trust them), or else checks the master file.

VC 确定 SCCS 下文件的版本控制状态,与 RCS 非常相似。但它不考虑 SCCS 版本标头。因此,该变量vc-consult-headers不会影响 SCCS 的使用。

VC determines the version control state of files under SCCS much as with RCS. It does not consider SCCS version headers, though. Thus, the variable vc-consult-headers does not affect SCCS use.


29.1.13.3 CVS 特定的选项

29.1.13.3 Options specific for CVS

您可以指定附加命令行选项以传递给变量中的所有 CVS 操作vc-cvs-global-switches。这些开关紧接在cvs命令之后、要调用的操作名称之前 插入。

You can specify additional command line options to pass to all CVS operations in the variable vc-cvs-global-switches. These switches are inserted immediately after the cvs command, before the name of the operation to invoke.

在远程计算机上使用 CVS 存储库时,VC 可以尝试将网络交互保持在最低限度。这是由变量控制的 vc-cvs-stay-local。如果vc-cvs-stay-localonly-file(默认值),VC 仅使用本地 CVS 子目录中的条目和先前 CVS 命令返回的信息来确定每个文件的版本控制状态。因此,如果您修改了文件并且其他人签入了其他更改,则在您尝试提交之前,您不会收到冲突通知。

When using a CVS repository on a remote machine, VC can try keeping network interactions to a minimum. This is controlled by the variable vc-cvs-stay-local. If vc-cvs-stay-local is only-file (the default), VC determines the version control status of each file using only the entry in the local CVS subdirectory and the information returned by previous CVS commands. As a consequence, if you have modified a file and somebody else has checked in other changes, you will not be notified of the conflict until you try to commit.

如果更改vc-cvs-stay-localnil,VC 会先查询远程存储库,然后vc-next-action再决定在( )中执行哪些操作 C-x v v,就像对本地存储库所做的那样。

If you change vc-cvs-stay-local to nil, VC queries the remote repository before it decides what to do in vc-next-action (C-x v v), just as it does for local repositories.

您还可以设置vc-cvs-stay-local与存储库主机名匹配的正则表达式;然后,VC 仅针对与该模式匹配的主机中的存储库保留在本地。

You can also set vc-cvs-stay-local to a regular expression that is matched against the repository host name; VC then stays local only for repositories from hosts that match the pattern.

使用远程存储库时,Emacs 通常会对每个编辑文件的原始版本进行自动版本备份。每当您将第一个更改保存到文件时,就会创建这些本地备份,并在您将更改提交到存储库后将其删除。 (请注意,这些与普通的 Emacs 备份文件不同;请参阅备份文件C-x v =。)和等命令C-x v u使用自动版本备份(如果可能),以避免访问网络。

When using a remote repository, Emacs normally makes automatic version backups of the original versions of each edited file. These local backups are made whenever you save the first changes to a file, and they are removed after you commit your changes to the repository. (Note that these are not the same as ordinary Emacs backup files; see Backup Files.) Commands like C-x v = and C-x v u make use of automatic version backups, if possible, to avoid having to access the network.

设置vc-cvs-stay-localnil禁用自动版本备份。

Setting vc-cvs-stay-local to nil disables the making of automatic version backups.

自动版本备份的名称格式为 .这与保存旧版本的名称类似(请参阅检查和比较旧版本),除了附加点('file.~version.~C-x v ~')在版本之后。相关VC命令可以使用这两种版本备份。主要区别在于,C-x v ~当您提交时,不会自动删除 所做的手动版本备份。

Automatic version backups have names of the form file.~version.~. This is similar to the name that C-x v ~ saves old versions to (see Examining And Comparing Old Revisions), except for the additional dot (‘.’) after the version. The relevant VC commands can use both kinds of version backups. The main difference is that the manual version backups made by C-x v ~ are not deleted automatically when you commit.

CVS 默认情况下不使用锁定,但有一些方法可以使用其CVSREAD监视功能来启用类似锁定的行为;有关详细信息,请参阅 CVS 文档。如果是这种情况,您可以 C-x v v在 Emacs 中使用来切换锁定,就像使用基于锁定的版本控制系统一样(请参阅使用锁定的基本版本控制)。

CVS does not use locking by default, but there are ways to enable locking-like behavior using its CVSREAD or watch feature; see the CVS documentation for details. If that case, you can use C-x v v in Emacs to toggle locking, as you would for a locking-based version control system (see Basic Version Control with Locking).


29.2 处理项目

29.2 Working with Projects

项目是用于生成一个或多个程序的文件的集合属于项目的文件通常存储在目录层次结构中;层次结构的顶级目录称为项目根

A project is a collection of files used for producing one or more programs. Files that belong to a project are typically stored in a hierarchy of directories; the top-level directory of the hierarchy is known as the project root.

给定目录是否是某个项目的根目录由项目特定的基础设施(称为项目后端)决定。 Emacs 目前支持两种这样的后端: VC 感知(请参阅版本控制),其中 VCS 存储库被视为一个项目;和 EDE(请参阅Emacs 开发环境)。预计未来将扩展以支持其他类型的项目。

Whether a given directory is a root of some project is determined by the project-specific infrastructure, known as project back-end. Emacs currently supports two such back-ends: VC-aware (see Version Control), whereby a VCS repository is considered a project; and EDE (see Emacs Development Environment). This is expected to be extended in the future to support additional types of projects.

哪些文件属于或不属于项目也由项目后端决定。例如,VC 感知后端不会将“忽略”文件(请参阅忽略版本控制文件)视为项目的一部分。此外,VC 感知项目后端默认考虑“未跟踪”文件。该行为可以通过变量 来控制 project-vc-include-untracked

Which files do or don’t belong to a project is also determined by the project back-end. For example, the VC-aware back-end doesn’t consider “ignored” files (see Ignore Version Control Files) to be part of the project. Also, the VC-aware Project back-end considers “untracked” files by default. That behavior is controllable with the variable project-vc-include-untracked.


29.2.1 对文件进行操作的项目命令

29.2.1 Project Commands That Operate on Files

C-x p f
C-x p f

访问属于当前项目的文件 ( project-find-file)。

Visit a file that belongs to the current project (project-find-file).

C-x p g
C-x p g

在属于当前项目 ( project-find-regexp) 的所有文件中查找正则表达式的匹配项。

Find matches for a regexp in all files that belong to the current project (project-find-regexp).

M-x project-search
M-x project-search

在属于当前项目的所有文件中交互式搜索正则表达式匹配项。

Interactively search for regexp matches in all files that belong to the current project.

C-x p r
C-x p r

对属于当前项目 ( ) 的所有文件中的正则表达式执行查询替换project-query-replace-regexp

Perform query-replace for a regexp in all files that belong to the current project (project-query-replace-regexp).

C-x p d
C-x p d

在当前项目的根目录 ( project-dired) 中运行 Dired。

Run Dired in the current project’s root directory (project-dired).

C-x p v
C-x p v

vc-dir在当前项目的根目录( )中运行project-vc-dir

Run vc-dir in the current project’s root directory (project-vc-dir).

C-x p s
C-x p s

在当前项目的根目录 ( project-shell) 中启动一个下级 shell。

Start an inferior shell in the current project’s root directory (project-shell).

C-x p e
C-x p e

在当前项目的根目录(project-eshell)中启动Eshell。

Start Eshell in the current project’s root directory (project-eshell).

C-x p c
C-x p c

在当前项目的根目录(project-compile)中运行编译。

Run compilation in the current project’s root directory (project-compile).

C-x p !
C-x p !

在当前项目的根目录(project-shell-command)中运行 shell 命令。

Run shell command in the current project’s root directory (project-shell-command).

C-x p &
C-x p &

在当前项目的根目录 ( project-async-shell-command) 中异步运行 shell 命令。

Run shell command asynchronously in the current project’s root directory (project-async-shell-command).

Emacs 提供了方便处理项目文件的命令。本小节描述这些命令。

Emacs provides commands for handling project files conveniently. This subsection describes these commands.

这里描述的所有命令都共享当前项目的概念 。当前项目由调用命令时的当前缓冲区的缓冲区default-directory(请参阅文件名)确定 。如果该目录似乎不属于可识别的项目,这些命令会提示您输入项目目录。

All of the commands described here share the notion of the current project. The current project is determined by the default-directory (see File Names) of the buffer that is the current buffer when the command is invoked. If that directory doesn’t seem to belong to a recognizable project, these commands prompt you for the project directory.

命令C-x p f( ) 是访问属于当前项目的文件(请参阅访问文件project-find-file)的便捷方法。与 不同,此命令不需要键入要访问的文件的完整文件名,您可以仅键入文件的基本名称(即省略前导目录)。此外,该命令考虑的完成候选仅包括属于当前项目的文件,而不包括其他文件。如果此时存在文件名,则此命令会将该文件提供为“未来历史记录”的第一个元素。如果给定前缀,则包含项目根目录下的所有文件,除了中列出的VCS目录 。 C-x C-fvc-directory-exclusion-list

The command C-x p f (project-find-file) is a convenient way of visiting files (see Visiting Files) that belong to the current project. Unlike C-x C-f, this command doesn’t require to type the full file name of the file to visit, you can type only the file’s base name (i.e., omit the leading directories). In addition, the completion candidates considered by the command include only the files belonging to the current project, and nothing else. If there’s a file name at point, this command offers that file as the first element of the “future history”. If given a prefix, include all files under the project root, except for VCS directories listed in vc-directory-exclusion-list.

命令C-x p g( project-find-regexp) 类似于 rgrep(请参阅在 Emacs 下使用 Grep 进行搜索),但它仅搜索属于当前项目的文件。该命令提示输入要搜索的正则表达式,并弹出带有搜索结果的外部参照模式缓冲区,您可以在其中使用外部参照模式命令选择匹配项(请参阅*外部参考*缓冲)。当使用前缀参数调用时,此命令还会提示输入开始搜索的基本目录;例如,这允许将搜索限制为仅搜索项目根目录的某个子目录下的项目文件。此命令显示匹配的方式受 值的影响xref-auto-jump-to-first-xref(请参阅搜索和用标识符替换)。

The command C-x p g (project-find-regexp) is similar to rgrep (see Searching with Grep under Emacs), but it searches only the files that belong to the current project. The command prompts for the regular expression to search, and pops up an Xref mode buffer with the search results, where you can select a match using the Xref mode commands (see Commands Available in the *xref* Buffer). When invoked with a prefix argument, this command additionally prompts for the base directory from which to start the search; this allows, for example, to limit the search only to project files under a certain subdirectory of the project root. The way this command displays the matches is affected by the value of xref-auto-jump-to-first-xref (see Searching and Replacing with Identifiers).

M-x project-search是 的顺序变体 project-find-regexp。它提示输入正则表达式在当前项目的文件中进行搜索,但不是查找所有匹配项并显示它们,而是在找到匹配项时停止并访问匹配位置处的匹配文件,允许您编辑匹配项文件。要查找其余的匹配项,请输入。 M-x fileloop-continue RET

M-x project-search is a sequential variant of project-find-regexp. It prompts for a regular expression to search in the current project’s files, but instead of finding all the matches and displaying them, it stops when it finds a match and visits the matched file at the locus of the match, allowing you to edit the matched file. To find the rest of the matches, type M-x fileloop-continue RET.

C-x p r( project-query-replace-regexp) 与 类似 project-search,但它会提示您是否替换它找到的每个匹配项query-replace(请参阅查询替换),并在您响应后继续处理下一个匹配项。如果您的响应导致 Emacs 退出查询替换循环,您可以稍后继续使用。 M-x fileloop-continue RET

C-x p r (project-query-replace-regexp) is similar to project-search, but it prompts you for whether to replace each match it finds, like query-replace does (see Query Replace), and continues to the next match after you respond. If your response causes Emacs to exit the query-replace loop, you can later continue with M-x fileloop-continue RET.

命令C-x p d( project-find-dir) 提示您在当前项目中选择一个目录,然后完成。并打开一个 Dired 缓冲区(请参阅Dired,目录编辑器),列出其中的文件。

The command C-x p d (project-find-dir) prompts you to choose a directory inside the current project, with completion. And opens a Dired buffer (see Dired, the Directory Editor) listing the files in it.

命令C-x p D( project-dired) 打开 Dired 缓冲区(请参阅Dired,目录编辑器),列出当前项目根目录中的文件。

The command C-x p D (project-dired) opens a Dired buffer (see Dired, the Directory Editor) listing the files in the current project’s root directory.

命令C-x p v( project-vc-dir) 打开 VC 目录缓冲区(请参阅VC 目录模式),列出当前项目根目录下目录树中文件的版本控制状态。

The command C-x p v (project-vc-dir) opens a VC Directory buffer (see VC Directory Mode) listing the version control statuses of the files in a directory tree under the current project’s root directory.

命令C-x p s( )在新缓冲区中 project-shell启动 shell 会话(请参阅从 Emacs 运行 Shell 命令),并将当前项目的根目录作为工作目录。

The command C-x p s (project-shell) starts a shell session (see Running Shell Commands from Emacs) in a new buffer with the current project’s root as the working directory.

命令C-x p e( project-eshell) 在新缓冲区中启动 Eshell 会话,并将当前项目的根目录作为工作目录。请参阅Eshell中的Eshell :Emacs Shell

The command C-x p e (project-eshell) starts an Eshell session in a new buffer with the current project’s root as the working directory. See Eshell in Eshell: The Emacs Shell.

命令C-x p c( )在当前项目的根目录中 project-compile运行编译(请参阅Emacs 下的运行编译)。

The command C-x p c (project-compile) runs compilation (see Running Compilations under Emacs) in the current project’s root directory.

命令C-x p !( )在当前项目的根目录中 project-shell-command运行 。shell-command

The command C-x p ! (project-shell-command) runs shell-command in the current project’s root directory.

命令C-x p &( )在当前项目的根目录中 project-async-shell-command运行 。async-shell-command

The command C-x p & (project-async-shell-command) runs async-shell-command in the current project’s root directory.


29.2.2 对缓冲区进行操作的项目命令

29.2.2 Project Commands That Operate on Buffers

C-x p b
C-x p b

切换到属于当前项目的另一个缓冲区 ( project-switch-to-buffer)。

Switch to another buffer belonging to the current project (project-switch-to-buffer).

C-x p C-b
C-x p C-b

列出项目缓冲区 ( project-list-buffers)。

List the project buffers (project-list-buffers).

C-x p k
C-x p k

杀死属于当前项目的所有活动缓冲区 ( project-kill-buffers)。

Kill all live buffers that belong to the current project (project-kill-buffers).

处理一个项目可能会涉及到让许多缓冲区访问属于该项目的文件,以及属于该项目但不访问任何文件的缓冲区(例如 *汇编*由 ) 创建的缓冲区project-compile。命令C-x p b( project-switch-to-buffer) 通过提示要切换的缓冲区并仅将当前项目的缓冲区视为完成的候选缓冲区,帮助您在属于当前项目的缓冲区之间进行切换。

Working on a project could potentially involve having many buffers visiting files that belong to the project, and also buffers that belong to the project, but don’t visit any files (like the *compilation* buffer created by project-compile). The command C-x p b (project-switch-to-buffer) helps you switch between buffers that belong to the current project by prompting for a buffer to switch and considering only the current project’s buffers as candidates for completion.

与该命令list-buffers(请参阅列出现有缓冲区)一样,命令C-x p C-b( project-list-buffers) 显示现有缓冲区的列表,但仅属于当前项目。

Like the command list-buffers (see Listing Existing Buffers), the command C-x p C-b (project-list-buffers) displays a list of existing buffers, but only belonging to the current project.

当您完成项目工作时,您可能希望杀死属于该项目的所有缓冲区,以保持 Emacs 会话更小。命令C-x p k( project-kill-buffers) 的作用是:它杀死属于当前项目且满足project-kill-buffer-conditions.如果 project-kill-buffers-display-buffer-list为非nil,则首先显示要杀死的缓冲区。

When you finish working on the project, you may wish to kill all the buffers that belong to the project, to keep your Emacs session smaller. The command C-x p k (project-kill-buffers) accomplishes that: it kills all the buffers that belong to the current project that satisfy any of project-kill-buffer-conditions. If project-kill-buffers-display-buffer-list is non-nil, the buffers to be killed will be displayed first.


29.2.3 切换项目

29.2.3 Switching Projects

C-x p p
C-x p p

为另一个项目运行 Emacs 命令 ( project-switch-project)。

Run an Emacs command for another project (project-switch-project).

当当前没有项目时,对项目文件进行操作的命令(请参阅对文件进行操作的项目命令)将方便地提示您输入项目目录。当您在某个项目中,但想要对其他项目进行操作时,请使用命令C-x p pproject-switch-project)。此命令提示您在已知项目根目录中选择一个目录,然后显示可用于操作您选择的项目的命令菜单。该变量 project-switch-commands控制菜单中可用的命令以及哪个键调用每个命令。

Commands that operate on project files (see Project Commands That Operate on Files) will conveniently prompt you for a project directory when no project is current. When you are inside some project, but you want to operate on a different project, use the C-x p p command (project-switch-project). This command prompts you to choose a directory among known project roots, and then displays the menu of available commands to operate on the project you choose. The variable project-switch-commands controls which commands are available in the menu, and which key invokes each command.

该变量project-list-file命名 Emacs 在其中记录已知项目列表的文件。它默认为文件 项目user-emacs-directory(请参阅Emacs如何查找您的初始化文件)。

The variable project-list-file names the file in which Emacs records the list of known projects. It defaults to the file projects in user-emacs-directory (see How Emacs Finds Your Init File).


29.2.4 管理项目列表文件

29.2.4 Managing the Project List File

M-x project-forget-project
M-x project-forget-project

project-list-file.

Remove a known project from the project-list-file.

通常,Emacs 会自动在 中添加和删除项目 project-list-file,但有时您可能需要手动编辑可用项目。 M-x project-forget-project 提示您选择可用项目之一,然后将其从文件中删除。

Normally Emacs automatically adds and removes projects to and from the project-list-file, but sometimes you may want to manually edit the available projects. M-x project-forget-project prompts you to choose one of the available projects, and then removes it from the file.


29.3 变更日志

29.3 Change Logs

许多软件项目都会保留变更日志。这是一个文件,通常命名为变更日志,包含程序更改时间和方式的时间记录。有时,这些文件是根据版本控制系统中存储的更改日志条目自动生成的,或者用于生成这些更改日志条目。有时,会有多个更改日志文件,每个更改日志文件都记录一个目录或目录树中的更改。

Many software projects keep a change log. This is a file, normally named ChangeLog, containing a chronological record of when and how the program was changed. Sometimes, these files are automatically generated from the change log entries stored in version control systems, or are used to generate these change log entries. Sometimes, there are several change log files, each recording the changes in one directory or directory tree.


29.3.1 更改日志命令

29.3.1 Change Log Commands

Emacs 命令C-x 4 a向您正在编辑的文件的更改日志文件添加一个新条目 ( add-change-log-entry-other-window)。如果该文件实际上是备份文件,它会创建一个适合该文件的父文件的条目,这对于为当前版本中已删除的函数创建日志条目非常有用。

The Emacs command C-x 4 a adds a new entry to the change log file for the file you are editing (add-change-log-entry-other-window). If that file is actually a backup file, it makes an entry appropriate for the file’s parent—that is useful for making log entries for functions that have been deleted in the current version.

C-x 4 a访问更改日志文件并创建一个新条目,除非最近的条目是针对今天的日期和您的姓名的。它还为当前文件创建一个新项目。对于许多语言,它甚至可以猜测函数或其他已更改对象的名称。

C-x 4 a visits the change log file and creates a new entry unless the most recent entry is for today’s date and your name. It also creates a new item for the current file. For many languages, it can even guess the name of the function or other object that was changed.

为了查找更改日志文件,Emacs 从您正在编辑的文件中搜索目录树。默认情况下,如果它发现一个似乎是版本控制存储库根目录的目录,它就会停止。要更改此设置,请自定义change-log-directory-files.

To find the change log file, Emacs searches up the directory tree from the file you are editing. By default, it stops if it finds a directory that seems to be the root of a version-control repository. To change this, customize change-log-directory-files.

当变量add-log-keep-changes-together为 non-时nilC-x 4 a添加到文件的任何现有项目,而不是启动新项目。

When the variable add-log-keep-changes-together is non-nil, C-x 4 a adds to any existing item for the file, rather than starting a new item.

您可以组合相同性质的多个更改。如果您在初始 后没有输入任何文本C-x 4 a,则任何后续文本 C-x 4 a都会向更改日志条目添加另一个符号。

You can combine multiple changes of the same nature. If you don’t enter any text after the initial C-x 4 a, any subsequent C-x 4 a adds another symbol to the change log entry.

如果add-log-always-start-new-record为非nilC-x 4 a则始终创建新条目,即使最后一个条目是您在同一日期创建的。

If add-log-always-start-new-record is non-nil, C-x 4 a always makes a new entry, even if the last entry was made by you and on the same date.

如果变量的值为change-log-version-info-enabled non- nilC-x 4 a则将文件的版本号添加到更改日志条目中。它通过使用变量 中的正则表达式搜索文件的前百分之十来查找版本号 change-log-version-number-regexp-list

If the value of the variable change-log-version-info-enabled is non-nil, C-x 4 a adds the file’s version number to the change log entry. It finds the version number by searching the first ten percent of the file, using regular expressions from the variable change-log-version-number-regexp-list.

在更改日志模式下访问更改日志文件。在这种主要模式中,每一组分组的项目都算作一个段落,每个条目都被视为一页。这有助于编辑条目。 C-j并像前一行一样自动填充缩进每个新行;这对于输入条目内容很方便。

The change log file is visited in Change Log mode. In this major mode, each bunch of grouped items counts as one paragraph, and each entry is considered a page. This facilitates editing the entries. C-j and auto-fill indent each new line like the previous line; this is convenient for entering the contents of an entry.

当更改日志模式打开时,您可以使用该命令change-log-goto-source(默认绑定到C-c C-c)转到附近点的更改日志条目的源位置。然后该next-error命令的后续调用(默认情况下绑定到 M-g M-nC-x `)将在更改日志中的条目之间移动。您将跳转到文件中已更改的实际站点,而不仅仅是下一个更改日志条目。您还可以使用 previous-error向后移动更改日志条目。

You can use the command change-log-goto-source (by default bound to C-c C-c) to go to the source location of the change log entry near point, when Change Log mode is on. Then subsequent invocations of the next-error command (by default bound to M-g M-n and C-x `) will move between entries in the change log. You will jump to the actual site in the file that was changed, not just to the next change log entry. You can also use previous-error to move back through the change log entries.

您可以使用该命令M-x change-log-merge在更改日志模式下将其他日志文件合并到缓冲区中,并保留条目的日期顺序。

You can use the command M-x change-log-merge to merge other log files into a buffer in Change Log Mode, preserving the date ordering of entries.

版本控制系统是跟踪程序更改并保留更改日志的另一种方法。如今,许多使用 VCS 的项目不保留单独的版本更改日志文件,因此您可能希望避免在存储库中包含这样的文件。如果 的值为 add-log-dont-create-changelog-filenon- nil,则C-x 4 a( add-change-log-entry-other-window) 等命令将在适当命名的临时缓冲区而不是文件中记录更改(如果此类文件尚不存在)。

Version control systems are another way to keep track of changes in your program and keep a change log. Many projects that use a VCS don’t keep a separate versioned change log file nowadays, so you may wish to avoid having such a file in the repository. If the value of add-log-dont-create-changelog-file is non-nil, commands like C-x 4 a (add-change-log-entry-other-window) will record changes in a suitably named temporary buffer instead of a file, if such a file does not already exist.

无论您有更改日志文件还是使用更改日志的临时缓冲区,您都可以在 VC 日志缓冲区中键入C-c C-a ( ) 以插入相关更改日志条目(如果存在)。log-edit-insert-changelog请参阅日志条目缓冲区的功能

Whether you have a change log file or use a temporary buffer for change logs, you can type C-c C-a (log-edit-insert-changelog) in the VC Log buffer to insert the relevant change log entries, if they exist. See Features of the Log Entry Buffer.


29.3.2 ChangeLog的格式

29.3.2 Format of ChangeLog

更改日志条目以标题行开头,其中包含当前日期、您的姓名(取自变量 add-log-full-name)和您的电子邮件地址(取自变量add-log-mailing-address)。除了这些标题行之外,更改日志中的每一行都以空格或制表符开头。条目的大部分由items组成,每个 items 都以一行开头,该行以空格和一个星号开头。这里有两个条目,日期均为 1993 年 5 月,分别有 2 项和 1 项。

A change log entry starts with a header line that contains the current date, your name (taken from the variable add-log-full-name), and your email address (taken from the variable add-log-mailing-address). Aside from these header lines, every line in the change log starts with a space or a tab. The bulk of the entry consists of items, each of which starts with a line starting with whitespace and a star. Here are two entries, both dated in May 1993, with two items and one item respectively.

1993-05-25 理查德·斯托曼 <rms@gnu.org>

        * man.el:将符号“man-*”重命名为“Man-*”。
        (手动输入):使提示字符串更清晰。

        * simple.el(闪烁匹配括号距离):
        将默认值更改为 12,000。

1993-05-24 理查德·斯托曼 <rms@gnu.org>

        * vc.el (minor-mode-map-alist): 如果它是空的,不要使用它。
        (vc-cancel-version):文档修复。
1993-05-25  Richard Stallman  <rms@gnu.org>

        * man.el: Rename symbols 'man-*' to 'Man-*'.
        (manual-entry): Make prompt string clearer.

        * simple.el (blink-matching-paren-distance):
        Change default to 12,000.

1993-05-24  Richard Stallman  <rms@gnu.org>

        * vc.el (minor-mode-map-alist): Don't use it if it's void.
        (vc-cancel-version): Doc fix.

一篇文章可以描述几个变化;每个更改都应该有自己的项目,或者项目中自己的行。通常,项目之间应该有一个空行。当项目相关时(相同更改的部分,在不同的位置),通过在它们之间不留空行来对它们进行分组。

One entry can describe several changes; each change should have its own item, or its own line in an item. Normally there should be a blank line between items. When items are related (parts of the same change, in different places), group them by leaving no blank line between them.

您应该在更改日志文件的末尾放置版权声明和许可声明。这是一个例子:

You should put a copyright notice and permission notice at the end of the change log file. Here is an example:

版权所有 1997、1998 自由软件基金会
复制和分发此文件(无论是否经过修改)
允许,前提是保留版权声明和本声明。
Copyright 1997, 1998 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification, are
permitted provided the copyright notice and this notice are preserved.

当然,您应该替换正确的年份和版权所有者。

Of course, you should substitute the proper years and copyright holder.


29.4 查找标识符引用

29.4 Find Identifier References

标识符是程序的语法子单元的名称:函数、子例程、方法、类、数据类型、宏等。在编程语言中,每个标识符都是该语言语法中的符号标识符也称为标签

An identifier is a name of a syntactical subunit of the program: a function, a subroutine, a method, a class, a data type, a macro, etc. In a programming language, each identifier is a symbol in the language’s syntax. Identifiers are also known as tags.

程序开发和维护需要能够快速查找每个标识符的定义和引用位置、在整个项目中重命名标识符等。这些功能对于查找主要模式中的引用(除了为支持编程语言而定义的模式之外)也很有用。例如,文本或 TeX 文档的章、节、附录等也可以被视为子单元,并且它们的名称可以用作标识符。在本章中,我们使用术语“标识符”来统指程序源代码和其他类型文本中的任何类型子单元的名称。

Program development and maintenance requires capabilities to quickly find where each identifier was defined and referenced, to rename identifiers across the entire project, etc. These capabilities are also useful for finding references in major modes other than those defined to support programming languages. For example, chapters, sections, appendices, etc. of a text or a TeX document can be treated as subunits as well, and their names can be used as identifiers. In this chapter, we use the term “identifiers” to collectively refer to the names of any kind of subunits, in program source and in other kinds of text alike.

Emacs 为这些功能提供了一个统一的接口,称为“外部参照'。

Emacs provides a unified interface to these capabilities, called ‘xref’.

为了完成它的工作,xref需要利用信息并采用特定于主要模式的方法。在哪些文件中搜索标识符、如何查找对标识符的引用、如何完成标识符——所有这些以及更多内容都是特定于模式的知识。 xref将其工作的特定于模式的部分委托给 该模式提供的后端;它还包括一些命令的默认值,适用于那些不提供自己的模式的命令。

To do its job, xref needs to make use of information and to employ methods specific to the major mode. What files to search for identifiers, how to find references to identifiers, how to complete on identifiers—all this and more is mode-specific knowledge. xref delegates the mode-specific parts of its job to a backend provided by the mode; it also includes defaults for some of its commands, for those modes that don’t provide their own.

后端可以通过多种方式实现其功能。这里有一些例子:

A backend can implement its capabilities in a variety of ways. Here are a few examples:

  1. 一些主要模式提供了用于查找语言符号的内置方法。例如,Emacs Lisp 符号可以通过搜索由 Emacs Lisp 解释器维护的包加载历史记录以及查阅内置文档字符串来识别; Emacs Lisp 模式在其后端使用这些工具来允许查找符号的定义。 (这种后端的一个缺点是它只知道加载到解释器中的子单元。)
  2. Some major modes provide built-in means for looking up the language symbols. For example, Emacs Lisp symbols can be identified by searching the package load history, maintained by the Emacs Lisp interpreter, and by consulting the built-in documentation strings; the Emacs Lisp mode uses these facilities in its backend to allow finding definitions of symbols. (One disadvantage of this kind of backend is that it only knows about subunits that were loaded into the interpreter.)
  3. 如果针对当前缓冲区的项目(请参阅使用项目)和当前缓冲区的主要模式激活了 Eglot ,则 Eglot 会查阅外部语言服务器程序并提供服务器提供的有关项目中标识符定义的数据。请参阅Eglot中的Eglot 功能:Emacs LSP 客户端
  4. If Eglot is activated for the current buffer’s project (see Working with Projects) and the current buffer’s major mode, Eglot consults an external language server program and provides the data supplied by the server regarding the definitions of the identifiers in the project. See Eglot Features in Eglot: The Emacs LSP Client.
  5. 外部程序可以通过扫描相关文件来提取参考文献,并建立这些参考文献的数据库。然后,后端可以在需要列出或查找引用时访问该数据库。 Emacs 发行版包括一个用于在程序中标记标识符定义的命令,它通过将引用提取到标记表etags中来支持许多编程语言和其他主要模式,例如 HTML 。请参阅创建标签表。支持的语言的主要模式可以使用标签表作为其后端的基础。 (这种后端的一个缺点是标签表需要通过不时重建来保持合理的最新状态。) etags
  6. An external program can extract references by scanning the relevant files, and build a database of these references. A backend can then access this database whenever it needs to list or look up references. The Emacs distribution includes etags, a command for tagging identifier definitions in programs, which supports many programming languages and other major modes, such as HTML, by extracting references into tags tables. See Creating Tags Tables. Major modes for languages supported by etags can use tags tables as basis for their backend. (One disadvantage of this kind of backend is that tags tables need to be kept reasonably up to date, by rebuilding them from time to time.)

29.4.1 查找标识符

29.4.1 Find Identifiers

本小节介绍查找标识符引用并执行有关标识符的各种查询的命令。每个这样的引用可以定义一个标识符,例如,提供程序子单元的实现或文档部分的文本;或者它可以使用标识符,例如调用函数或方法、为变量赋值、在交叉引用中提及章节等。

This subsection describes the commands that find references to identifiers and perform various queries about identifiers. Each such reference could define an identifier, e.g., provide the implementation of a program subunit or the text of a document section; or it could use the identifier, e.g., call a function or a method, assign a value to a variable, mention a chapter in a cross-reference, etc.


29.4.1.1 查找标识符

29.4.1.1 Looking Up Identifiers

让您能够做的最重要的事情xref就是找到特定标识符的定义。

The most important thing that xref enables you to do is to find the definition of a specific identifier.

M-.
M-.

查找标识符 ( xref-find-definitions) 的定义。

Find definitions of an identifier (xref-find-definitions).

C-M-. pattern RET
C-M-. pattern RET

查找名称与模式 ( )匹配的所有标识符xref-find-apropos

Find all identifiers whose name matches pattern (xref-find-apropos).

C-x 4 . RET
C-x 4 . RET

查找标识符的定义,但将其显示在另一个窗口中 ( xref-find-definitions-other-window)。

Find definitions of identifier, but display it in another window (xref-find-definitions-other-window).

C-x 5 . RET
C-x 5 . RET

找到标识符的定义,并将其显示在新框架中(xref-find-definitions-other-frame)。

Find definition of identifier, and display it in a new frame (xref-find-definitions-other-frame).

M-x xref-find-definitions-at-mouse
M-x xref-find-definitions-at-mouse

单击鼠标查找标识符的定义。

Find definition of identifier at mouse click.

M-,
M-,

返回到您之前调用的位置M-.和朋友 ( xref-go-back)。

Go back to where you previously invoked M-. and friends (xref-go-back).

C-M-,
C-M-,

前进到您先前调用的位置M-, ( xref-go-forward)。

Go forward to where you previously invoked M-, (xref-go-forward).

M-x xref-etags-mode
M-x xref-etags-mode

切换xref到使用etags后端。

Switch xref to use the etags backend.

M-.( xref-find-definitions) 显示了点标识符的定义。使用前缀参数,或者如果当前没有标识符,它会提示输入标识符。 (如果您希望它始终提示,请自定义xref-prompt-for-identifiert。)

M-. (xref-find-definitions) shows the definition of the identifier at point. With a prefix argument, or if there’s no identifier at point, it prompts for the identifier. (If you want it to always prompt, customize xref-prompt-for-identifier to t.)

当输入标识符参数时M-.,您可以使用常用的迷你缓冲区完成命令(请参阅完成),其中已知的标识符名称是完成候选。

When entering the identifier argument to M-., you can use the usual minibuffer completion commands (see Completion), with the known identifier names being the completion candidates.

与大多数可以切换缓冲区的命令一样, xref-find-definitions它有一个变体,可以在另一个窗口中显示新缓冲区,以及为其创建一个新帧。前者为C-x 4 .xref-find-definitions-other-window),后者为 C-x 5 .xref-find-definitions-other-frame)。

Like most commands that can switch buffers, xref-find-definitions has a variant that displays the new buffer in another window, and one that makes a new frame for it. The former is C-x 4 . (xref-find-definitions-other-window), and the latter is C-x 5 . (xref-find-definitions-other-frame).

该命令的xref-find-definitions-at-mouse工作方式与 类似 xref-find-definitions,但它会在鼠标事件位置或周围查找标识符名称。该命令旨在绑定到鼠标事件,例如C-M-mouse-1

The command xref-find-definitions-at-mouse works like xref-find-definitions, but it looks for the identifier name at or around the place of a mouse event. This command is intended to be bound to a mouse event, such as C-M-mouse-1, for example.

命令C-M-.( xref-find-apropos) 类似于 apropos标签(请参阅Apropos)。它显示所选标签表中名称与指定regexp匹配的标识符列表 。这就像M-.,不同之处在于它对标识符进行正则表达式匹配,而不是将符号名称匹配为固定字符串。默认情况下,该命令会弹出*外部参考*buffer 与 一样M-.,但您可以通过自定义变量来显示额外的输出tags-apropos-additional-actions;有关详细信息,请参阅其文档。

The command C-M-. (xref-find-apropos) is like apropos for tags (see Apropos). It displays a list of identifiers in the selected tags table whose names match the specified regexp. This is just like M-., except that it does regexp matching of identifiers instead of matching symbol names as fixed strings. By default, the command pops up the *xref* buffer, like M-., but you can display additional output by customizing the variable tags-apropos-additional-actions; see its documentation for details.

如果上述任何命令找到多个匹配定义,则默认情况下会弹出*外部参考*显示匹配候选者的缓冲区。 (C-M-. 总是弹出 *外部参考*缓冲区(如果找到至少一个匹配项)。)候选者通常在该缓冲区中显示为文件名以及该文件中的匹配标识符。在该缓冲区中,您可以选择任何要显示的候选项,并且您还有几个附加命令,如以下命令中的可用命令中所述:*外部参考*缓冲。但是,如果变量的值为xref-auto-jump-to-first-definitionmove则将在 *外部参考*buffer,如果是tshow,则第一个候选者会自动显示在自己的窗口中;t还选择显示第一个候选的窗口。默认值为 nil,仅显示候选中的候选者*外部参考* 缓冲区,但不选择其中任何一个。

If any of the above commands finds more than one matching definition, it by default pops up the *xref* buffer showing the matching candidates. (C-M-. always pops up the *xref* buffer if it finds at least one match.) The candidates are normally shown in that buffer as the name of a file and the matching identifier(s) in that file. In that buffer, you can select any of the candidates for display, and you have several additional commands, described in Commands Available in the *xref* Buffer. However, if the value of the variable xref-auto-jump-to-first-definition is move, the first of these candidates is automatically selected in the *xref* buffer, and if it’s t or show, the first candidate is automatically shown in its own window; t also selects the window showing the first candidate. The default value is nil, which just shows the candidates in the *xref* buffer, but doesn’t select any of them.

要返回到显示定义M-,位置,请使用( xref-go-back)。它跳回最后一次调用的点M-.。因此,您可以使用 查找并检查某事物的定义M-.,然后返回到之前使用 的位置M-,M-,允许您追溯您在地点历史记录中前进的步骤,一直到历史记录中的第一个地点(您第一次调用 的地方)M-.,或中间的任何地点。

To go back to places from where you’ve displayed the definition, use M-, (xref-go-back). It jumps back to the point of the last invocation of M-.. Thus you can find and examine the definition of something with M-. and then return to where you were with M-,. M-, allows you to retrace the steps you made forward in the history of places, all the way to the first place in history, where you first invoked M-., or to any place in-between.

如果您之前使用 回退得太远M-,,或者想要重新检查您返回的位置,则可以使用C-M-, ( xref-go-forward) 再次前进。这与 using 类似M-.,只不过您不需要在每个步骤中将指针移动到要查找其定义的标识符。 C-M-, 允许您追溯您在地点历史记录中执行的所有步骤,一直到历史记录中您调用的最后一个地点 M-,,或者中间的任何地点。

If you previously went back too far with M-,, or want to re-examine a place from which you went back, you can use C-M-, (xref-go-forward) to go forward again. This is similar to using M-., except that you don’t need on each step to move point to the identifier whose definition you want to look up. C-M-, allows you to retrace all the steps you made back in the history of places, all the way to the last place in history, where you invoked M-,, or to any place in-between.

一些主要模式安装的xref支持设施有时可能无法找到某些标识符。例如,在 Emacs Lisp 模式下(请参阅评估 Emacs Lisp 表达式),M-.默认情况下将仅查找 Lisp 包中加载到当前 Emacs 会话中或自动加载的函数和变量(请参阅Emacs Lisp 参考手册中的自动加载)。如果找不到某些标识符,您可以尝试强制使用 后端(请参阅查找标识符参考)。为此,请使用 打开外部参照标签次要模式,然后再次调用。 (为此,请务必运行以在源文件的目录树中创建标签表,请参阅创建标签表。) M-.xrefetagsM-x xref-etags-modeM-.etags

Some major modes install xref support facilities that might sometimes fail to find certain identifiers. For example, in Emacs Lisp mode (see Evaluating Emacs Lisp Expressions) M-. will by default find only functions and variables from Lisp packages which are loaded into the current Emacs session or are auto-loaded (see Autoload in The Emacs Lisp Reference Manual). If M-. fails to find some identifiers, you can try forcing xref to use the etags backend (see Find Identifier References). To this end, turn on the Xref Etags minor mode with M-x xref-etags-mode, then invoke M-. again. (For this to work, be sure to run etags to create the tags table in the directory tree of the source files, see Creating Tags Tables.)


29.4.1.2 中可用的命令*外部参考*缓冲

29.4.1.2 Commands Available in the *xref* Buffer

中提供了以下命令*外部参考*通过特殊的 XREF 模式进行缓冲:

The following commands are provided in the *xref* buffer by the special XREF mode:

RET
RET
mouse-1
mouse-1

显示当前行 ( ) 上的引用xref-goto-xref。使用前缀参数,也埋葬*外部参考*缓冲。

Display the reference on the current line (xref-goto-xref). With prefix argument, also bury the *xref* buffer.

mouse-2
mouse-2

与 相同mouse-1,但使窗口显示 *外部参考*缓冲选定的窗口 ( xref-select-and-show-xref)。

The same as mouse-1, but make the window displaying the *xref* buffer the selected window (xref-select-and-show-xref).

n
n
.
.

移至下一个参考并将其显示在另一个窗口 ( xref-next-line) 中。

Move to the next reference and display it in the other window (xref-next-line).

N
N

移至下一个参考组的第一个参考并将其显示在另一个窗口 ( xref-next-group) 中。

Move to the first reference of the next reference group and display it in the other window (xref-next-group).

p
p
,
,

移至上一个参考并将其显示在另一个窗口 ( xref-prev-line) 中。

Move to the previous reference and display it in the other window (xref-prev-line).

P
P

移至上一个参考组的第一个参考并将其显示在另一个窗口 ( xref-prev-group) 中。

Move to the first reference of the previous reference group and display it in the other window (xref-prev-group).

C-o
C-o

xref-show-location-at-point在另一个窗口 ( ) 中显示当前行的引用。

Display the reference on the current line in the other window (xref-show-location-at-point).

r pattern RET replacement RET
r pattern RET replacement RET

对匹配模式( )的引用执行交互式查询替换 ,用replacementxref-query-replace-in-results替换匹配项。该命令只能用于 *外部参考*显示所有相关文件中标识符的所有匹配项的缓冲区。请参阅使用标识符进行搜索和替换

Perform interactive query-replace on references that match pattern (xref-query-replace-in-results), replacing the match with replacement. This command can only be used in *xref* buffers that show all the matches for an identifier in all the relevant files. See Searching and Replacing with Identifiers.

g
g

刷新内容*外部参考*缓冲 (xref-revert-buffer)。

Refresh the contents of the *xref* buffer (xref-revert-buffer).

M-,
M-,

退出显示*外部参考*缓冲区,然后跳转到前一个外部参照堆栈位置 ( xref-quit-and-pop-marker-stack)。

Quit the window showing the *xref* buffer, and then jump to the previous Xref stack location (xref-quit-and-pop-marker-stack).

q
q

退出显示*外部参考*缓冲 (xref-quit)。

Quit the window showing the *xref* buffer (xref-quit).

此外,常用的导航命令(例如箭头键、 C-n和 )C-p可用于在缓冲区中移动而不显示引用。

In addition, the usual navigation commands, such as the arrow keys, C-n, and C-p are available for moving around the buffer without displaying the references.


29.4.1.4 标识符查询

29.4.1.4 Identifier Inquiries

C-M-i
C-M-i
M-TAB
M-TAB

对点周围的文本执行补全,如果已加载 ( completion-at-point),则可能使用选定的标签表。

Perform completion on the text around point, possibly using the selected tags table if one is loaded (completion-at-point).

M-x list-tags RET file RET
M-x list-tags RET file RET

显示程序文件file中定义的标识符列表 。

Display a list of the identifiers defined in the program file file.

C-M-. regexp RET
C-M-. regexp RET

显示与正则表达式 ( )匹配的所有标识符的列表xref-find-apropos。请参阅查找标识符

Display a list of all identifiers matching regexp (xref-find-apropos). See Looking Up Identifiers.

M-x tags-next-file
M-x tags-next-file

访问所选标签表中记录的文件。

Visit files recorded in the selected tags table.

在大多数编程语言模式中,您可以键入C-M-i或 ( ) 来完成点处的符号。某些模式为该模式提供了专门的完成命令;对于那些没有的人,如果加载了标签表,则此命令可以使用它来生成完成候选者。请参阅符号名称的完成M-TABcompletion-at-point

In most programming language modes, you can type C-M-i or M-TAB (completion-at-point) to complete the symbol at point. Some modes provide specialized completion for this command tailored to the mode; for those that don’t, if there is a tags table loaded, this command can use it to generate completion candidates. See Completion for Symbol Names.

M-x list-tags读取所选标签表所涵盖的文件之一的名称,并显示该文件中定义的标签列表。不要将目录作为文件名的一部分,除非标记表中记录的文件名包含目录。此命令仅适用于 etags 后端,并且需要项目的标签表可用。请参阅标签表。如果以交互方式使用,则默认标记是当前缓冲区的文件名(如果以交互方式使用)。

M-x list-tags reads the name of one of the files covered by the selected tags table, and displays a list of tags defined in that file. Do not include a directory as part of the file name unless the file name recorded in the tags table includes a directory. This command works only with the etags backend, and requires a tags table for the project to be available. See Tags Tables. If used interactively, the default tag is file name of the current buffer if used interactively.

M-x tags-next-file访问所选标签表涵盖的文件。第一次调用时,它会访问该表覆盖的第一个文件。每个后续调用都会访问下一个覆盖的文件,除非提供了前缀参数,在这种情况下,它将返回到第一个文件。该命令需要选择一个标签表。

M-x tags-next-file visits files covered by the selected tags table. The first time it is called, it visits the first file covered by the table. Each subsequent call visits the next covered file, unless a prefix argument is supplied, in which case it returns to the first file. This command requires a tags table to be selected.


29.4.2 标签表

29.4.2 Tags Tables

标签记录通过扫描某个程序或某个文档的源代码提取的标签18 。从生成的文件中提取的标签引用原始文件,而不是在标签提取期间扫描的生成的文件。生成文件的示例包括从 Cweb 源文件、Yacc 解析器或 Lex 扫描器定义生成的 C 文件;。我预处理的C文件;以及预处理生成的 Fortran 文件.fpp源文件。

A tags table records the tags18 extracted by scanning the source code of a certain program or a certain document. Tags extracted from generated files reference the original files, rather than the generated files that were scanned during tag extraction. Examples of generated files include C files generated from Cweb source files, from a Yacc parser, or from Lex scanner definitions; .i preprocessed C files; and Fortran files produced by preprocessing .fpp source files.

要生成标签表,请etags在文档或源代码文件上运行 shell 命令。这 '电子标签' 程序将标签写入标签表文件,或简称标签文件。标签文件的常规名称是标签。请参阅创建标签表。 (也可以使用其他包中的命令之一来创建标签表,这些命令可以以相同的格式生成此类表。)

To produce a tags table, you run the etags shell command on a document or the source code file. The ‘etags’ program writes the tags to a tags table file, or tags file in short. The conventional name for a tags file is TAGS. See Creating Tags Tables. (It is also possible to create a tags table by using one of the commands from other packages that can produce such tables in the same format.)

Emacs 通过包使用标签表etags作为xref.由于标签表是由etags属于 Emacs 发行版一部分的命令生成的,因此我们在此更详细地描述标签表。

Emacs uses the tags tables via the etags package as one of the supported backends for xref. Because tags tables are produced by the etags command that is part of an Emacs distribution, we describe tags tables in more detail here.

Ebrowse 工具与 C++ 类似,etags但专门针对 C++ 定制。请参阅Ebrowse 用户手册中的Ebrowse。语义包提供了另一种独立于工具来生成和使用标签的方法。请参阅语义etags

The Ebrowse facility is similar to etags but specifically tailored for C++. See Ebrowse in Ebrowse User’s Manual. The Semantic package provides another way to generate and use tags, separate from the etags facility. See Semantic.


29.4.2.1 源文件标签语法

29.4.2.1 Source File Tag Syntax

以下是最流行语言的标签语法定义方式:

Here is how tag syntax is defined for the most popular languages:

  • 在 C 代码中,任何 C 函数或 typedef 都是标记, structunion和的定义也是标记enum#define宏定义#undefenum 常量也是标签,除非您指定 '--无定义' 制作标签表时。同样,全局变量是标签,除非您指定 '--无全局变量',结构成员也是如此,除非您指定 '--无成员'。用于 '--无全局变量','--无定义' 和 '--无成员' 可以使标签表文件变得更小。

    除了函数定义之外,您还可以通过给出 ' 来标记函数声明和外部变量--声明' 的选项 etags

  • In C code, any C function or typedef is a tag, and so are definitions of struct, union and enum. #define macro definitions, #undef and enum constants are also tags, unless you specify ‘--no-defines’ when making the tags table. Similarly, global variables are tags, unless you specify ‘--no-globals’, and so are struct members, unless you specify ‘--no-members’. Use of ‘--no-globals’, ‘--no-defines’ and ‘--no-members’ can make the tags table file much smaller.

    You can tag function declarations and external variables in addition to function definitions by giving the ‘--declarations’ option to etags.

  • 在C++代码中,除了C代码的所有标记结构之外,还可以识别成员函数;成员变量也会被识别,除非您使用 '--无成员' 选项。 operator 定义的标签名称如 '运算符+'。如果您指定 '--班级资格' 选项,类中变量和函数的标签被命名为 '::变量' 和 '::函数'。默认情况下,类方法和成员不是类限定的,这允许更准确地在源中识别它们的名称。
  • In C++ code, in addition to all the tag constructs of C code, member functions are also recognized; member variables are also recognized, unless you use the ‘--no-members’ option. operator definitions have tag names like ‘operator+’. If you specify the ‘--class-qualify’ option, tags for variables and functions in classes are named ‘class::variable’ and ‘class::function’. By default, class methods and members are not class-qualified, which allows to identify their names in the sources more accurately.
  • 在 Java 代码中,标签包括 C++ 中识别的所有结构,以及interface,extendsimplements结构。类中变量和函数的标签被命名为“班级多变的' 和 '班级功能'。
  • In Java code, tags include all the constructs recognized in C++, plus the interface, extends and implements constructs. Tags for variables and functions in classes are named ‘class.variable’ and ‘class.function’.
  • \chapter在 LaTeX 文档中, \section, \subsection, \subsubsection, , \eqno, \label, \ref, \cite, \bibitem, \part, \appendix, \entry, , \index, \def, \newcommand,\renewcommand\newenvironment的参数\renewenvironment是标签。

    TEXTAGS如果您在调用之前在环境变量中指定它们,其他命令也可以创建标签etags。该环境变量的值应该是以冒号分隔的命令名称列表。例如,

    TEXTAGS="mycommand:myothercommand"
    导出文本标签
    

    指定(使用 Bourne shell 语法)命令 '\我的命令' 和 '\myother 命令' 还定义标签。

  • In LaTeX documents, the arguments for \chapter, \section, \subsection, \subsubsection, \eqno, \label, \ref, \cite, \bibitem, \part, \appendix, \entry, \index, \def, \newcommand, \renewcommand, \newenvironment and \renewenvironment are tags.

    Other commands can make tags as well, if you specify them in the environment variable TEXTAGS before invoking etags. The value of this environment variable should be a colon-separated list of command names. For example,

    TEXTAGS="mycommand:myothercommand"
    export TEXTAGS
    

    specifies (using Bourne shell syntax) that the commands ‘\mycommand’ and ‘\myothercommand’ also define tags.

  • 在 Lisp 代码中,用 定义的任何函数、用ordefun定义的任何变量,以及通常以 ' 开头的任何表达式的第一个参数defvardefconst(定义' 零列中是一个标签。作为例外,形式的表达式 被视为声明,并且仅在 '(defvar foo)--声明' 给出了选项。
  • In Lisp code, any function defined with defun, any variable defined with defvar or defconst, and in general the first argument of any expression that starts with ‘(def’ in column zero is a tag. As an exception, expressions of the form (defvar foo) are treated as declarations, and are only tagged if the ‘--declarations’ option is given.
  • 在Scheme代码中,标签包括用def或用名称以'开头的构造定义的任何内容定义'。它们还包括set!在文件顶层 设置的变量。
  • In Scheme code, tags include anything defined with def or with a construct whose name starts with ‘def’. They also include variables set with set! at top level in the file.

还支持其他几种语言:

Several other languages are also supported:

  • 在 Ada 代码中,函数、过程、包、任务和类型都是标签。使用 '--仅包' 仅为包创建标签的选项。

    在 Ada 中,相同的名称可以用于不同类型的实体(例如,过程和函数)。此外,对于包、过程和函数之类的东西,还有规范(即接口)和主体(即实现)。为了更轻松地选择所需的定义,Ada 标记名称具有指示实体类型的后缀:

    '/b'

    封装体。

    '/F'

    功能。

    '/k'

    任务。

    '/p'

    程序。

    '/秒'

    封装规格

    '/吨'

    类型。

    因此,将直接进入包的主体,而只会搜索任何标签 。 M-x find-tag RET bidule/b RETbiduleM-x find-tag RET bidule RETbidule

  • In Ada code, functions, procedures, packages, tasks and types are tags. Use the ‘--packages-only’ option to create tags for packages only.

    In Ada, the same name can be used for different kinds of entity (e.g., for a procedure and for a function). Also, for things like packages, procedures and functions, there is the spec (i.e., the interface) and the body (i.e., the implementation). To make it easier to pick the definition you want, Ada tag names have suffixes indicating the type of entity:

    /b

    package body.

    /f

    function.

    /k

    task.

    /p

    procedure.

    /s

    package spec.

    /t

    type.

    Thus, M-x find-tag RET bidule/b RET will go directly to the body of the package bidule, while M-x find-tag RET bidule RET will just search for any tag bidule.

  • 在汇编代码中,出现在行开头并后跟冒号的标签是标记。
  • In assembler code, labels appearing at the start of a line, followed by a colon, are tags.
  • 在 Bison 或 Yacc 输入文件中,每个规则将其构造的非终结符定义为标签。文件中包含 C 代码的部分被解析为 C 代码。
  • In Bison or Yacc input files, each rule defines as a tag the nonterminal it constructs. The portions of the file that contain C code are parsed as C code.
  • 在 Cobol 代码中,标签是段落名称;也就是说,从第 8 列开始并后跟句点的任何单词。
  • In Cobol code, tags are paragraph names; that is, any word starting in column 8 and followed by a period.
  • 在Erlang代码中,标签是文件中定义的函数、记录和宏。
  • In Erlang code, the tags are the functions, records and macros defined in the file.
  • 在 Fortran 代码中,函数、子例程和块数据都是标签。
  • In Fortran code, functions, subroutines and block data are tags.
  • 在 Go 代码中,包、函数和类型都是标签。
  • In Go code, packages, functions, and types are tags.
  • 在 HTML 输入文件中,标签是 和title, h1, h2h3头。此外,标签位于name=锚点和所有出现的id=.
  • In HTML input files, the tags are the title and the h1, h2, h3 headers. Also, tags are name= in anchors and all occurrences of id=.
  • 在Lua输入文件中,所有函数都是标签。
  • In Lua input files, all functions are tags.
  • 在 makefile 中,目标是标签;此外,变量是标签,除非您指定 '--无全局变量'。
  • In makefiles, targets are tags; additionally, variables are tags unless you specify ‘--no-globals’.
  • 在 Objective C 代码中,标签包括类、类类别、方法和协议的 Objective C 定义。类中变量和函数的标签命名为“::变量' 和 '::函数'。
  • In Objective C code, tags include Objective C definitions for classes, class categories, methods and protocols. Tags for variables and functions in classes are named ‘class::variable’ and ‘class::function’.
  • 在 Pascal 代码中,标签是文件中定义的函数和过程。
  • In Pascal code, the tags are the functions and procedures defined in the file.
  • 在 Perl 代码中,标签是由packagesubuse constantmylocal关键字定义的包、子例程和变量。使用 '--全局变量' 如果你想标记全局变量。子例程的标签命名为 '::'。默认包中定义的子例程的名称是 '主要::'。
  • In Perl code, the tags are the packages, subroutines and variables defined by the package, sub, use constant, my, and local keywords. Use ‘--globals’ if you want to tag global variables. Tags for subroutines are named ‘package::sub’. The name for subroutines defined in the default package is ‘main::sub’.
  • 在 PHP 代码中,标签是函数、类和定义。变量也是标签,除非你使用 '--无成员' 选项。
  • In PHP code, tags are functions, classes and defines. Vars are tags too, unless you use the ‘--no-members’ option.
  • 在 PostScript 代码中,标签就是函数。
  • In PostScript code, the tags are the functions.
  • 在 Prolog 代码中,标签是行首的谓词和规则。
  • In Prolog code, tags are predicates and rules at the beginning of line.
  • 在Python代码中,def或者class在行的开头生成一个标签。
  • In Python code, def or class at the beginning of a line generate a tag.
  • 在 Ruby 代码中,defclassmodule在行的开头生成一个标记。常量也会生成标签。
  • In Ruby code, def or class or module at the beginning of a line generate a tag. Constants also generate tags.
  • 在 Rust 代码中,标记用fnenum或 定义struct的任何内容macro_rules!
  • In Rust code, tags anything defined with fn, enum, struct or macro_rules!.

您还可以基于正则表达式匹配生成标签(请参阅Etags Regexps)以处理其他格式和语言。

You can also generate tags based on regexp matching (see Etags Regexps) to handle other formats and languages.


29.4.2.2 创建标签表

29.4.2.2 Creating Tags Tables

etags程序用于创建标签表文件。它知道多种语言的语法,如 源文件标记语法中所述。以下是如何运行etags

The etags program is used to create a tags table file. It knows the syntax of several languages, as described in Source File Tag Syntax. Here is how to run etags:

etags输入文件...
etags inputfiles

程序etags读取指定的文件,并写入一个名为的标签表标签在当前工作目录中。您可以选择使用 ' 为标签表指定不同的文件名--输出=文件' 选项;指定-作为文件名将标签表打印到标准输出。您还可以使用 ' 将新创建的标签表附加到现有文件中- 附加' 选项。

The etags program reads the specified files, and writes a tags table named TAGS in the current working directory. You can optionally specify a different file name for the tags table by using the ‘--output=file’ option; specifying - as a file name prints the tags table to standard output. You can also append the newly created tags table to an existing file by using the ‘--append’ option.

如果指定的文件不存在,则etags查找它们的压缩版本并解压缩它们以读取它们。在 MS-DOS 下,etags还查找文件名,例如mycode.cgz 如果给出'mycode.c' 在命令行上和mycode.c 不存在。

If the specified files don’t exist, etags looks for compressed versions of them and uncompresses them to read them. Under MS-DOS, etags also looks for file names like mycode.cgz if it is given ‘mycode.c’ on the command line and mycode.c does not exist.

如果标签表由于其中描述的文件发生更改而变得过时,您可以通过etags 再次运行该程序来更新它。如果标签表没有记录标签,或者将其记录到错误的文件中,那么在更新标签表之前,Emacs 将无法找到该定义。但如果标签表中记录的位置变得有点错误(由于其他编辑),Emacs 仍然能够找到正确的位置,但会稍有延迟。

If the tags table becomes outdated due to changes in the files described in it, you can update it by running the etags program again. If the tags table does not record a tag, or records it for the wrong file, then Emacs will not be able to find that definition until you update the tags table. But if the position recorded in the tags table becomes a little bit wrong (due to other editing), Emacs will still be able to find the right position, with a slight delay.

因此,无需在每次编辑后更新标签表。当您定义要列出的新标签时,或者当您将标签定义从一个文件移动到另一个文件时,或者当更改变得重大时,您应该更新标签表。

Thus, there is no need to update the tags table after each edit. You should update a tags table when you define new tags that you want to have listed, or when you move tag definitions from one file to another, or when changes become substantial.

您可以通过传递 '使标签表包含另一个标签表--include=文件' 的选项etags。然后它覆盖包含的标签文件覆盖的所有文件以及它自己的文件。

You can make a tags table include another tags table, by passing the ‘--include=file’ option to etags. It then covers all the files covered by the included tags file, as well as its own.

如果您在运行时指定具有相对文件名的源文件 etags,则标签文件将包含相对于最初写入标签文件的目录的文件名。这样,您可以移动包含标签文件和源文件的整个目录树,并且标签文件仍将正确引用源文件。如果标签文件是-或者是在/dev目录,但是文件名是相对于当前工作目录的。例如,当将标签写入标准输出时,这很有用。

If you specify the source files with relative file names when you run etags, the tags file will contain file names relative to the directory where the tags file was initially written. This way, you can move an entire directory tree containing both the tags file and the source files, and the tags file will still refer correctly to the source files. If the tags file is - or is in the /dev directory, however, the file names are made relative to the current working directory. This is useful, for example, when writing the tags to the standard output.

使用相对文件名时,它不应该是指向不同目录中的标记文件的符号链接,因为这通常会使文件名无效。

When using a relative file name, it should not be a symbolic link pointing to a tags file in a different directory, because this would generally render the file names invalid.

如果您指定绝对文件名作为 的参数etags,则标记文件将包含绝对文件名。这样,即使您移动标签文件,只要源文件保留在同一位置,标签文件仍将引用相同的文件。绝对文件名以 ' 开头/',或与 '设备:/' 在 MS-DOS 和 MS-Windows 上。

If you specify absolute file names as arguments to etags, then the tags file will contain absolute file names. This way, the tags file will still refer to the same files even if you move it, as long as the source files remain in the same place. Absolute file names start with ‘/’, or with ‘device:/’ on MS-DOS and MS-Windows.

当您想要从大量文件创建标签表时,在命令行上列出它们可能会遇到问题,因为某些系统对其长度有限制。您可以通过告诉etags从标准输入读取文件名来规避此限制,方法是键入破折号代替文件名,如下所示:

When you want to make a tags table from a great number of files, you may have problems listing them on the command line, because some systems have a limit on its length. You can circumvent this limit by telling etags to read the file names from its standard input, by typing a dash in place of the file names, like this:

寻找 。 -名称“*。[chCH]”-打印|电子标签-
find . -name "*.[chCH]" -print | etags -

etags根据文件名和内容识别输入文件中使用的语言。它首先尝试将文件名和扩展名与某些语言常用的文件名和扩展名相匹配。某些语言的解释器名称已知(例如,perlPerl 或plProlog),因此etags接下来寻找以下形式的解释器规范:#!插值' 在输入文件的第一行,并将其与已知的解释器进行匹配。如果这些都不起作用,或者如果您想覆盖语言的自动检测,您可以使用 ' 显式指定语言--语言=名称' 选项。您可以将这些选项与文件名混合使用;每一项都适用于其后面的文件名。指定 '--语言=自动' 告诉etags继续从文件名和文件内容猜测语言。指定 '--语言=无' 完全关闭特定于语言的处理;然后etags仅通过正则表达式匹配来识别标签(请参阅Etags Regexps)。当输入文件使用 尚未支持的语言etags,并且您希望避免使用etagsFortran 和 C 作为默认语言时,这会派上用场。

etags recognizes the language used in an input file based on its file name and contents. It first tries to match the file’s name and extension to the ones commonly used with certain languages. Some languages have interpreters with known names (e.g., perl for Perl or pl for Prolog), so etags next looks for an interpreter specification of the form ‘#!interp’ on the first line of an input file, and matches that against known interpreters. If none of that works, or if you want to override the automatic detection of the language, you can specify the language explicitly with the ‘--language=name’ option. You can intermix these options with file names; each one applies to the file names that follow it. Specify ‘--language=auto’ to tell etags to resume guessing the language from the file names and file contents. Specify ‘--language=none’ to turn off language-specific processing entirely; then etags recognizes tags by regexp matching alone (see Etags Regexps). This comes in handy when an input file uses a language not yet supported by etags, and you want to avoid having etags fall back on Fortran and C as the default languages.

选项 '--parse-stdin=文件etags' 在从程序调用时最有用。它可以在命令行上使用(仅一次)代替文件名。 etags将从标准输入读取并将生成的标签标记为属于文件 file

The option ‘--parse-stdin=file’ is mostly useful when calling etags from programs. It can be used (only once) in place of a file name on the command line. etags will read from standard input and mark the produced tags as belonging to the file file.

对于 C 和 C++,如果源文件不遵守 GNU 编码标准的约定,如果有大括号 ('{' 和 '}') 在第 0 列中仅适用于顶级定义,例如函数和 struct定义,我们建议您使用 '--忽略缩进' 选项,以防止etags错误地解释零列中的右大括号。

For C and C++, if the source files don’t observe the GNU Coding Standards’ convention if having braces (‘{’ and ‘}’) in column zero only for top-level definitions, like functions and struct definitions, we advise that you use the ‘--ignore-indentation’ option, to prevent etags from incorrectly interpreting closing braces in column zero.

'etags--帮助' 输出已知的语言列表etags ,以及猜测语言的文件名规则。它还打印所有可用选项的列表etags以及简短的说明。如果后面跟着一个或多个 '--语言=语言' 选项,它输出有关如何为lang生成标签的详细信息 。

etags --help’ outputs the list of the languages etags knows, and the file name rules for guessing the language. It also prints a list of all the available etags options, together with a short explanation. If followed by one or more ‘--language=lang’ options, it outputs detailed information about how tags are generated for lang.


29.4.2.3 Etag 正则表达式

29.4.2.3 Etags Regexps

这 '--正则表达式' 选项允许etags通过正则表达式匹配来识别标签。您可以将此选项与文件名混合使用;每一项都适用于其后面的源文件。如果您指定多个 '--正则表达式' 选项,所有这些选项都是并行使用的。语法是:

The ‘--regex’ option to etags allows tags to be recognized by regular expression matching. You can intermix this option with file names; each one applies to the source files that follow it. If you specify multiple ‘--regex’ options, all of them are used in parallel. The syntax is:

--regex=[ {language} ]/ tagregexp /[ nameregexp /]修饰符
--regex=[{language}]/tagregexp/[nameregexp/]modifiers

选项值的基本部分是tagregexp,用于匹配标签的正则表达式。它始终用于锚定,即仅匹配行的开头。如果您想允许缩进标签,请使用与初始空格匹配的正则表达式;以 ' 开头[\t]*'。

The essential part of the option value is tagregexp, the regexp for matching tags. It is always used anchored, that is, it only matches at the beginning of a line. If you want to allow indented tags, use a regexp that matches initial whitespace; start it with ‘[ \t]*’.

在这些正则表达式中,'\' 引用下一个字符,并且支持所有 C 字符转义序列:'\A'对于铃声,'\b'用于后部空间,'\e'为了逃避,'\F' 对于换页,'\n'对于换行符,'\r' 对于回车,'\t' 对于选项卡,并且 '\v' 用于垂直制表符。此外, '\d' 代表DEL字符。

In these regular expressions, ‘\’ quotes the next character, and all the C character escape sequences are supported: ‘\a’ for bell, ‘\b’ for back space, ‘\e’ for escape, ‘\f’ for formfeed, ‘\n’ for newline, ‘\r’ for carriage return, ‘\t’ for tab, and ‘\v’ for vertical tab. In addition, ‘\d’ stands for the DEL character.

理想情况下,tagregexp匹配的字符不应多于识别您要标记的内容所需的字符。如果语法要求您编写tagregexp以便匹配标签本身之外的更多字符,您应该添加一个nameregexp,以仅挑选标签。这将使 Emacs 能够更准确地查找标签并更可靠地完成标签名称。在nameregexp中,使用“反向引用”(参见正则表达式中的反斜杠)来括号分组通常很方便\(...\)'tagregexp中。例如, '\1' 指的是第一个这样的带括号的分组。您可以在下面找到一些这样的示例。

Ideally, tagregexp should not match more characters than are needed to recognize what you want to tag. If the syntax requires you to write tagregexp so it matches more characters beyond the tag itself, you should add a nameregexp, to pick out just the tag. This will enable Emacs to find tags more accurately and to do completion on tag names more reliably. In nameregexp, it is frequently convenient to use “back references” (see Backslash in Regular Expressions) to parenthesized groupings ‘\( … \) in tagregexp. For example, ‘\1’ refers to the first such parenthesized grouping. You can find some examples of this below.

修饰符是零个或多个字符的序列,用于修改匹配etags的方式。不带修饰符的正则表达式以区分大小写的方式顺序应用于输入文件的每一行。修饰符及其含义是:

The modifiers are a sequence of zero or more characters that modify the way etags does the matching. A regexp with no modifiers is applied sequentially to each line of the input file, in a case-sensitive way. The modifiers and their meanings are:

''
i

匹配此正则表达式时忽略大小写。

Ignore case when matching this regexp.

''
m

将此正则表达式与整个文件匹配,以便可以进行多行匹配。

Match this regular expression against the whole file, so that multi-line matches are possible.

's'
s

将此正则表达式与整个文件匹配,并允许 '' 在tagregexp中匹配换行符。

Match this regular expression against the whole file, and allow ‘.’ in tagregexp to match newlines.

这 '-R' 选项取消前面 ' 定义的所有正则表达式--正则表达式' 选项。它也适用于其后面的文件名。这是一个例子:

The ‘-R’ option cancels all the regexps defined by preceding ‘--regex’ options. It too applies to the file names following it. Here’s an example:

etags --regex=/ reg1 /i voo.doo --regex=/ reg2 /m \
    bar.ber -R --lang=lisp los.er
etags --regex=/reg1/i voo.doo --regex=/reg2/m \
    bar.ber -R --lang=lisp los.er

这里etags选择解析语言呜呜理发师根据他们的内容。 etags还使用 reg1来识别其他标签呜呜,以及 reg1reg2来识别附加标签 理发师reg1针对每一行进行检查 呜呜理发师,以不区分大小写的方式,而 reg2 则针对整体进行检查理发师文件,允许以区分大小写的方式进行多行匹配。 etags 仅使用 Lisp 标签规则,没有用户指定的正则表达式匹配来识别中的标签失败者

Here etags chooses the parsing language for voo.doo and bar.ber according to their contents. etags also uses reg1 to recognize additional tags in voo.doo, and both reg1 and reg2 to recognize additional tags in bar.ber. reg1 is checked against each line of voo.doo and bar.ber, in a case-insensitive way, while reg2 is checked against the whole bar.ber file, permitting multi-line matches, in a case-sensitive way. etags uses only the Lisp tags rules, with no user-specified regexp matching, to recognize tags in los.er.

您可以限制 '--正则表达式' 选项通过使用可选前缀{language}来仅匹配给定语言的文件。 ('etags--帮助' 打印 所识别的语言列表 。)这在文件中etags存储许多预定义的正则表达式时特别有用。etags以下示例标记DEFVAREmacs 源文件中的宏,仅适用于 C 语言:

You can restrict a ‘--regex’ option to match only files of a given language by using the optional prefix {language}. (‘etags --help’ prints the list of languages recognized by etags.) This is particularly useful when storing many predefined regular expressions for etags in a file. The following example tags the DEFVAR macros in the Emacs source files, for the C language only:

--regex='{c}/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/\1/'
--regex='{c}/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/\1/'

当您有复杂的正则表达式时,可以将它们的列表存储在文件中。以下选项语法指示etags读取两个正则表达式文件。第二个文件中包含的正则表达式的匹配不区分大小写。

When you have complex regular expressions, you can store the list of them in a file. The following option syntax instructs etags to read two files of regular expressions. The regular expressions contained in the second file are matched without regard to case.

--regex=@区分大小写的文件--ignore-case-regex=@忽略大小写的文件
--regex=@case-sensitive-file --ignore-case-regex=@ignore-case-file

正则表达式文件etags每行包含一个正则表达式。空行以及以空格或制表符开头的行将被忽略。当一行中的第一个字符是 '@',etags假设该行的其余部分是另一个正则表达式文件的名称;因此,一个这样的文件可以包含另一个文件。所有其他行都被视为正则表达式。如果该行的第一个非空白文本是 '--',该行是注释。

A regex file for etags contains one regular expression per line. Empty lines, and lines beginning with space or tab are ignored. When the first character in a line is ‘@’, etags assumes that the rest of the line is the name of another file of regular expressions; thus, one such file can include another file. All the other lines are taken to be regular expressions. If the first non-whitespace text on the line is ‘--’, that line is a comment.

例如,我们可以创建一个名为“emacs.标签' 包含以下内容:

For example, we can create a file called ‘emacs.tags’ with the following contents:

        -- 这是 GNU Emacs C 源文件
{c}/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/\1/
        -- This is for GNU Emacs C source files
{c}/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/\1/

然后像这样使用它:

and then use it like this:

etags --regex=@emacs.tags *.[ch] */*.[ch]
etags --regex=@emacs.tags *.[ch] */*.[ch]

这里还有一些例子。引用正则表达式是为了保护它们免受 shell 解释。

Here are some more examples. The regexps are quoted to protect them from shell interpretation.

  • 标记八度文件:
    etags --语言=无 \
          --regex='/[ \t]*函数.*=[ \t]*\([^ \t]*\)[ \t]*(/\1/' \
          --regex='/###key \(.*\)/\1/' \
          --regex='/[ \t]*全局[ \t].*/' \
          *.m
    

    请注意,不会为脚本生成标签,因此您必须自己添加一行形式的 '###key脚本名称'如果你想跳到它。

  • Tag Octave files:
    etags --language=none \
          --regex='/[ \t]*function.*=[ \t]*\([^ \t]*\)[ \t]*(/\1/' \
          --regex='/###key \(.*\)/\1/' \
          --regex='/[ \t]*global[ \t].*/' \
          *.m
    

    Note that tags are not generated for scripts, so that you have to add a line by yourself of the form ‘###key scriptname’ if you want to jump to it.

  • 标记 Tcl 文件:
    etags --语言=无 --regex='/proc[ \t]+\([^ \t]+\)/\1/' *.tcl
    
  • Tag Tcl files:
    etags --language=none --regex='/proc[ \t]+\([^ \t]+\)/\1/' *.tcl
    
  • 标记 VHDL 文件:
    etags --语言=无 \
      --regex='/[ \t]*\(架构\|配置\) +[^ ]* +OF/' \
      --regex='/[ \t]*\(属性\|实体\|功能\|包\
      \( 正文\)?\|过程\|过程\|类型\)[ \t]+\([^ \t(]+\)/\3/'
    
  • Tag VHDL files:
    etags --language=none \
      --regex='/[ \t]*\(ARCHITECTURE\|CONFIGURATION\) +[^ ]* +OF/' \
      --regex='/[ \t]*\(ATTRIBUTE\|ENTITY\|FUNCTION\|PACKAGE\
      \( BODY\)?\|PROCEDURE\|PROCESS\|TYPE\)[ \t]+\([^ \t(]+\)/\3/'
    

29.4.3 选择标签表

29.4.3 Selecting a Tags Table

Emacs 在任何时候最多有一个选定的标签表。所有用于处理标签表的命令首先使用选定的标签表。要选择标签表,请键入M-x visit-tags-table,它将读取标签表文件名作为参数,并使用标签默认为包含名为的文件的第一个目录标签 从默认目录向上递归搜索时遇到。

Emacs has at any time at most one selected tags table. All the commands for working with tags tables use the selected one first. To select a tags table, type M-x visit-tags-table, which reads the tags table file name as an argument, with TAGS defaulting to the first directory that contains a file named TAGS encountered when recursively searching upward from the default directory.

在您尝试使用标签表内容之前,Emacs 并不真正读取它们;所做visit-tags-table的只是将文件名存储在变量中tags-file-name,仅此而已。该变量的初始值为nil;该值告诉所有使用标签表的命令,它们必须要求提供要使用的标签表文件名。

Emacs does not actually read in the tags table contents until you try to use them; all visit-tags-table does is store the file name in the variable tags-file-name, and not much more. The variable’s initial value is nil; that value tells all the commands for working with tags tables that they must ask for a tags table file name to use.

除了选定的标签表之外,Emacs 还维护您一起使用的多个标签表的列表。例如,如果您正在开发一个使用库的程序,您可能希望程序和库的标签表都可用,以便 Emacs 可以轻松地从两者中找到标识符。如果所选标签表没有标识符或未提及标签命令所需的源文件,则该命令将尝试使用当前标签表列表中的所有其他标签表。

In addition to the selected tags table, Emacs maintains the list of several tags tables that you use together. For example, if you are working on a program that uses a library, you may wish to have the tags tables of both the program and the library available, so that Emacs could easily find identifiers from both. If the selected tags table doesn’t have the identifier or doesn’t mention the source file a tags command needs, the command will try using all the other tags tables in the current list of tags tables.

当另一个标签表已加载时,使用visit-tags-table加载新标签表可以为您提供一个选择:您可以将新标签表添加到当前标签表列表中,或者放弃当前列表并开始一个新列表。如果您启动一个新列表,则会使用新标签表而不是其他标签表。如果将新表添加到当前列表中,则会使用该新表以及其他表。

Using visit-tags-table to load a new tags table when another tags table is already loaded gives you a choice: you can add the new tags table to the current list of tags tables, or discard the current list and start a new list. If you start a new list, the new tags table is used instead of others. If you add the new table to the current list, it is used as well as the others.

您可以通过将变量设置 tags-table-list为目录名称列表来指定标签表的精确列表,如下所示:

You can specify a precise list of tags tables by setting the variable tags-table-list to a list of directory names, like this:

(setq 标签表列表
      '(“~/.emacs.d”“/usr/local/lib/emacs/src”))
(setq tags-table-list
      '("~/.emacs.d" "/usr/local/lib/emacs/src"))

这告诉标签命令查看标签文件在你的 〜/ .emacs.d目录和在/usr/local/lib/emacs/src 目录。顺序取决于您所在的文件以及哪个标签表提到了该文件。

This tells the tags commands to look at the TAGS files in your ~/.emacs.d directory and in the /usr/local/lib/emacs/src directory. The order depends on which file you are in and which tags table mentions that file.

不要同时设置tags-file-nametags-table-list

Do not set both tags-file-name and tags-table-list.


29.5 Emacs开发环境

29.5 Emacs Development Environment

EDE(Emacs 开发环境)是一个软件包,可简化使用 Emacs 创建、构建和调试大型程序的任务。它提供了 Emacs 中 IDE(或集成开发环境)的一些功能。

EDE (Emacs Development Environment) is a package that simplifies the task of creating, building, and debugging large programs with Emacs. It provides some of the features of an IDE, or Integrated Development Environment, in Emacs.

本节提供 EDE 用法的简要说明。有关完整详细信息,请参阅Emacs 开发环境中的EDE

This section provides a brief description of EDE usage. For full details, see EDE in Emacs Development Environment.

EDE 作为全局次要模式实现(请参阅次要模式)。要启用它,请键入M-x global-ede-mode或单击“项目支持(EDE)' 中的项目工具' 菜单。您还可以在每次启动 Emacs 时启用 EDE,方法是将以下行添加到初始化文件中:

EDE is implemented as a global minor mode (see Minor Modes). To enable it, type M-x global-ede-mode or click on the ‘Project Support (EDE)’ item in the ‘Tools’ menu. You can also enable EDE each time you start Emacs, by adding the following line to your initialization file:

(全局 ede 模式 t)
(global-ede-mode t)

激活 EDE 会添加一个名为 '发展' 到菜单栏。许多 EDE 命令,包括下面描述的命令,都可以从此菜单调用。

Activating EDE adds a menu named ‘Development’ to the menu bar. Many EDE commands, including the ones described below, can be invoked from this menu.

EDE 将文件组织到项目中,项目对应于目录树。项目根目录是项目的最顶层目录。要定义新项目,请访问所需项目根目录中的文件并输入M-x ede-new.此命令提示输入 项目类型,它指的是 EDE 将用于管理项目的底层方法(请参阅Emacs 开发环境中的EDE)。最常见的项目类型是'制作',它使用 Makefile,以及 '汽车制造商',它使用 GNU Automake(请参阅Automake中的Automake)。在这两种情况下,EDE 还会创建一个名为项目.ede,它存储有关项目的信息。

EDE organizes files into projects, which correspond to directory trees. The project root is the topmost directory of a project. To define a new project, visit a file in the desired project root and type M-x ede-new. This command prompts for a project type, which refers to the underlying method that EDE will use to manage the project (see EDE in Emacs Development Environment). The most common project types are ‘Make’, which uses Makefiles, and ‘Automake’, which uses GNU Automake (see Automake in Automake). In both cases, EDE also creates a file named Project.ede, which stores information about the project.

一个项目可能包含一个或多个目标。目标可以是目标文件、可执行程序或某种其他类型的文件,它们是根据项目中的一个或多个文件构建的。

A project may contain one or more targets. A target can be an object file, executable program, or some other type of file, which is built from one or more of the files in the project.

要将新目标添加到项目,请键入C-c . t ( M-x ede-new-target)。此命令还会询问您是否希望将当前文件添加到该目标,这意味着目标将从该文件构建。定义目标后,您可以通过键入C-c . a ( ede-add-file) 向其中添加更多文件。

To add a new target to a project, type C-c . t (M-x ede-new-target). This command also asks if you wish to add the current file to that target, which means that the target is to be built from that file. After you have defined a target, you can add more files to it by typing C-c . a (ede-add-file).

要构建目标,请键入C-c . c( ede-compile-target)。要构建项目中的所有目标,请键入C-c . C ( ede-compile-project)。 EDE 使用文件类型来猜测应该如何构建目标。

To build a target, type C-c . c (ede-compile-target). To build all the targets in the project, type C-c . C (ede-compile-project). EDE uses the file types to guess how the target should be built.


29.6 使用 Emerge 合并文件

29.6 Merging Files with Emerge

对于程序员来说,交叉信号并在两个不同方向修改同一个程序并不罕见。要摆脱这种混乱,您需要合并两个版本。 Emerge 使这变得更容易。有关比较文件的其他方法,请参阅 《Ediff 手册》中的比较文件Ediff

It’s not unusual for programmers to get their signals crossed and modify the same program in two different directions. To recover from this confusion, you need to merge the two versions. Emerge makes this easier. For other ways to compare files, see Comparing Files, and Ediff in The Ediff Manual.


29.6.1 Emerge 概述

29.6.1 Overview of Emerge

要启动 Emerge,请运行以下四个命令之一:

To start Emerge, run one of these four commands:

M-x emerge-files
M-x emerge-files

合并两个指定的文件。

Merge two specified files.

M-x emerge-files-with-ancestor
M-x emerge-files-with-ancestor

参考共同的祖先合并两个指定的文件。

Merge two specified files, with reference to a common ancestor.

M-x emerge-buffers
M-x emerge-buffers

合并两个缓冲区。

Merge two buffers.

M-x emerge-buffers-with-ancestor
M-x emerge-buffers-with-ancestor

参考第三个缓冲区中的共同祖先合并两个缓冲区。

Merge two buffers with reference to a common ancestor in a third buffer.

Emerge 命令比较两个文件或缓冲区,并在三个缓冲区中显示比较结果:一个用于每个输入文本(A 缓冲区B 缓冲区),另一个(合并缓冲区)用于进行合并。合并缓冲区显示完整的合并文本,而不仅仅是差异。无论两个输入文本有何不同,您都可以选择将其中之一包含在合并缓冲区中。

The Emerge commands compare two files or buffers, and display the comparison in three buffers: one for each input text (the A buffer and the B buffer), and one (the merge buffer) where merging takes place. The merge buffer shows the full merged text, not just the differences. Wherever the two input texts differ, you can choose which one of them to include in the merge buffer.

从现有缓冲区获取输入的 Emerge 命令仅使用这些缓冲区的可访问部分(如果这些缓冲区已缩小)。请参阅缩小范围

The Emerge commands that take input from existing buffers use only the accessible portions of those buffers, if they are narrowed. See Narrowing.

如果有一个共同的祖先版本可用,并且要合并的两个文本均源自该版本,则 Emerge 可以使用它来猜测哪个替代方案是正确的。无论一个当前版本与祖先一致,Emerge 都会假定另一个当前版本是有意更改,应保留在合并版本中。使用 '有祖先' 命令,如果您想指定共同的祖先文本。这些命令读取三个文件或缓冲区名称 - 变体 A、变体 B 和共同祖先。

If a common ancestor version is available, from which the two texts to be merged were both derived, Emerge can use it to guess which alternative is right. Wherever one current version agrees with the ancestor, Emerge presumes that the other current version is a deliberate change which should be kept in the merged version. Use the ‘with-ancestor’ commands if you want to specify a common ancestor text. These commands read three file or buffer names—variant A, variant B, and the common ancestor.

比较完成并准备好缓冲区后,交互式合并开始。您可以通过在合并缓冲区中键入特殊合并命令来控制合并 (请参阅合并命令)。对于输入文本之间的每一轮差异,您可以选择保留其中的一个,或一起编辑它们。

After the comparison is done and the buffers are prepared, the interactive merging starts. You control the merging by typing special merge commands in the merge buffer (see Merge Commands). For each run of differences between the input texts, you can choose which one of them to keep, or edit them both together.

合并缓冲区使用一种特殊的主要模式,即 Emerge 模式,以及用于进行这些选择的命令。但您也可以使用普通的 Emacs 命令编辑缓冲区。

The merge buffer uses a special major mode, Emerge mode, with commands for making these choices. But you can also edit the buffer with ordinary Emacs commands.

在任何给定时间,Emerge 的注意力都集中在一个特定的差异上,称为选定的差异。这种差异在三个缓冲区中被标记出来,如下所示:

At any given time, the attention of Emerge is focused on one particular difference, called the selected difference. This difference is marked off in the three buffers like this:

vvvvvvvvvvvvvvvvvvv
不同的文字
^^^^^^^^^^^^^^^^^^^^^^
vvvvvvvvvvvvvvvvvvvv
text that differs
^^^^^^^^^^^^^^^^^^^^

按顺序出现所有差异的编号,模式行始终显示所选差异的编号。

Emerge numbers all the differences sequentially and the mode line always shows the number of the selected difference.

通常,合并缓冲区从文本的 A 版本开始。但是,当差异的 A 版本与共同祖先一致时,则该差异最初会首选 B 版本。

Normally, the merge buffer starts out with the A version of the text. But when the A version of a difference agrees with the common ancestor, then the B version is initially preferred for that difference.

退出时,Emerge 会将合并的文本保留在合并缓冲区中。此时,您可以将其保存在带有C-x C-w.如果您给emerge-files或 一个数字参数emerge-files-with-ancestor,它会使用迷你缓冲区读取输出文件的名称。 (这是这些命令读取的最后一个文件名。)然后退出 Emerge 会将合并的文本保存在输出文件中。

Emerge leaves the merged text in the merge buffer when you exit. At that point, you can save it in a file with C-x C-w. If you give a numeric argument to emerge-files or emerge-files-with-ancestor, it reads the name of the output file using the minibuffer. (This is the last file name those commands read.) Then exiting from Emerge saves the merged text in the output file.

通常,Emerge 命令在退出时将输出缓冲区保存在其文件中。如果使用 中止 Emerge C-],Emerge 命令不会保存输出缓冲区,但如果您愿意,可以自行保存。

Normally, Emerge commands save the output buffer in its file when you exit. If you abort Emerge with C-], the Emerge command does not save the output buffer, but you can save it yourself if you wish.


29.6.2 Emerge 的子模式

29.6.2 Submodes of Emerge

您可以选择两种模式来发出合并命令:快速模式和编辑模式。在快速模式下,基本合并命令是单个字符,但普通 Emacs 命令被禁用。如果您仅使用合并命令,这会很方便。在编辑模式下,所有合并命令都以前缀 key 开头C-c C-c,并且普通的 Emacs 命令也可用。这允许编辑合并缓冲区,但会减慢 Emerge 操作。

You can choose between two modes for giving merge commands: Fast mode and Edit mode. In Fast mode, basic merge commands are single characters, but ordinary Emacs commands are disabled. This is convenient if you use only merge commands. In Edit mode, all merge commands start with the prefix key C-c C-c, and the normal Emacs commands are also available. This allows editing the merge buffer, but slows down Emerge operations.

用于e切换到编辑模式,以及C-c C-c f切换到快速模式。模式行用 ' 表示编辑和快速模式' 和 'F'。

Use e to switch to Edit mode, and C-c C-c f to switch to Fast mode. The mode line indicates Edit and Fast modes with ‘E’ and ‘F’.

Emerge 有两个额外的子模式,它们会影响特定合并命令的工作方式:自动前进模式和跳过首选项模式。

Emerge has two additional submodes that affect how particular merge commands work: Auto Advance mode and Skip Prefers mode.

如果自动前进模式有效,则ab命令前进到下一个差异。只要您从输入中选择其中一种替代方案,您就可以更快地完成合并。模式行表示自动前进模式,带有 'A'。

If Auto Advance mode is in effect, the a and b commands advance to the next difference. This lets you go through the merge faster as long as you simply choose one of the alternatives from the input. The mode line indicates Auto Advance mode with ‘A’.

如果“跳过偏好”模式有效,则np命令会跳过状态“prefer-A”和“prefer-B”中的差异(请参阅差异状态)。因此,您只能看到两个版本都被认为不正确的差异。模式行用 ' 表示 Skip Prefers 模式S'。此模式仅在存在祖先时才相关。

If Skip Prefers mode is in effect, the n and p commands skip over differences in states “prefer-A” and “prefer-B” (see State of a Difference). Thus you see only differences for which neither version is presumed correct. The mode line indicates Skip Prefers mode with ‘S’. This mode is only relevant when there is an ancestor.

使用命令s a( emerge-auto-advance) 设置或清除自动前进模式。使用s s( emerge-skip-prefers) 设置或清除跳过首选项模式。这些命令使用正参数打开模式,使用负参数或零参数关闭模式,以及不使用参数切换模式。

Use the command s a (emerge-auto-advance) to set or clear Auto Advance mode. Use s s (emerge-skip-prefers) to set or clear Skip Prefers mode. These commands turn on the mode with a positive argument, turn it off with a negative or zero argument, and toggle the mode with no argument.


29.6.3 差异状态

29.6.3 State of a Difference

在合并缓冲区中,差异用 ' 行标记v' 和 '^' 人物。每个差异都有以下七种状态之一:

In the merge buffer, a difference is marked with lines of ‘v’ and ‘^’ characters. Each difference has one of these seven states:

A
A

区别在于显示的是 A 版本。该a命令总是产生这种状态;模式行用 ' 表示A'。

The difference is showing the A version. The a command always produces this state; the mode line indicates it with ‘A’.

B

不同之处在于显示 B 版本。该b命令总是产生这种状态;模式行用 ' 表示'。

The difference is showing the B version. The b command always produces this state; the mode line indicates it with ‘B’.

默认-A
default-A
默认-B
default-B

区别在于默认显示 A 或 B 状态,因为您还没有做出选择。所有差异都从默认 A 状态开始(因此合并缓冲区是 A 缓冲区的副本),除了首选一种替代方案的差异(见下文)。

当您选择差异时,其状态从default-A或default-B更改为普通A或B。因此,所选差异永远不会具有状态default-A或default-B,并且这些状态永远不会显示在模式行中。

该命令d a选择default-A 作为默认状态,并d b选择default-B。此选择的默认值适用于您从未选择过且没有首选替代方案的所有差异。如果您按顺序进行合并,则未选择的差异是所选差异之后的差异。因此,在按顺序移动时,您可以通过在部分之间 使用d a和 ,有效地将 A 版本设置为合并缓冲区某些部分的默认值,将 B 版本设置为其他部分的默认值。d b

The difference is showing the A or the B state by default, because you haven’t made a choice. All differences start in the default-A state (and thus the merge buffer is a copy of the A buffer), except those for which one alternative is preferred (see below).

When you select a difference, its state changes from default-A or default-B to plain A or B. Thus, the selected difference never has state default-A or default-B, and these states are never displayed in the mode line.

The command d a chooses default-A as the default state, and d b chooses default-B. This chosen default applies to all differences that you have never selected and for which no alternative is preferred. If you are moving through the merge sequentially, the differences you haven’t selected are those following the selected one. Thus, while moving sequentially, you can effectively make the A version the default for some sections of the merge buffer and the B version the default for others by using d a and d b between sections.

更喜欢-A
prefer-A
偏好-B
prefer-B

区别在于显示 A 或 B 状态,因为它是 首选状态。这意味着您尚未做出明确的选择,但一种选择似乎可能是正确的,因为另一种选择与共同祖先一致。因此,如果 A 缓冲区与共同祖先一致,则首选 B 版本,因为它很可能是实际更改的版本。

这两种状态在模式行中显示为 'A*' 和 '乙*'。

The difference is showing the A or B state because it is preferred. This means that you haven’t made an explicit choice, but one alternative seems likely to be right because the other alternative agrees with the common ancestor. Thus, where the A buffer agrees with the common ancestor, the B version is preferred, because chances are it is the one that was actually changed.

These two states are displayed in the mode line as ‘A*’ and ‘B*’.

合并的
combined

区别在于显示 A 和 B 状态的组合,作为x cx C命令的结果。

一旦差异处于这种状态,ab命令不会对其执行任何操作,除非您给它们一个数字参数。

模式行将此状态显示为 '梳子'。

The difference is showing a combination of the A and B states, as a result of the x c or x C commands.

Once a difference is in this state, the a and b commands don’t do anything to it unless you give them a numeric argument.

The mode line displays this state as ‘comb’.


29.6.4 合并命令

29.6.4 Merge Commands

以下是快速模式的合并命令;在编辑模式下,在它们前面加上C-c C-c

Here are the Merge commands for Fast mode; in Edit mode, precede them with C-c C-c:

p
p

选择之前的差异。

Select the previous difference.

n
n

选择下一个差异。

Select the next difference.

a
a

选择此差异的 A 版本。

Choose the A version of this difference.

b
b

选择这个差异的B版本。

Choose the B version of this difference.

C-u n j
C-u n j

选择差值n

Select difference number n.

.
.

选择差异包含点。

Select the difference containing point.

q
q

退出——完成合并。

Quit—finish the merge.

C-]
C-]

Abort——退出合并并且不保存输出。

Abort—exit merging and do not save the output.

f
f

进入快速模式。 (在编辑模式下,这实际上是C-c C-c f。)

Go into Fast mode. (In Edit mode, this is actually C-c C-c f.)

e
e

进入编辑模式。

Go into Edit mode.

l
l

使所有三个窗口居中(如C-l)。通过参数,重新建立默认的三窗口显示。

Recenter (like C-l) all three windows. With an argument, reestablish the default three-window display.

-
-

指定前缀数字参数的一部分。

Specify part of a prefix numeric argument.

digit
digit

还指定前缀数字参数的一部分。

Also specify part of a prefix numeric argument.

d a
d a

从这里开始,在合并缓冲区中选择 A 版本作为默认版本。

Choose the A version as the default from here down in the merge buffer.

d b
d b

在合并缓冲区中选择 B 版本作为默认版本。

Choose the B version as the default from here down in the merge buffer.

c a
c a

将这个差异的 A 版本复制到 Kill Ring 中。

Copy the A version of this difference into the kill ring.

c b
c b

将这个差异的 B 版本复制到 Kill Ring 中。

Copy the B version of this difference into the kill ring.

i a
i a

在点处插入此差异的 A 版本。

Insert the A version of this difference at point.

i b
i b

在点处插入此差异的 B 版本。

Insert the B version of this difference at point.

m
m

在差异周围放置点和标记。

Put point and mark around the difference.

^
^

向下滚动所有三个窗口(如M-v)。

Scroll all three windows down (like M-v).

v
v

向上滚动所有三个窗口(如C-v)。

Scroll all three windows up (like C-v).

<
<

向左滚动所有三个窗口(如C-x <)。

Scroll all three windows left (like C-x <).

>
>

向右滚动所有三个窗口(如C-x >)。

Scroll all three windows right (like C-x >).

|
|

重置所有三个窗口上的水平滚动。

Reset horizontal scroll on all three windows.

x 1
x 1

将合并窗口缩小到一行。 (用于C-u l将其恢复为完整尺寸。)

Shrink the merge window to one line. (Use C-u l to restore it to full size.)

x c
x c

合并此差异的两个版本(请参阅合并两个版本)。

Combine the two versions of this difference (see Combining the Two Versions).

x f
x f

在帮助窗口中显示 Emerge 正在运行的文件/缓冲区的名称。 (用于C-u l恢复 Windows。)

Show the names of the files/buffers Emerge is operating on, in a Help window. (Use C-u l to restore windows.)

x j
x j

将这一差异与以下差异连接起来。 (C-u x j将此差异与前一个差异结合起来。)

Join this difference with the following one. (C-u x j joins this difference with the previous one.)

x s
x s

将这个差异分为两个差异。在使用此命令之前,将三个缓冲区中的每个缓冲区中的点定位到要拆分差异的位置。

Split this difference into two differences. Before you use this command, position point in each of the three buffers at the place where you want to split the difference.

x t
x t

修剪差异顶部和底部的相同线条。当 A 和 B 版本相同但与祖先版本不同时,就会出现此类行。

Trim identical lines off the top and bottom of the difference. Such lines occur when the A and B versions are identical but differ from the ancestor version.


29.6.5 退出出现

29.6.5 Exiting Emerge

命令q( emerge-quit) 完成合并,并将结果存储到输出文件(如果您指定了)。它将 A 和 B 缓冲区恢复到正确的内容,或者杀死它们(如果它们是由 Emerge 创建的并且您没有更改它们)。它还会禁用合并缓冲区中的 Emerge 命令,因为稍后执行这些命令可能会损坏各个缓冲区的内容。

The q command (emerge-quit) finishes the merge, storing the results into the output file if you specified one. It restores the A and B buffers to their proper contents, or kills them if they were created by Emerge and you haven’t changed them. It also disables the Emerge commands in the merge buffer, since executing them later could damage the contents of the various buffers.

C-]中止合并。这意味着退出而不写入输出文件。如果您没有指定输出文件,则中止合并和完成合并之间没有真正的区别。

C-] aborts the merge. This means exiting without writing the output file. If you didn’t specify an output file, then there is no real difference between aborting and finishing the merge.

如果 Emerge 命令是从另一个 Lisp 程序调用的,那么它的返回值是t成功完成,或者nil中止。

If the Emerge command was called from another Lisp program, then its return value is t for successful completion, or nil if you abort.


29.6.6 组合两个版本

29.6.6 Combining the Two Versions

有时您想保留两种选择以获得特定的差异。为此,请使用x c,它会像这样编辑合并缓冲区:

Sometimes you want to keep both alternatives for a particular difference. To do this, use x c, which edits the merge buffer like this:

#ifdef
来自 B 缓冲区的新版本
#else /* 不是新的 */
来自 A 缓冲区的版本
#endif /* 不是新的 */
#ifdef NEW
version from B buffer
#else /* not NEW */
version from A buffer
#endif /* not NEW */

虽然此示例显示了分隔两个替代版本的 C 预处理器条件,但您可以通过将变量设置emerge-combine-versions-template为您选择的字符串来指定要使用的字符串。在字符串中,'%A' 表示版本 A 的放置位置,并且 '%b' 表示版本 B 的放置位置。生成上面显示的结果的默认设置如下所示:

While this example shows C preprocessor conditionals delimiting the two alternative versions, you can specify the strings to use by setting the variable emerge-combine-versions-template to a string of your choice. In the string, ‘%a’ says where to put version A, and ‘%b’ says where to put version B. The default setting, which produces the results shown above, looks like this:

"#ifdef NEW\n%b#else /* 不是新的 */\n%a#endif /* 不是新的 */\n"
"#ifdef NEW\n%b#else /* not NEW */\n%a#endif /* not NEW */\n"

29.6.7 出现的要点

29.6.7 Fine Points of Emerge

在合并期间,您不得尝试自己编辑 A 和 B 缓冲区。 Emerge 会暂时修改它们,但最终会将它们恢复原样。

During the merge, you mustn’t try to edit the A and B buffers yourself. Emerge modifies them temporarily, but ultimately puts them back the way they were.

您可以同时进行任意数量的合并,只是不要同时使用任何一个缓冲区作为多个合并的输入,因为在这些缓冲区中进行的临时更改会互相妨碍。

You can have any number of merges going at once—just don’t use any one buffer as input to more than one merge at once, since the temporary changes made in these buffers would get in each other’s way.

启动 Emerge 可能需要很长时间,因为它需要完全比较文件。在diff完成之前,Emacs 无法执行任何其他操作。也许将来有人会更改 Emerge,让其在输入文件很大时在后台进行比较,然后您可以继续使用 Emacs 执行其他操作,直到 Emerge 准备好接受命令。

Starting Emerge can take a long time because it needs to compare the files fully. Emacs can’t do anything else until diff finishes. Perhaps in the future someone will change Emerge to do the comparison in the background when the input files are large—then you could keep on doing other things with Emacs until Emerge is ready to accept commands.

设置合并后,Emerge 运行 hook emerge-startup-hook。请参阅钩子

After setting up the merge, Emerge runs the hook emerge-startup-hook. See Hooks.


29.7 错误参考

29.7 Bug Reference

大多数具有一定数量用户的项目都会在某些问题跟踪软件中跟踪错误报告,这些软件为每个报告分配一个唯一的简短编号或标识符。这些用于引用给定的错误,例如,在修复某些错误的代码上方的源代码注释中、在文档文件中或在某些邮件列表或 IRC 频道的讨论中。

Most projects with a certain amount of users track bug reports in some issue tracking software which assigns each report a unique and short number or identifier. Those are used to reference a given bug, e.g., in a source code comment above the code fixing some bug, in documentation files, or in discussions on some mailing list or IRC channel.

次要模式bug-reference-modebug-reference-prog-mode突出显示此类错误引用,并可以跟踪它们到项目问题跟踪器上的相应错误报告。 bug-reference-prog-mode是它的一个变体bug-reference-mode,仅在源代码注释和字符串中突出显示错误引用。

The minor modes bug-reference-mode and bug-reference-prog-mode highlight such bug references and make it possible to follow them to the corresponding bug report on the project’s issue tracker. bug-reference-prog-mode is a variant of bug-reference-mode which highlights bug references only inside source code comments and strings.

为了实现其工作,错误引用模式需要了解错误引用的语法 ( bug-reference-bug-regexp),以及可以查找错误报告的跟踪器的 URL ( bug-reference-url-format)。由于这些通常因项目而异,因此在参阅每目录局部变量或参阅文件中的局部变量中指定它们是有意义的。

For its working, bug reference mode needs to know the syntax of bug references (bug-reference-bug-regexp), and the URL of the tracker where bug reports can be looked up (bug-reference-url-format). Since those are typically different from project to project, it makes sense to specify them in see Per-Directory Local Variables or see Local Variables in Files.

例如,假设在我们的项目中,我们通常将对错误报告的引用编写为 bug#1234 或 Bug-1234 ,并且问题跟踪器上该错误的页面是https://project.org/issues/1234,那么这些本地变量部分就可以了。

For example, let’s assume in our project, we usually write references to bug reports as bug#1234, or Bug-1234 and that this bug’s page on the issue tracker is https://project.org/issues/1234, then these local variables section would do.

;;局部变量:
;; bug-reference-bug-regexp: "\\([Bb]ug[#-]\\([0-9]+\\)\\)"
;; bug-reference-url-format:“https://project.org/issues/%s”
;;结尾:
;; Local Variables:
;; bug-reference-bug-regexp: "\\([Bb]ug[#-]\\([0-9]+\\)\\)"
;; bug-reference-url-format: "https://project.org/issues/%s"
;; End:

第一个正则表达式组捕获的字符串定义了错误引用创建的覆盖范围,即突出显示并可单击的部分。

The string captured by the first regexp group defines the bounds of the overlay bug-reference creates, i.e., the part which is highlighted and made clickable.

中的第二个正则表达式组捕获的字符串 bug-reference-bug-regexp用于替换. %sbug-reference-url-format

The string captured by the second regexp group in bug-reference-bug-regexp is used to replace the %s template in the bug-reference-url-format.

请注意,这bug-reference-url-format也可能是一个函数,以便满足更复杂的场景,例如,当必须使用错误引用的不同部分来区分导致不同 URL 的问题和合并请求时。

Note that bug-reference-url-format may also be a function in order to cater for more complex scenarios, e.g., when different parts of the bug reference have to be used to distinguish between issues and merge requests resulting in different URLs.

自动设置

Automatic Setup

如果bug-reference-mode已激活、 bug-reference-mode-hook已运行且仍然 bug-reference-bug-regexp且未bug-reference-url-format 同时设置,它将尝试通过依次调用函数来为这两个变量本身设置合适的值, bug-reference-auto-setup-functions直到能够设置变量为止。

If bug-reference-mode is activated, bug-reference-mode-hook has been run and still bug-reference-bug-regexp, and bug-reference-url-format aren’t both set, it’ll try to setup suitable values for these two variables itself by calling the functions in bug-reference-auto-setup-functions one after the other until one is able to set the variables.

目前,设置功能分为三种类型。

Right now, there are three types of setup functions.

  1. 通过变量 bug-reference-forge-alist、 和 来配置版本控制文件的设置bug-reference-setup-from-vc-alist。默认情况下能够设置 GNU 项目,其中https://debbugs.gnu.org用作问题跟踪器,问题通常被引用为bug#13(但也考虑许多不同的符号),以及几种现代软件锻造,例如 GitLab 、Gitea、SourceHut 或 GitHub。如果您部署此类伪造的自托管实例,则告诉错误参考的最简单方法是通过 bug-reference-forge-alist.
  2. Setup for version-controlled files configurable by the variables bug-reference-forge-alist, and bug-reference-setup-from-vc-alist. The defaults are able to setup GNU projects where https://debbugs.gnu.org is used as issue tracker and issues are usually referenced as bug#13 (but many different notations are considered, too), and several kinds of modern software forges such as GitLab, Gitea, SourceHut, or GitHub. If you deploy a self-hosted instance of such a forge, the easiest way to tell bug-reference about it is through bug-reference-forge-alist.
  3. 设置根据邮件文件夹/mbox 名称猜测电子邮件,以及可通过变量配置的邮件标头值 bug-reference-setup-from-mail-alist。支持 内置新闻和邮件阅读器“使用 Gnus 发送电子邮件和新闻组新闻”以及使用“Rmail 阅读邮件” 。
  4. Setup for email guessing from mail folder/mbox names, and mail header values configurable by the variable bug-reference-setup-from-mail-alist. The built-in news- and mailreader Email and Usenet News with Gnus and Reading Mail with Rmail are supported.
  5. IRC 通道的设置可通过变量进行配置 bug-reference-setup-from-irc-alist。支持 内置 IRC 客户端 Rcirc(请参阅《Rcirc 手册》中的Rcirc)和 ERC(请参阅《ERC 手册》中的ERC) 。
  6. Setup for IRC channels configurable by the variable bug-reference-setup-from-irc-alist. The built-in IRC clients Rcirc, See Rcirc in The Rcirc Manual, and ERC, See ERC in The ERC Manual, are supported.

对于几乎所有这些模式,只需启用 就足够了 bug-reference-mode,只有 Rmail 需要稍微不同的设置。

For almost all of those modes, it’s enough to simply enable bug-reference-mode, only Rmail requires a slightly different setup.

;;如果文件受版本控制,请使用基于 VC 的设置。
(add-hook 'prog-mode-hook #'bug-reference-prog-mode)

;; Gnus(摘要和文章缓冲区)
(add-hook 'gnus-mode-hook #'bug-reference-mode)

;;远程邮件
(add-hook 'rmail-show-message-hook #'bug-reference-mode-force-auto-setup)

;;环路
(add-hook 'rcirc-mode-hook #'bug-reference-mode)

;;欧洲研究委员会
(add-hook 'erc-mode-hook #'bug-reference-mode)
;; Use VC-based setup if file is under version control.
(add-hook 'prog-mode-hook #'bug-reference-prog-mode)

;; Gnus (summary & article buffers)
(add-hook 'gnus-mode-hook #'bug-reference-mode)

;; Rmail
(add-hook 'rmail-show-message-hook #'bug-reference-mode-force-auto-setup)

;; Rcirc
(add-hook 'rcirc-mode-hook #'bug-reference-mode)

;; ERC
(add-hook 'erc-mode-hook #'bug-reference-mode)

在 Rmail 的情况下, 必须与激活 并强制自动设置的rmail-show-message-hook功能结合使用,而不是模式挂钩。原因是,对于 Rmail,所有消息都驻留在同一缓冲区中,但每当显示其他消息时都需要执行设置。 bug-reference-mode-force-auto-setupbug-reference-mode

In the Rmail case, instead of the mode hook, the rmail-show-message-hook has to be used in combination with the function bug-reference-mode-force-auto-setup which activates bug-reference-mode and forces auto-setup. The reason is that with Rmail all messages reside in the same buffer but the setup needs to be performed whenever another messages is displayed.

添加对第三方软件包的支持

Adding support for third-party packages

添加对错误引用自动设置的支持通常非常简单:编写一个零参数的设置函数来收集所需的信息(例如,在 MUA 的情况下,List-Id/To/From/Cc 邮件标头值) ),然后调用以下辅助函数之一:

Adding support for bug-reference’ auto-setup is usually quite straight-forward: write a setup function of zero arguments which gathers the required information (e.g., List-Id/To/From/Cc mail header values in the case of a MUA), and then calls one of the following helper functions:

  • bug-reference-maybe-setup-from-vc它根据 进行设置bug-reference-setup-from-vc-alist
  • bug-reference-maybe-setup-from-vc which does the setup according to bug-reference-setup-from-vc-alist,
  • bug-reference-maybe-setup-from-mail它根据 进行设置bug-reference-setup-from-mail-alist
  • bug-reference-maybe-setup-from-mail which does the setup according to bug-reference-setup-from-mail-alist,
  • bug-reference-maybe-setup-from-irc根据 进行设置bug-reference-setup-from-irc-alist
  • and bug-reference-maybe-setup-from-irc which does the setup according to bug-reference-setup-from-irc-alist.

如果设置函数nil可以设置错误引用模式,那么它应该返回 non- ,如果该函数所做的最后一件事是调用上面的辅助函数之一,就是这种情况。

A setup function should return non-nil if it could setup bug-reference mode which is the case if the last thing the function does is calling one of the helper functions above.

最后,必须将设置功能添加到 bug-reference-auto-setup-functions.

Finally, the setup function has to be added to bug-reference-auto-setup-functions.

请注意,这些自动设置功能应首先检查它们是否适用,例如通过检查值major-mode

Note that these auto-setup functions should check as a first step if they are applicable, e.g., by checking the major-mode value.

与 debugs 包集成

Integration with the debbugs package

如果您的项目问题在服务器 https://debbugs.gnu.org上进行跟踪,您可以使用该包直接在 Emacs 中浏览和回复报告debbugs,该包可以通过 Package 菜单下载(请参阅Emacs Lisp Packages)。该软件包添加了次要模式debbugs-browse-mode,可以在其之上激活bug-reference-modebug-reference-prog-mode如下所示:

If your project’s issues are tracked on the server https://debbugs.gnu.org, you can browse and reply to reports directly in Emacs using the debbugs package, which can be downloaded via the Package Menu (see Emacs Lisp Packages). This package adds the minor mode debbugs-browse-mode, which can be activated on top of bug-reference-mode and bug-reference-prog-mode as follows:

(add-hook 'bug-reference-mode-hook 'debbugs-browse-mode)
(add-hook 'bug-reference-prog-mode-hook 'debbugs-browse-mode)
(add-hook 'bug-reference-mode-hook 'debbugs-browse-mode)
(add-hook 'bug-reference-prog-mode-hook 'debbugs-browse-mode)

30 缩写

30 Abbrevs

定义的缩写是一个单词,如果插入它,它会扩展为一些不同的文本。缩写由用户定义以特定方式扩展。例如,您可以定义 '' 作为缩写扩展为 '找到外水獭'。然后你可以插入 '找到外水獭' 通过键入 进入缓冲区。 f o o SPC

A defined abbrev is a word which expands, if you insert it, into some different text. Abbrevs are defined by the user to expand in specific ways. For example, you might define ‘foo’ as an abbrev expanding to ‘find outer otter’. Then you could insert ‘find outer otter ’ into the buffer by typing f o o SPC.

第二种缩写工具称为动态缩写扩展。您可以使用动态缩写扩展和显式命令来扩展缓冲区中 point 之前的字母,方法是在缓冲区中查找以这些字母开头的其他单词。请参阅动态缩写扩展

A second kind of abbreviation facility is called dynamic abbrev expansion. You use dynamic abbrev expansion with an explicit command to expand the letters in the buffer before point by looking for other words in the buffer that start with those letters. See Dynamic Abbrev Expansion.

第三种,嬉皮扩展,概括了缩写扩展。请参阅自动打字功能中的嬉皮扩展

A third kind, hippie expansion, generalizes abbreviation expansion. See Hippie Expansion in Features for Automatic Typing.


30.1 缩写概念

30.1 Abbrev Concepts

缩写已定义为扩展为指定扩展的单词。当您在缩写后面插入单词分隔符时,会扩展缩写 - 用其扩展替换缩写。例如,如果 '' 被定义为扩展为 ' 的缩写找到外水獭',然后输入f o o .将插入 '找到外水獭。'。

An abbrev is a word that has been defined to expand into a specified expansion. When you insert a word-separator character following the abbrev, that expands the abbrev—replacing the abbrev with its expansion. For example, if ‘foo’ is defined as an abbrev expanding to ‘find outer otter’, then typing f o o . will insert ‘find outer otter.’.

Abbrev 仅在启用 Abbrev 模式(一种缓冲区本地次要模式)时展开。禁用缩写模式不会导致缩写定义被遗忘,但在再次启用缩写模式之前它们不会扩展。该命令M-x abbrev-mode切换缩写模式;对于数字参数,如果参数为正,则打开缩写模式,否则关闭。请参阅次要模式

Abbrevs expand only when Abbrev mode, a buffer-local minor mode, is enabled. Disabling Abbrev mode does not cause abbrev definitions to be forgotten, but they do not expand until Abbrev mode is enabled again. The command M-x abbrev-mode toggles Abbrev mode; with a numeric argument, it turns Abbrev mode on if the argument is positive, off otherwise. See Minor Modes.

缩写可以具有特定于模式的定义,仅在一种主要模式下有效。缩写还可以具有在所有主要模式中都有效的全局定义。相同的缩写可以具有全局定义和针对不同主要模式的各种特定于模式的定义。当前主模式的模式特定定义会覆盖全局定义。

Abbrevs can have mode-specific definitions, active only in one major mode. Abbrevs can also have global definitions that are active in all major modes. The same abbrev can have a global definition and various mode-specific definitions for different major modes. A mode-specific definition for the current major mode overrides a global definition.

无论是否启用缩写模式,您都可以在编辑会话期间以交互方式定义缩写。您还可以将缩写定义列表保存在文件中,然后可以重新加载该文件以在以后的会话中使用。

You can define abbrevs interactively during the editing session, irrespective of whether Abbrev mode is enabled. You can also save lists of abbrev definitions in files, which you can then reload for use in later sessions.


30.2 定义缩写

30.2 Defining Abbrevs

C-x a g
C-x a g

定义一个缩写,使用 point 之前的一个或多个单词作为其扩展 ( add-global-abbrev)。

Define an abbrev, using one or more words before point as its expansion (add-global-abbrev).

C-x a l
C-x a l

类似,但定义一个特定于当前主要模式的缩写 ( add-mode-abbrev)。

Similar, but define an abbrev specific to the current major mode (add-mode-abbrev).

C-x a i g
C-x a i g

将缓冲区中的单词定义为缩写 ( inverse-add-global-abbrev)。

Define a word in the buffer as an abbrev (inverse-add-global-abbrev).

C-x a i l
C-x a i l

将缓冲区中的单词定义为特定于模式的缩写 ( inverse-add-mode-abbrev)。

Define a word in the buffer as a mode-specific abbrev (inverse-add-mode-abbrev).

M-x define-global-abbrev RET abbrev RET exp RET
M-x define-global-abbrev RET abbrev RET exp RET

将abbrev定义为扩展到exp 的缩写。

Define abbrev as an abbrev expanding into exp.

M-x define-mode-abbrev RET abbrev RET exp RET
M-x define-mode-abbrev RET abbrev RET exp RET

将abbrev定义为扩展到exp 的模式特定缩写。

Define abbrev as a mode-specific abbrev expanding into exp.

M-x kill-all-abbrevs
M-x kill-all-abbrevs

放弃所有缩写定义,留下一片空白。

Discard all abbrev definitions, leaving a blank slate.

定义缩写的常用方法是输入您希望缩写扩展到的文本,在其后面放置点,然后键入C-x a g ( add-global-abbrev)。这使用迷你缓冲区读取缩写本身,然后将其定义为 point 之前的一个或多个单词的缩写。使用数字参数来表示 point 之前有多少个单词应被视为扩展。例如,定义缩写 ''如上所述,插入文本'找到外水獭' 然后输入 . C-u 3 C-x a g f o o RET

The usual way to define an abbrev is to enter the text you want the abbrev to expand to, position point after it, and type C-x a g (add-global-abbrev). This reads the abbrev itself using the minibuffer, and then defines it as an abbrev for one or more words before point. Use a numeric argument to say how many words before point should be taken as the expansion. For example, to define the abbrev ‘foo’ as mentioned above, insert the text ‘find outer otter’ and then type C-u 3 C-x a g f o o RET.

如果您正在使用transient-mark-mode(这是默认设置),则活动区域将用作所定义的缩写的扩展。如果不是,则参数为零C-x a g表示使用该区域的内容。

If you’re using transient-mark-mode (which is the default), the active region will be used as the expansion of the abbrev being defined. If not, an argument of zero to C-x a g means to use the contents of the region.

命令C-x a l( add-mode-abbrev) 类似,但为当前主模式定义了特定于模式的缩写。这些参数的作用与 相同C-x a g

The command C-x a l (add-mode-abbrev) is similar, but defines a mode-specific abbrev for the current major mode. The arguments work the same as for C-x a g.

C-x a i g( inverse-add-global-abbrev) 和C-x a i l( inverse-add-mode-abbrev) 执行相反的任务:如果缩写文本已在缓冲区中,则可以使用这些命令通过指定迷你缓冲区中的扩展来定义缩写。这些命令将扩展用于定义的缩写文本。

C-x a i g (inverse-add-global-abbrev) and C-x a i l (inverse-add-mode-abbrev) perform the opposite task: if the abbrev text is already in the buffer, you use these commands to define an abbrev by specifying the expansion in the minibuffer. These commands will expand the abbrev text used for the definition.

您可以使用命令定义缩写,而无需在缓冲区中插入缩写或其扩展define-global-abbrev。它读取两个参数——缩写及其扩展。该命令 define-mode-abbrev对于特定于模式的缩写也有同样的作用。

You can define an abbrev without inserting either the abbrev or its expansion in the buffer using the command define-global-abbrev. It reads two arguments—the abbrev, and its expansion. The command define-mode-abbrev does likewise for a mode-specific abbrev.

要更改缩写的定义,只需重新定义即可。当缩写有先前的定义时,缩写定义命令会在替换它之前要求确认。

To change the definition of an abbrev, just make a new definition. When an abbrev has a prior definition, the abbrev definition commands ask for confirmation before replacing it.

要删除缩写定义,请为缩写定义命令提供负参数:C-u - C-x a gC-u - C-x a l。前者删除全局定义,而后者删除特定于模式的定义。 M-x kill-all-abbrevs删除所有缩写定义,包括全局和本地。

To remove an abbrev definition, give a negative argument to the abbrev definition command: C-u - C-x a g or C-u - C-x a l. The former removes a global definition, while the latter removes a mode-specific definition. M-x kill-all-abbrevs removes all abbrev definitions, both global and local.


30.3 控制缩写扩展

30.3 Controlling Abbrev Expansion

启用缩写模式后,每当缩写出现在点之前的缓冲区中并且您键入自动插入的空格或标点符号(SPC、逗号等)时,缩写就会展开。更准确地说,任何不是单词构成的字符都会扩展缩写,并且任何单词构成字符都可以是缩写的一部分。使用缩写的最常见方法是插入缩写,然后插入标点符号或空格字符来扩展它。

When Abbrev mode is enabled, an abbrev expands whenever it is present in the buffer just before point and you type a self-inserting whitespace or punctuation character (SPC, comma, etc.). More precisely, any character that is not a word constituent expands an abbrev, and any word-constituent character can be part of an abbrev. The most common way to use an abbrev is to insert it and then insert a punctuation or whitespace character to expand it.

缩写扩展保留大小写:'' 扩展为 '找到外水獭', 和 '' 到 '寻找外层水獭'。 'FOO' 扩展为 '寻找外水獭' 默认情况下,但如果将变量更改abbrev-all-caps为非值nil,它将扩展为 '寻找外水獭'。

Abbrev expansion preserves case: ‘foo’ expands to ‘find outer otter’, and ‘Foo’ to ‘Find outer otter’. ‘FOO’ expands to ‘Find Outer Otter’ by default, but if you change the variable abbrev-all-caps to a non-nil value, it expands to ‘FIND OUTER OTTER’.

这些命令用于控制缩写扩展:

These commands are used to control abbrev expansion:

M-'
M-'

将前缀与后面要扩展的缩写分开 ( abbrev-prefix-mark)。

Separate a prefix from a following abbrev to be expanded (abbrev-prefix-mark).

C-x a e
C-x a e

展开 ( ) 点之前的缩写expand-abbrev。即使未启用缩写模式,此功能也有效。

Expand the abbrev before point (expand-abbrev). This is effective even when Abbrev mode is not enabled.

M-x unexpand-abbrev
M-x unexpand-abbrev

撤消最后扩展的缩写的扩展。

Undo the expansion of the last expanded abbrev.

M-x expand-region-abbrevs
M-x expand-region-abbrevs

展开在该区域中找到的部分或全部缩写。

Expand some or all abbrevs found in the region.

您可能希望扩展一个缩写并在扩展后附加一个前缀;例如,如果 '中国科学技术协会' 扩展为 '建造',您可能想用它来输入 '重建'。输入 不起作用 recnst,因为它不一定是定义的缩写。您可以做的就是在前缀 ' 之间使用命令M-'( )abbrev-prefix-mark关于' 和缩写 '中国科学技术协会'。首先,插入 '关于'。然后输入M-';这会在缓冲区中插入一个连字符,以表明它已完成其工作。然后插入缩写 '中国科学技术协会';缓冲区现在包含 '重建'。现在插入一个非单词字符来扩展缩写 '中国科学技术协会' 进入 '建造'。此扩展步骤还会删除指示M-'已使用的连字符。结果就是想要的'重建'。

You may wish to expand an abbrev and attach a prefix to the expansion; for example, if ‘cnst’ expands into ‘construction’, you might want to use it to enter ‘reconstruction’. It does not work to type recnst, because that is not necessarily a defined abbrev. What you can do is use the command M-' (abbrev-prefix-mark) in between the prefix ‘re’ and the abbrev ‘cnst’. First, insert ‘re’. Then type M-'; this inserts a hyphen in the buffer to indicate that it has done its work. Then insert the abbrev ‘cnst’; the buffer now contains ‘re-cnst’. Now insert a non-word character to expand the abbrev ‘cnst’ into ‘construction’. This expansion step also deletes the hyphen that indicated M-' had been used. The result is the desired ‘reconstruction’.

如果您确实想要缓冲区中缩写的文本,而不是其扩展,您可以通过插入以下标点符号来完成此操作C-q。因此,foo C-q ,离开'富,' 在缓冲区中,而不是扩展它。

If you actually want the text of the abbrev in the buffer, rather than its expansion, you can accomplish this by inserting the following punctuation with C-q. Thus, foo C-q , leaves ‘foo,’ in the buffer, not expanding it.

如果您错误地扩展了缩写,您可以通过键入C-/( undo) 来撤消扩展。请参阅撤消。这将撤消缩写扩展的插入并返回缩写文本。如果您想要的结果是终止非单词字符加上未展开的缩写,则必须重新插入终止字符,并用 引用它C-q。您还可以使用该命令M-x unexpand-abbrev取消最后一次扩展,而不删除终止字符。

If you expand an abbrev by mistake, you can undo the expansion by typing C-/ (undo). See Undo. This undoes the insertion of the abbrev expansion and brings back the abbrev text. If the result you want is the terminating non-word character plus the unexpanded abbrev, you must reinsert the terminating character, quoting it with C-q. You can also use the command M-x unexpand-abbrev to cancel the last expansion without deleting the terminating character.

M-x expand-region-abbrevs在该区域中搜索定义的缩写,并为找到的每个缩写提供用其扩展替换它。如果您使用缩写输入文本但忘记先打开缩写模式,则此命令非常有用。它也可能与一组特殊的缩写定义一起使用,用于一次进行多个全局替换。即使未启用缩写模式,该命令也有效。

M-x expand-region-abbrevs searches through the region for defined abbrevs, and for each one found offers to replace it with its expansion. This command is useful if you have typed in text using abbrevs but forgot to turn on Abbrev mode first. It may also be useful together with a special set of abbrev definitions for making several global replacements at once. This command is effective even if Abbrev mode is not enabled.

该函数expand-abbrev通过调用指定的函数来执行扩展abbrev-expand-function。通过更改此函数,您可以对缩写扩展进行任意更改。请参阅Emacs Lisp 参考手册中的缩写扩展

The function expand-abbrev performs the expansion by calling the function that abbrev-expand-function specifies. By changing this function you can make arbitrary changes to the abbrev expansion. See Abbrev Expansion in The Emacs Lisp Reference Manual.


30.4 缩写建议

30.4 Abbrevs Suggestions

当您手动键入当前存在活动定义缩写的文本时,您可以获得缩写建议。例如,如果有一个缩写 ''随着扩展'找到外水獭',然后您手动输入 '找到外水獭',Emacs 可以注意到这一点,并在您停止输入时在回显区域显示提示。

You can get abbrev suggestions when you manually type text for which there is currently an active defined abbrev. For example, if there is an abbrev ‘foo’ with the expansion ‘find outer otter’, and you manually type ‘find outer otter’, Emacs can notice this and show a hint in the echo area when you have stopped typing.

要启用缩写建议功能,请将该选项自定义 abbrev-suggest为非值nil

To enable the abbrev suggestion feature, customize the option abbrev-suggest to a non-nil value.

该变量abbrev-suggest-hint-threshold控制何时向用户建议缩写。此变量定义 Emacs 建议使用缩写所需的最小节省量(就用户不必键入的字符数而言)。例如,如果用户输入 '富酒吧'(七个字符)并且有一个缩写'福巴尔' 定义(五个字符),除非阈值设置为数字 2 或更低,否则用户将不会得到任何建议。使用默认值 3,用户在本例中不会得到任何建议,因为使用缩写所节省的成本低于阈值。如果您总是想获得缩写建议,请将此变量的值设置为零。

The variable abbrev-suggest-hint-threshold controls when to suggest an abbrev to the user. This variable defines the minimum savings (in terms of the number of characters the user will not have to type) required for Emacs to suggest using an abbrev. For example, if the user types ‘foo bar’ (seven characters) and there is an abbrev ‘fubar’ defined (five characters), the user will not get any suggestion unless the threshold is set to the number 2 or lower. With the default value 3, the user would not get any suggestion in this example, because the savings in using the abbrev are below the threshold. If you always want to get abbrev suggestions, set this variable’s value to zero.

该命令abbrev-suggest-show-report显示一个缓冲区,其中包含当前编辑会话期间显示的所有缩写建议。如果您收到几个缩写建议但不记得全部,这可能会很有用。

The command abbrev-suggest-show-report displays a buffer with all the abbrev suggestions shown during the current editing session. This can be useful if you get several abbrev suggestions and don’t remember them all.


30.5 检查和编辑缩写

30.5 Examining and Editing Abbrevs

M-x list-abbrevs
M-x list-abbrevs

显示所有缩写定义的列表。使用数字参数时,仅列出本地缩写。

Display a list of all abbrev definitions. With a numeric argument, list only local abbrevs.

M-x edit-abbrevs
M-x edit-abbrevs

编辑缩写列表;您可以添加、更改或删除定义。

Edit a list of abbrevs; you can add, alter or remove definitions.

的输出M-x list-abbrevs看起来像这样:

The output from M-x list-abbrevs looks like this:

各种其他表...
(python-模式-骨架-缩写表)
“类”(sys)0“”python骨架类
(lisp 模式缩写表)
“ks”0“键盘映射集”
(全局缩写表)
“dfn”0“定义”
various other tables…
(python-mode-skeleton-abbrev-table)
"class" (sys)	    0 "" python-skeleton-class
(lisp-mode-abbrev-table)
"ks"          0    "keymap-set"
(global-abbrev-table)
"dfn"         0    "definition"

(一些没有语义意义的空行和其他一些缩写表已被省略。)

(Some blank lines of no semantic significance, and some other abbrev tables, have been omitted.)

括号中包含名称的行是特定缩写表中缩写的标题;global-abbrev-table包含所有全局缩写,以主要模式命名的其他缩写表包含特定于模式的缩写。

A line containing a name in parentheses is the header for abbrevs in a particular abbrev table; global-abbrev-table contains all the global abbrevs, and the other abbrev tables that are named after major modes contain the mode-specific abbrevs.

在每个缩写表中,每个非空行定义一个缩写。行首的单词是缩写。后面的数字是缩写已扩展的次数。 Emacs 会跟踪这一点,以帮助您了解实际使用的缩写,以便您可以消除那些不经常使用的缩写。行尾的字符串是扩展。

Within each abbrev table, each nonblank line defines one abbrev. The word at the beginning of the line is the abbrev. The number that follows is the number of times the abbrev has been expanded. Emacs keeps track of this to help you see which abbrevs you actually use, so that you can eliminate those that you don’t use often. The string at the end of the line is the expansion.

一些缩写标有 '(系统)'。这些系统缩写(请参阅Emacs Lisp 参考手册中的缩写)是由各种模式预定义的,并且不会保存到您的缩写文件中。要禁用系统缩写,请定义一个扩展为自身的同名缩写,并将其保存到缩写文件中。系统缩写有一个关联的钩子函数,调用该函数来执行缩写扩展;该函数的名称遵循 所示的缓冲区中的缩写扩展。 list-abbrevs

Some abbrevs are marked with ‘(sys)’. These system abbrevs (see Abbrevs in The Emacs Lisp Reference Manual) are pre-defined by various modes, and are not saved to your abbrev file. To disable a system abbrev, define an abbrev of the same name that expands to itself, and save it to your abbrev file. The system abbrevs have an associated hook function, which is called to perform the abbrev expansion; the name of that function follows the abbrev expansion in the buffer shown by list-abbrevs.

M-x edit-abbrevs允许您通过在 Emacs 缓冲区中编辑缩写定义列表来添加、更改或删除缩写定义。该列表具有与上述相同的格式。缩写缓冲区称为 *缩写*,并且处于编辑缩写模式。在此缓冲区中键入内容C-c C-c以安装缓冲区中指定的缩写定义,并删除任何未列出的缩写定义。

M-x edit-abbrevs allows you to add, change or kill abbrev definitions by editing a list of them in an Emacs buffer. The list has the same format described above. The buffer of abbrevs is called *Abbrevs*, and is in Edit-Abbrevs mode. Type C-c C-c in this buffer to install the abbrev definitions as specified in the buffer—and delete any abbrev definitions not listed.

该命令edit-abbrevs实际上与 相同, list-abbrevs只是它选择缓冲区*缩写*list-abbrevs只是将其显示在另一个窗口中。

The command edit-abbrevs is actually the same as list-abbrevs except that it selects the buffer *Abbrevs* whereas list-abbrevs merely displays it in another window.


30.6 保存缩写

30.6 Saving Abbrevs

这些命令允许您在编辑会话之间保留缩写定义。

These commands allow you to keep abbrev definitions between editing sessions.

M-x write-abbrev-file RET file RET
M-x write-abbrev-file RET file RET

编写一个描述所有定义的缩写的文件

Write a file file describing all defined abbrevs.

M-x read-abbrev-file RET file RET
M-x read-abbrev-file RET file RET

读取文件file并定义其中指定的缩写。

Read the file file and define abbrevs as specified therein.

M-x define-abbrevs
M-x define-abbrevs

从当前缓冲区中的定义定义缩写。

Define abbrevs from definitions in current buffer.

M-x insert-abbrevs
M-x insert-abbrevs

将所有缩写及其扩展插入当前缓冲区。

Insert all abbrevs and their expansions into current buffer.

M-x write-abbrev-file使用迷你缓冲区读取文件名,然后将所有当前缩写定义的描述写入该文件。这用于保存缩写定义以供稍后会话使用。文件中存储的文本是一系列 Lisp 表达式,这些表达式在执行时定义与您当前拥有的相同的缩写。

M-x write-abbrev-file reads a file name using the minibuffer and then writes a description of all current abbrev definitions into that file. This is used to save abbrev definitions for use in a later session. The text stored in the file is a series of Lisp expressions that, when executed, define the same abbrevs that you currently have.

M-x read-abbrev-file使用迷你缓冲区读取文件名,然后读取文件,根据文件内容定义缩写。功能quietly-read-abbrev-file类似,只是不在回显区域显示消息;您不能以交互方式调用它,它主要在 init 文件中使用(请参阅Emacs 初始化文件)。如果使用这些函数中的任何一个 nil作为参数调用,它将使用变量 给定的文件 abbrev-file-name,即〜/.emacs.d/abbrev_defs默认情况下。这是标准缩写定义文件,Emacs 在启动时会自动从中加载缩写。 (作为例外,Emacs 在以批处理模式启动时不会加载缩写文件。有关批处理模式的说明, 请参阅初始选项。)

M-x read-abbrev-file reads a file name using the minibuffer and then reads the file, defining abbrevs according to the contents of the file. The function quietly-read-abbrev-file is similar except that it does not display a message in the echo area; you cannot invoke it interactively, and it is used primarily in your init file (see The Emacs Initialization File). If either of these functions is called with nil as the argument, it uses the file given by the variable abbrev-file-name, which is ~/.emacs.d/abbrev_defs by default. This is your standard abbrev definition file, and Emacs loads abbrevs from it automatically when it starts up. (As an exception, Emacs does not load the abbrev file when it is started in batch mode. See Initial Options, for a description of batch mode.)

C-x s如果您更改了其中的任何缩写,无论何时,只要 Emacs 提供保存所有文件(for或 C-x C-c),Emacs 都会自动保存缩写。它将它们保存在 指定的文件中 abbrev-file-name。可以通过将变量设置save-abbrevs为来禁止此功能nil;将其设置为 silently将自动保存缩写而无需询问。

Emacs will offer to save abbrevs automatically if you have changed any of them, whenever it offers to save all files (for C-x s or C-x C-c). It saves them in the file specified by abbrev-file-name. This feature can be inhibited by setting the variable save-abbrevs to nil; setting it to silently will save the abbrevs automatically without asking.

命令M-x insert-abbrevsM-x define-abbrevs与前面的命令类似,但作用于 Emacs 缓冲区中的文本。 M-x insert-abbrevs将文本插入到当前缓冲区中的 point 之后,描述所有当前的缩写定义;M-x define-abbrevs解析整个当前缓冲区并相应地定义缩写。

The commands M-x insert-abbrevs and M-x define-abbrevs are similar to the previous commands but work on text in an Emacs buffer. M-x insert-abbrevs inserts text into the current buffer after point, describing all current abbrev definitions; M-x define-abbrevs parses the entire current buffer and defines abbrevs accordingly.


30.7 动态缩写扩展

30.7 Dynamic Abbrev Expansion

当您插入文本时,上述缩写工具会自动运行,但所有缩写都必须明确定义。相比之下, 动态缩写允许根据缓冲区的内容自动确定缩写的含义,但动态缩写扩展仅在您明确请求时才会发生。

The abbrev facility described above operates automatically as you insert text, but all abbrevs must be defined explicitly. By contrast, dynamic abbrevs allow the meanings of abbreviations to be determined automatically from the contents of the buffer, but dynamic abbrev expansion happens only when you request it explicitly.

M-/
M-/

通过搜索以该缩写 ( ) 开头的单词,将 point 之前的缓冲区中的单词扩展为动态缩写dabbrev-expand

Expand the word in the buffer before point as a dynamic abbrev, by searching for words starting with that abbreviation (dabbrev-expand).

C-M-/
C-M-/

将 point 之前的单词作为动态缩写完成 ( dabbrev-completion)。

Complete the word before point as a dynamic abbrev (dabbrev-completion).

例如,如果缓冲区包含 '这是否遵循'然后你输入f o M-/,效果是插入'跟随' 因为这是缓冲区中以 ' 开头的最后一个单词'。一个数字参数表示M-/采用从点向后看发现的第二个、第三个等不同的扩展。M-/ 通过回顾更远的地方,重复寻找替代的扩展。扫描完点之前的所有文本后,它会搜索点之后的文本。变量dabbrev-limit(如果非nil)指定在缓冲区中搜索扩展的距离。

For example, if the buffer contains ‘does this follow ’ and you type f o M-/, the effect is to insert ‘follow’ because that is the last word in the buffer that starts with ‘fo’. A numeric argument to M-/ says to take the second, third, etc. distinct expansion found looking backward from point. Repeating M-/ searches for an alternative expansion by looking farther back. After scanning all the text before point, it searches the text after point. The variable dabbrev-limit, if non-nil, specifies how far away in the buffer to search for an expansion.

扫描当前缓冲区后,M-/通常会搜索其他缓冲区。变量dabbrev-check-all-buffersdabbrev-check-other-buffers可用于确定搜索哪些其他缓冲区(如果有)。具有从 中的任何模式派生的主要模式的缓冲区dabbrev-ignored-buffer-modes 将被忽略。

After scanning the current buffer, M-/ normally searches other buffers. The variables dabbrev-check-all-buffers and dabbrev-check-other-buffers can be used to determine which other buffers, if any, are searched. Buffers that have major modes derived from any of the modes in dabbrev-ignored-buffer-modes are ignored.

为了更好地控制要扫描的缓冲区,请自定义变量dabbrev-ignored-buffer-namesdabbrev-ignored-buffer-regexps。前者的值是要跳过的缓冲区名称列表。后者的值是正则表达式列表;如果缓冲区的名称与这些正则表达式中的任何一个匹配,则动态缩写扩展会跳过该缓冲区。

For finer control over which buffers to scan, customize the variables dabbrev-ignored-buffer-names and dabbrev-ignored-buffer-regexps. The value of the former is a list of buffer names to skip. The value of the latter is a list of regular expressions; if a buffer’s name matches any of these regular expressions, dynamic abbrev expansion skips that buffer.

的否定参数M-/(如 中C-u - M-/)表示首先搜索 point 之后的扩展,然后搜索其他缓冲区,并且仅将 point 之前的扩展视为最后的手段。如果您重复M-/查找另一个扩展,请不要指定参数。重复M-/循环遍历 point 之后的所有扩展,然后循环遍历 point 之前的扩展。

A negative argument to M-/, as in C-u - M-/, says to search first for expansions after point, then other buffers, and consider expansions before point only as a last resort. If you repeat the M-/ to look for another expansion, do not specify an argument. Repeating M-/ cycles through all the expansions after point and then the expansions before point.

展开动态缩写后,您可以在其原始上下文中复制展开后的其他单词。只需键入 SPC M-/您要复制的每个附加单词即可。单词之间的空格和标点符号会随单词一起复制。

After you have expanded a dynamic abbrev, you can copy additional words that follow the expansion in its original context. Simply type SPC M-/ for each additional word you want to copy. The spacing and punctuation between words is copied along with the words.

您可以控制确定要扩展的单词的方式M-/以及如何扩展它,请参阅自定义动态缩写

You can control the way M-/ determines the word to expand and how to expand it, see Customizing Dynamic Abbreviation.

命令C-M-/( dabbrev-completion) 执行动态缩写的完成。它不是一一尝试可能的扩展,而是找到所有扩展,然后插入它们共有的文本。如果它们没有共同点,则C-M-/ 显示完成列表,您可以按照通常的方式从中选择一个选项。请参阅完成

The command C-M-/ (dabbrev-completion) performs completion of a dynamic abbrev. Instead of trying the possible expansions one by one, it finds all of them, then inserts the text that they have in common. If they have nothing in common, C-M-/ displays a list of completions, from which you can select a choice in the usual manner. See Completion.

动态缩写扩展完全独立于缩写模式;单词 with 的扩展M-/完全与它是否具有普通缩写的定义无关。

Dynamic abbrev expansion is completely independent of Abbrev mode; the expansion of a word with M-/ is completely independent of whether it has a definition as an ordinary abbrev.


30.8 自定义动态缩写

30.8 Customizing Dynamic Abbreviation

通常,动态缩写扩展在搜索扩展时会忽略大小写。也就是说,扩展不必与您正在扩展的单词一致。

Normally, dynamic abbrev expansion ignores case when searching for expansions. That is, the expansion need not agree in case with the word you are expanding.

该功能由变量 控制 dabbrev-case-fold-search。如果是t,则在此搜索中忽略大小写;如果是nil,则单词和扩展必须匹配大小写。如果值为case-fold-search(默认值),则该变量case-fold-search控制在搜索扩展时是否忽略大小写(请参阅搜索期间的宽松匹配)。

This feature is controlled by the variable dabbrev-case-fold-search. If it is t, case is ignored in this search; if it is nil, the word and the expansion must match in case. If the value is case-fold-search (the default), then the variable case-fold-search controls whether to ignore case while searching for expansions (see Lax Matching During Searching).

通常,动态缩写扩展通过将扩展转换为大小写模式来 保留您正在扩展的动态缩写的大小写模式 。

Normally, dynamic abbrev expansion preserves the case pattern of the dynamic abbrev you are expanding, by converting the expansion to that case pattern.

该变量dabbrev-case-replace控制是否保留动态缩写的大小写模式。如果是t,则在大多数情况下会保留动态缩写的大小写模式;如果是 nil,则始终逐字复制扩展。如果值为 case-replace(默认值),则该变量 case-replace控制是否逐字复制扩展(请参阅替换命令和宽松匹配)。

The variable dabbrev-case-replace controls whether to preserve the case pattern of the dynamic abbrev. If it is t, the dynamic abbrev’s case pattern is preserved in most cases; if it is nil, the expansion is always copied verbatim. If the value is case-replace (the default), then the variable case-replace controls whether to copy the expansion verbatim (see Replace Commands and Lax Matches).

但是,如果扩展包含复杂的混合大小写模式,并且动态缩写与该模式尽可能匹配,则扩展始终会逐字复制,而不管这些变量如何。因此,例如,如果缓冲区包含 variableWithSillyCasePattern,并且您键入v a M-/,它将逐字复制扩展,包括其大小写模式。

However, if the expansion contains a complex mixed case pattern, and the dynamic abbrev matches this pattern as far as it goes, then the expansion is always copied verbatim, regardless of those variables. Thus, for example, if the buffer contains variableWithSillyCasePattern, and you type v a M-/, it copies the expansion verbatim including its case pattern.

变量dabbrev-abbrev-char-regexp(如果非nil)控制哪些字符被视为单词的一部分,以实现动态扩展目的。正则表达式必须仅匹配一个字符,不能匹配两个或多个字符。相同的正则表达式还确定哪些字符是扩展的一部分。 (默认)值nil具有特殊含义:动态缩写(即当前位置的单词)由单词字符组成,但它们的扩展被视为单词和符号字符的序列。这通常适用于扩展程序源中的符号以及许多语言中的人类可读文本,但可能不是您在包含不常见标点符号的文本缓冲区中想要的;在这种情况下,该值"\\sw"可能会产生更好的结果。

The variable dabbrev-abbrev-char-regexp, if non-nil, controls which characters are considered part of a word, for dynamic expansion purposes. The regular expression must match just one character, never two or more. The same regular expression also determines which characters are part of an expansion. The (default) value nil has a special meaning: dynamic abbrevs (i.e. the word at point) are made of word characters, but their expansions are looked for as sequences of word and symbol characters. This is generally appropriate for expanding symbols in a program source and also for human-readable text in many languages, but may not be what you want in a text buffer that includes unusual punctuation characters; in that case, the value "\\sw" might produce better results.

在 shell 脚本和 makefile 中,变量名有时以 ' 为前缀$’有时也不是。此类文本的主要模式可以通过设置变量来自定义动态缩写扩展来处理可选前缀dabbrev-abbrev-skip-leading-regexp。它的值应该是一个正则表达式,与动态缩写表达式应忽略的可选前缀相匹配。默认值为nil,这意味着不应跳过任何字符。

In shell scripts and makefiles, a variable name is sometimes prefixed with ‘$’ and sometimes not. Major modes for this kind of text can customize dynamic abbrev expansion to handle optional prefixes by setting the variable dabbrev-abbrev-skip-leading-regexp. Its value should be a regular expression that matches the optional prefix that dynamic abbrev expression should ignore. The default is nil, which means no characters should be skipped.


31 Dired,目录编辑器

31 Dired, the Directory Editor

Dired 制作一个 Emacs 缓冲区,其中包含目录列表,以及可选的一些子目录。您可以使用普通的 Emacs 命令在此缓冲区中移动,并使用特殊的 Dired 命令来操作列出的文件。 Dired 适用于本地和远程目录。

Dired makes an Emacs buffer containing a listing of a directory, and optionally some of its subdirectories as well. You can use the normal Emacs commands to move around in this buffer, and special Dired commands to operate on the listed files. Dired works with both local and remote directories.

Dired 缓冲区通常是只读的,并且不允许在其中插入文本(但是,Wdired 模式允许这样做,请参阅编辑 Dired 缓冲区)。普通打印字符(例如d和 )x被重新定义为特殊的 Dired 命令。一些 Dired 命令标记标记当前文件(即当前行上的文件);其他命令对标记的文件或标记的文件进行操作。您首先标记某些文件,以便使用一个命令对所有文件进行操作。

The Dired buffer is normally read-only, and inserting text in it is not allowed (however, the Wdired mode allows that, see Editing the Dired Buffer). Ordinary printing characters such as d and x are redefined for special Dired commands. Some Dired commands mark or flag the current file (that is, the file on the current line); other commands operate on the marked files or on the flagged files. You first mark certain files in order to operate on all of them with one command.

Dired-X 软件包为 Dired 模式提供了各种额外功能。请参阅Dired Extra 用户手册中的Dired-X

The Dired-X package provides various extra features for Dired mode. See Dired-X in Dired Extra User’s Manual.

C-x C-d 您还可以使用( )查看目录中的文件列表list-directory。与 Dired 不同,此命令不允许您对列出的文件进行操作。请参阅文件目录

You can also view a list of files in a directory with C-x C-d (list-directory). Unlike Dired, this command does not allow you to operate on the listed files. See File Directories.


31.1 输入 Dired

31.1 Entering Dired

要调用 Dired,请键入C-x d( dired)。这使用迷你缓冲区读取目录名称,并打开Dired 缓冲区 ,列出该目录中的文件。您还可以提供通配符文件名模式作为 minibuffer 参数,在这种情况下,Dired 缓冲区会列出与该模式匹配的所有文件。通配符也可能出现在目录部分中。例如,

To invoke Dired, type C-x d (dired). This reads a directory’s name using the minibuffer, and opens a Dired buffer listing the files in that directory. You can also supply a wildcard file name pattern as the minibuffer argument, in which case the Dired buffer lists all files matching that pattern. A wildcard may appear in the directory part as well. For instance,

Cx d ~/foo/*.el   RET
Cx d ~/foo/*/*.el  RET
C-x d  ~/foo/*.el  RET
C-x d  ~/foo/*/*.el  RET

前者列出了所有扩展名为 '.el'在目录中''。后者列出了扩展名为 '.el' 在 ' 的所有子目录中'。

The former lists all the files with extension ‘.el’ in directory ‘foo’. The latter lists the files with extension ‘.el’ in all the subdirectories of ‘foo’.

在 Posix 系统上,当系统 shell 支持globstar(一种递归通配符功能)并且启用了该支持时,您可以在 Dired 中使用递归通配符:

On Posix systems, when the system shell supports globstar, a recursive globbing feature, and that support is enabled, you can use recursive globbing in Dired:

Cx d ~/foo/**/*.el  RET
C-x d  ~/foo/**/*.el  RET

此命令生成一个目录列表,其中包含扩展名为 ' 的所有文件.el',在 ' 的所有子目录中递归递减'。请注意,不同 shell 之间的 globstar 实现存在细微差别。检查您的 shell 手册以了解预期的行为。

This command produces a directory listing with all the files with extension ‘.el’, descending recursively in all the subdirectories of ‘foo’. Note that there are small differences in the implementation of globstar between different shells. Check your shell manual to know the expected behavior.

如果 shell 支持 globstar,但默认情况下禁用该支持,您仍然可以通过自定义 dired-maybe-use-globstar为非值来让 Dired 使用此功能nil;然后 Dired 将为那些它知道如何启用的 shell 启用 globstar(请参阅 参考资料 中 dired-enable-globstar-in-shell这些 shell 的列表)。

If the shell supports globstar, but that support is disabled by default, you can still let Dired use this feature by customizing dired-maybe-use-globstar to a non-nil value; then Dired will enable globstar for those shells for which it knows how (see dired-enable-globstar-in-shell for the list of those shells).

常用的历史记录和完成命令可以在迷你缓冲区中使用;特别是,M-n将访问的文件的名称(如果有)放入迷你缓冲区中(请参阅迷你缓冲区历史记录)。

The usual history and completion commands can be used in the minibuffer; in particular, M-n puts the name of the visited file (if any) in the minibuffer (see Minibuffer History).

您还可以通过给出C-x C-f( find-file) 目录名称来调用 Dired。

You can also invoke Dired by giving C-x C-f (find-file) a directory’s name.

您可以通过键入( ) 要求 Emacs 在任何缓冲区的默认目录(请参阅default-directory) 上调用 Dired 。如果缓冲区访问一个文件,该命令会将指针移动到它显示的 Dired 缓冲区中该文件的行;否则,点将位于目录列表中的第一个文件上。作为例外,如果您在 Dired 缓冲区中键入,Emacs 将显示父目录的目录列表,并将 point 放置在与您调用的目录相对应的行上。键入 ( ) 具有相同的效果,但会在新窗口中显示 Dired 缓冲区。 C-x C-jdired-jumpC-x C-jdired-jumpC-x 4 C-jdired-jump-other-window

You can ask Emacs to invoke Dired on the default-directory (see default-directory) of any buffer, by typing C-x C-j (dired-jump). If the buffer visits a file, this command will move point to that file’s line in the Dired buffer it shows; otherwise, point will end up on the first file in the directory listing. As an exception, if you type C-x C-j in a Dired buffer, Emacs displays the directory listing of the parent directory and places point on the line that corresponds to the directory where you invoked dired-jump. Typing C-x 4 C-j (dired-jump-other-window) has the same effect, but displays the Dired buffer in a new window.

该变量指定列出目录的dired-listing-switches选项;ls该字符串 必须包含 '-l'。如果在命令中使用前缀参数 dired,则可以ls在输入目录规范之前指定带有微型缓冲区的开关。无论如何指定,ls开关都可以包含不需要参数的短选项(即单个字符)和长选项(以 ' 开头)--') 其参数用 ' 指定='。

The variable dired-listing-switches specifies the options to give to ls for listing the directory; this string must contain ‘-l’. If you use a prefix argument with the dired command, you can specify the ls switches with the minibuffer before you enter the directory specification. No matter how they are specified, the ls switches can include short options (that is, single characters) requiring no arguments, and long options (starting with ‘--’) whose arguments are specified with ‘=’.

Dired 不能很好地处理名称中嵌入换行符的文件。如果你有很多这样的文件,你可以考虑添加'-b' 到dired-listing-switches。这将引用所有特殊字符并允许 Dired 更好地处理它们。 (您也可以使用C-u C-x d命令添加 '-b' 暂时地。)

Dired does not handle files that have names with embedded newline characters well. If you have many such files, you may consider adding ‘-b’ to dired-listing-switches. This will quote all special characters and allow Dired to handle them better. (You can also use the C-u C-x d command to add ‘-b’ temporarily.)

Dired 在模式行中显示用于调用哪些开关的指示ls。默认情况下,Dired 将尝试确定开关是否指示按名称或日期排序,并在模式行中如此说明。如果dired-switches-in-mode-line 变量为as-is,则将逐字显示开关。如果该变量的值为整数,则开关显示将被截断为该长度。该变量也可以是一个函数,它将作为唯一的参数被调用dired-actual-switches,并且应该返回一个字符串以显示在模式行中。

Dired displays in the mode line an indication of what were the switches used to invoke ls. By default, Dired will try to determine whether the switches indicate sorting by name or date, and will say so in the mode line. If the dired-switches-in-mode-line variable is as-is, the switches will be shown verbatim. If this variable’s value is an integer, the switch display will be truncated to that length. This variable can also be a function, which will be called with dired-actual-switches as the only parameter, and should return a string to display in the mode line.

如果您的ls程序支持 '--dired' 选项,Dired 自动传递该选项;这会导致ls为某些不寻常的文件名发出特殊的转义序列,否则 Dired 将无法解析这些名称。第一次在 Emacs 会话中运行 Dired 时,它会检查是否ls支持 '--dired' 选项,通过使用该选项调用一次。如果退出代码为 0,Dired 随后将使用 '--dired' 选项;否则就不会。您可以通过自定义变量来禁止此检查dired-use-ls-dired。该值unspecified(默认)表示执行检查;任何其他非nil值手段使用 '--dired' 选项;并nil意味着不使用 '--dired' 选项。

If your ls program supports the ‘--dired’ option, Dired automatically passes it that option; this causes ls to emit special escape sequences for certain unusual file names, without which Dired will not be able to parse those names. The first time you run Dired in an Emacs session, it checks whether ls supports the ‘--dired’ option by calling it once with that option. If the exit code is 0, Dired will subsequently use the ‘--dired’ option; otherwise it will not. You can inhibit this check by customizing the variable dired-use-ls-dired. The value unspecified (the default) means to perform the check; any other non-nil value means to use the ‘--dired’ option; and nil means not to use the ‘--dired’ option.

在 MS-Windows 和 MS-DOS 系统以及某些远程系统上,Emacs 模拟ls.有关该仿真的选项和特性, 请参阅MS-Windows 上的仿真。ls

On MS-Windows and MS-DOS systems, and also on some remote systems, Emacs emulates ls. See Emulation of ls on MS-Windows, for options and peculiarities of this emulation.

要在另一个窗口中显示 Dired 缓冲区,请使用C-x 4 d ( dired-other-window)。 C-x 5 d ( dired-other-frame) 在单独的帧中显示 Dired 缓冲区。

To display the Dired buffer in another window, use C-x 4 d (dired-other-window). C-x 5 d (dired-other-frame) displays the Dired buffer in a separate frame.

键入q( quit-window) 会隐藏 Dired 缓冲区,并删除其窗口(如果该窗口是专门为该缓冲区创建的)。

Typing q (quit-window) buries the Dired buffer, and deletes its window if the window was created just for that buffer.


31.2 Navigation in the Dired Buffer

所有常用的 Emacs 光标移动命令都可以在 Dired 缓冲区中使用。键C-n和分别C-p被重新定义为 run dired-next-linedired-previous-line,它们将光标放在该行文件名的开头,而不是行的开头。

All the usual Emacs cursor motion commands are available in Dired buffers. The keys C-n and C-p are redefined to run dired-next-line and dired-previous-line, respectively, and they put the cursor at the beginning of the file name on the line, rather than at the beginning of the line.

为了更加方便,SPCn在 Dired 中相当于C-n. p相当于C-p. (按行移动在 Dired 中非常常见,因此应该易于键入。) DEL (向上移动并取消标记)对于简单地向上移动也通常很有用(请参阅使用 Dired 删除文件)。

For extra convenience, SPC and n in Dired are equivalent to C-n. p is equivalent to C-p. (Moving by lines is so common in Dired that it deserves to be easy to type.) DEL (move up and unflag) is also often useful simply for moving up (see Deleting Files with Dired).

j( dired-goto-file) 提示使用迷你缓冲区输入文件名,并将指针移动到 Dired 缓冲区中描述该文件的行。

j (dired-goto-file) prompts for a file name using the minibuffer, and moves point to the line in the Dired buffer describing that file.

M-s f C-s( dired-isearch-filenames) 在 Dired 缓冲区中执行向前增量搜索,仅在文件名中查找匹配项并忽略缓冲区中的其余文本。 M-s f M-C-s( dired-isearch-filenames-regexp) 使用正则表达式搜索执行相同的操作。如果将变量更改dired-isearch-filenamest,则通常的搜索命令也会将其自身限制为文件名;例如,C-s行为类似于M-s f C-s.如果值为 dwim,则搜索命令仅当点最初位于文件名上时才匹配文件名。有关增量搜索的信息, 请参阅搜索和替换。

M-s f C-s (dired-isearch-filenames) performs a forward incremental search in the Dired buffer, looking for matches only amongst the file names and ignoring the rest of the text in the buffer. M-s f M-C-s (dired-isearch-filenames-regexp) does the same, using a regular expression search. If you change the variable dired-isearch-filenames to t, then the usual search commands also limit themselves to the file names; for instance, C-s behaves like M-s f C-s. If the value is dwim, then search commands match the file names only when point was on a file name initially. See Searching and Replacement, for information about incremental search.

当 Dired 缓冲区包含多个目录时,一些附加的导航命令可用。请参阅移动子目录

Some additional navigation commands are available when the Dired buffer includes several directories. See Moving Over Subdirectories.


31.3 使用 Dired 删除文件

31.3 Deleting Files with Dired

Dired 最常见的用途之一是首先标记要删除的文件,然后删除已标记的文件。

One of the most frequent uses of Dired is to first flag files for deletion, then delete the files that were flagged.

d
d

将此文件标记为删除 ( dired-flag-file-deletion)。

Flag this file for deletion (dired-flag-file-deletion).

u
u

删除删除标志( dired-unmark)。

Remove the deletion flag (dired-unmark).

DEL
DEL

将点移至上一行并删除该行上的删除标志 ( dired-unmark-backward)。

Move point to previous line and remove the deletion flag on that line (dired-unmark-backward).

x
x

删除标记为删除的文件 ( dired-do-flagged-delete)。

Delete files flagged for deletion (dired-do-flagged-delete).

您可以通过移至描述文件的行并键入d( dired-flag-file-deletion) 将文件标记为删除。删除标志可见为 'D' 在该行的开头。此命令将点移动到下一行,以便重复的d 命令标记连续的文件。数字前缀参数用作重复计数;负计数意味着标记前面的文件。

You can flag a file for deletion by moving to the line describing the file and typing d (dired-flag-file-deletion). The deletion flag is visible as a ‘D’ at the beginning of the line. This command moves point to the next line, so that repeated d commands flag successive files. A numeric prefix argument serves as a repeat count; a negative count means to flag preceding files.

如果该区域处于活动状态,则该d命令将该区域中的所有文件标记为删除;在这种情况下,该命令不会移动点,并忽略任何前缀参数。

If the region is active, the d command flags all files in the region for deletion; in this case, the command does not move point, and ignores any prefix argument.

将文件标记为删除而不是立即删除文件的原因是为了减少意外删除文件的危险。在指示 Dired 删除标记的文件之前,您可以使用命令u和删除删除标记DELu( dired-unmark) 的工作方式与 一样d,但删除标志而不是创建标志。 DEL ( dired-unmark-backward) 向上移动,移除标记;就像u参数−1 一样。任一命令的数字前缀参数用作重复计数,负计数表示在相反方向取消标记。如果该区域处于活动状态,这些命令会取消标记该区域中的所有文件,而不移动点。

The reason for flagging files for deletion, rather than deleting files immediately, is to reduce the danger of deleting a file accidentally. Until you direct Dired to delete the flagged files, you can remove deletion flags using the commands u and DEL. u (dired-unmark) works just like d, but removes flags rather than making flags. DEL (dired-unmark-backward) moves upward, removing flags; it is like u with argument −1. A numeric prefix argument to either command serves as a repeat count, with a negative count meaning to unflag in the opposite direction. If the region is active, these commands instead unflag all files in the region, without moving point.

要删除标记的文件,请键入x ( dired-do-flagged-delete)。此命令显示所有标记为删除的文件名的列表,并请求使用 进行确认 yes。如果您确认,Dired 将删除标记的文件,然后从 Dired 缓冲区的文本中删除它们的行。 Dired 缓冲区的行数稍少,仍保持选中状态。

To delete flagged files, type x (dired-do-flagged-delete). This command displays a list of all the file names flagged for deletion, and requests confirmation with yes. If you confirm, Dired deletes the flagged files, then deletes their lines from the text of the Dired buffer. The Dired buffer, with somewhat fewer lines, remains selected.

如果您在要求确认时回答no或退出C-g,您将立即返回 Dired,删除标志仍然存在于缓冲区中,并且没有实际删除的文件。

If you answer no or quit with C-g when asked to confirm, you return immediately to Dired, with the deletion flags still present in the buffer, and no files actually deleted.

您可以像删除其他文件一样删除空目录,但通常 Dired 无法删除非空目录。但是,如果变量dired-recursive-deletes为非- nil,则允许 Dired 删除非空目录,包括其所有内容。这可能有点冒险。如果该变量的值为always,Dired 会递归删除非空目录,风险更大。

You can delete empty directories just like other files, but normally Dired cannot delete directories that are nonempty. However, if the variable dired-recursive-deletes is non-nil, then Dired is allowed to delete nonempty directories including all their contents. That can be somewhat risky. If the value of the variable is always, Dired will delete nonempty directories recursively, which is even more risky.

即使您已设置dired-recursive-deletesnil,有时您也可能希望递归删除目录,而不要求对所有目录进行确认。例如,当您将许多目录标记为删除并且您非常确定可以安全地删除所有目录时,您可能希望这样做。对于每个非空目录,系统都会要求您确认删除,如果您回答 all,那么所有剩余的目录将被删除,没有任何进一步的问题。

Even if you have set dired-recursive-deletes to nil, you might want sometimes to delete directories recursively without being asked for confirmation for all of them. For example, you may want that when you have marked many directories for deletion and you are very sure that all of them can safely be deleted. For every nonempty directory you are asked for confirmation to delete, if you answer all, then all the remaining directories will be deleted without any further questions.

如果将变量更改delete-by-moving-to-trasht,上述删除命令会将受影响的文件或目录移动到操作系统的垃圾箱中,而不是直接删除它们。请参阅其他文件操作

If you change the variable delete-by-moving-to-trash to t, the above deletion commands will move the affected files or directories into the operating system’s Trash, instead of deleting them outright. See Miscellaneous File Operations.

删除文件的另一种方法是将其标记为m 并删除D,请参阅对文件进行操作

An alternative way of deleting files is to mark them with m and delete with D, see Operating on Files.


31.4 一次标记多个文件

31.4 Flagging Many Files at Once

#、、和命令根据文件名标记许多文件以进行删除 ~.% &% d

The #, ~, ., % &, and % d commands flag many files for deletion, based on their file names:

#
#

标记所有自动保存文件(名称以 ' 开头和结尾的文件#') 进行删除(请参阅自动保存:灾难防护)。

Flag all auto-save files (files whose names start and end with ‘#’) for deletion (see Auto-Saving: Protection Against Disasters).

~
~

标记所有备份文件(名称以 ' 结尾的文件)') 进行删除(请参阅备份文件)。

Flag all backup files (files whose names end with ‘~’) for deletion (see Backup Files).

. (Period)
. (Period)

标记多余的数字备份文件以进行删除。任一文件的最旧和最新的几个备份文件除外;中间的有标记。

Flag excess numeric backup files for deletion. The oldest and newest few backup files of any one file are exempt; the middle ones are flagged.

% &
% &

标记删除具有特定名称的所有文件,这表明您可以轻松地再次创建这些文件。

Flag for deletion all files with certain kinds of names which suggest you could easily create those files again.

% d regexp RET
% d regexp RET

标记删除名称与正则表达式 regexp匹配的所有文件。

Flag for deletion all files whose names match the regular expression regexp.

#( dired-flag-auto-save-files) 标记名称看起来像自动保存文件的所有文件,即名称以 ' 开头和结尾的文件#'。请参阅自动保存:灾难防护

# (dired-flag-auto-save-files) flags all files whose names look like auto-save files—that is, files whose names begin and end with ‘#’. See Auto-Saving: Protection Against Disasters.

~( dired-flag-backup-files) 标记名称为备份文件的所有文件,即名称以 ' 结尾的文件'。请参阅备份文件

~ (dired-flag-backup-files) flags all files whose names say they are backup files—that is, files whose names end in ‘~’. See Backup Files.

.(句点,dired-clean-directory)仅标记部分备份文件以进行删除:任何一个文件的除最旧的几个和最新的几个备份之外的所有备份文件。通常,为每个文件保留的最新版本的数量由变量给出dired-kept-versions不是 kept-new-versions;仅在保存时适用)。要保留的最旧版本的数量由变量给出 kept-old-versions

. (period, dired-clean-directory) flags just some of the backup files for deletion: all but the oldest few and newest few backups of any one file. Normally, the number of newest versions kept for each file is given by the variable dired-kept-versions (not kept-new-versions; that applies only when saving). The number of oldest versions to keep is given by the variable kept-old-versions.

带有正数字参数的句点(如 中C-u 3 .)指定要保留的最新版本的数量,覆盖 dired-kept-versions。负数字参数 overrides kept-old-versions,使用减去参数值来指定要保留的每个文件的最旧版本的数量。

Period with a positive numeric argument, as in C-u 3 ., specifies the number of newest versions to keep, overriding dired-kept-versions. A negative numeric argument overrides kept-old-versions, using minus the value of the argument to specify the number of oldest versions of each file to keep.

% &( dired-flag-garbage-files) 标记名称与变量指定的正则表达式匹配的文件 dired-garbage-files-regexp。默认情况下,这与 TeX 生成的某些文件匹配,'.bak' 文件,以及 '.orig' 和 '.rej' 生成的文件patch

% & (dired-flag-garbage-files) flags files whose names match the regular expression specified by the variable dired-garbage-files-regexp. By default, this matches certain files produced by TeX, ‘.bak’ files, and the ‘.orig’ and ‘.rej’ files produced by patch.

% d标记名称与指定正则表达式 ( dired-flag-files-regexp) 匹配的所有文件。仅使用文件名的非目录部分进行匹配。您可以使用 '^' 和 '$' 来锚定比赛。您可以通过在使用时隐藏某些子目录来从标记中排除它们% d。请参阅隐藏子目录

% d flags all files whose names match a specified regular expression (dired-flag-files-regexp). Only the non-directory part of the file name is used in matching. You can use ‘^’ and ‘$’ to anchor matches. You can exclude certain subdirectories from marking by hiding them while you use % d. See Hiding Subdirectories.


31.5 访问 Dired 中的文件

31.5 Visiting Files in Dired

有几个 Dired 命令用于访问或检查 Dired 缓冲区中列出的文件。所有这些都适用于当前行的文件;如果该文件确实是一个目录,这些命令会在该子目录上调用 Dired(创建一个单独的 Dired 缓冲区)。

There are several Dired commands for visiting or examining the files listed in the Dired buffer. All of them apply to the current line’s file; if that file is really a directory, these commands invoke Dired on that subdirectory (making a separate Dired buffer).

f
f

访问当前行描述的文件,例如键入C-x C-f 并提供该文件名 ( dired-find-file)。请参阅访问文件

Visit the file described on the current line, like typing C-x C-f and supplying that file name (dired-find-file). See Visiting Files.

RET
RET
e
e

相当于f

Equivalent to f.

o
o

与 类似f,但使用另一个窗口来显示文件的缓冲区 ( dired-find-file-other-window)。 Dired 缓冲区在第一个窗口中保持可见。这就像使用C-x 4 C-f来访问文件一样。请参阅多个窗口

Like f, but uses another window to display the file’s buffer (dired-find-file-other-window). The Dired buffer remains visible in the first window. This is like using C-x 4 C-f to visit the file. See Multiple Windows.

C-o
C-o

访问当前行描述的文件,并在另一个窗口中显示缓冲区,但不选择该窗口 ( dired-display-file)。

Visit the file described on the current line, and display the buffer in another window, but do not select that window (dired-display-file).

mouse-1
mouse-1
mouse-2
mouse-2

访问您单击其名称的文件 ( dired-mouse-find-file-other-window)。这使用另一个窗口来显示文件,就像o命令一样。

Visit the file whose name you clicked on (dired-mouse-find-file-other-window). This uses another window to display the file, like the o command.

v
v

dired-view-file使用查看模式 ( )查看当前行描述的文件。查看模式提供了方便的命令来导航缓冲区,但禁止更改它;请参阅查看模式

View the file described on the current line, with View mode (dired-view-file). View mode provides convenient commands to navigate the buffer but forbids changing it; See View Mode.

^
^

访问当前目录的父目录( dired-up-directory)。这相当于移动到该行..f在那里打字。

Visit the parent directory of the current directory (dired-up-directory). This is equivalent to moving to the line for .. and typing f there.

用户选项:dired-kill-when-opening-new-dired-buffer
User Option: dired-kill-when-opening-new-dired-buffer

当访问 Dired 中的新子目录时,Emacs 将(默认情况下)打开一个新缓冲区来显示这个新目录,并保持旧 Dired 缓冲区不变。如果此用户选项为非- nil,则在选择新目录后,旧的 Dired 缓冲区将被杀死。这意味着,如果您在 Dired 中遍历目录结构,最终不会得到多个 Dired 缓冲区。

When visiting a new sub-directory in Dired, Emacs will (by default) open a new buffer to display this new directory, and leave the old Dired buffer as is. If this user option is non-nil, the old Dired buffer will be killed after selecting the new directory. This means that if you’re traversing a directory structure in Dired, you won’t end up with more than a single Dired buffer.


31.6 Dired Marks 与 Flags

31.6 Dired Marks vs. Flags

而不是用 ' 标记文件D',您可以用一些其他字符来标记文件(通常是 '*')。大多数对文件进行操作的 Dired 命令都使用标有 ' 的文件*'。对标记文件进行操作的唯一命令是x,它会删除它们。

Instead of flagging a file with ‘D’, you can mark the file with some other character (usually ‘*’). Most Dired commands to operate on files use the files marked with ‘*’. The only command that operates on flagged files is x, which deletes them.

以下是一些用 ' 进行标记的命令*',用于取消标记以及对标记进行操作。 (有关标记和取消标记文件的命令, 请参阅使用 Dired 删除文件。)

Here are some commands for marking with ‘*’, for unmarking, and for operating on marks. (See Deleting Files with Dired, for commands to flag and unflag files.)

m
m
* m
* m

用 ' 标记当前文件*'(dired-mark)。如果该区域处于活动状态,则标记该区域中的所有文件;否则,如果提供了数字参数n ,则标记从当前文件开始的接下来的n个文件(如果n为负数,则标记前 - n个文件)。如果在子目录标题行上调用(请参阅Dired 中的子目录),此命令将标记该子目录中的所有文件。

Mark the current file with ‘*’ (dired-mark). If the region is active, mark all files in the region instead; otherwise, if a numeric argument n is supplied, mark the next n files instead, starting with the current file (if n is negative, mark the previous −n files). If invoked on a subdirectory header line (see Subdirectories in Dired), this command marks all the files in that subdirectory.

* N
* N

报告标记文件的数量和大小 ( dired-number-of-marked-files)。

Report what the number and size of the marked files are (dired-number-of-marked-files).

* *
* *

用 ' 标记所有可执行文件*'(dired-mark-executables)。使用数字参数,取消标记所有这些文件。

Mark all executable files with ‘*’ (dired-mark-executables). With a numeric argument, unmark all those files.

* @
* @

用 ' 标记所有符号链接*'(dired-mark-symlinks)。使用数字参数,取消标记所有这些文件。

Mark all symbolic links with ‘*’ (dired-mark-symlinks). With a numeric argument, unmark all those files.

* /
* /

用 ' 标记*' 所有属于目录的文件,除了 ..( dired-mark-directories)。使用数字参数,取消标记所有这些文件。

Mark with ‘*’ all files which are directories, except for . and .. (dired-mark-directories). With a numeric argument, unmark all those files.

* s
* s

标记当前子目录中的所有文件,除了..( dired-mark-subdir-files)。

Mark all the files in the current subdirectory, aside from . and .. (dired-mark-subdir-files).

u
u
* u
* u

删除该线上的任何标记 ( dired-unmark)。如果该区域处于活动状态,则取消标记该区域中的所有文件;否则,如果提供了数字参数n ,则取消标记接下来的n个文件,从当前文件开始(如果n为负数,则取消标记前n 个文件)。

Remove any mark on this line (dired-unmark). If the region is active, unmark all files in the region instead; otherwise, if a numeric argument n is supplied, unmark the next n files instead, starting with the current file (if n is negative, unmark the previous −n files).

DEL
DEL
* DEL
* DEL

将点移至上一行并删除该行上的所有标记 ( dired-unmark-backward)。如果该区域处于活动状态,则取消标记该区域中的所有文件;否则,如果 提供了数字参数n ,则取消标记前面的n个文件,从当前文件开始(如果n为负数,则取消标记接下来的n个文件)。

Move point to previous line and remove any mark on that line (dired-unmark-backward). If the region is active, unmark all files in the region instead; otherwise, if a numeric argument n is supplied, unmark the n preceding files instead, starting with the current file (if n is negative, unmark the next −n files).

* !
* !
U
U

删除此 Dired 缓冲区 ( ) 中所有文件的所有标记dired-unmark-all-marks

Remove all marks from all the files in this Dired buffer (dired-unmark-all-marks).

* ? markchar
* ? markchar
M-DEL
M-DEL

删除所有使用字符markchar ( dired-unmark-all-files) 的标记。如果使用 调用,该命令会提示输入markchar。该markchar是单个字符 - 不要使用它来终止它。请参阅下面命令的说明,该命令允许您将一个标记字符替换为另一个标记字符。 M-DELRET* c

使用数字参数,此命令查询每个标记的文件,询问是否删除其标记。您可以回答y“是”、 n“否”,或者!从剩余文件中删除标记而不询问它们。

Remove all marks that use the character markchar (dired-unmark-all-files). If invoked with M-DEL, the command prompts for markchar. That markchar is a single character—do not use RET to terminate it. See the description of the * c command below, which lets you replace one mark character with another.

With a numeric argument, this command queries about each marked file, asking whether to remove its mark. You can answer y meaning yes, n meaning no, or ! to remove the marks from the remaining files without asking about them.

* C-n
* C-n
M-}
M-}

向下移动到下一个标记的文件 ( dired-next-marked-file)。如果文件有任何类型的标记,则该文件被“标记”。

Move down to the next marked file (dired-next-marked-file). A file is “marked” if it has any kind of mark.

* C-p
* C-p
M-{
M-{

上移至上一个标记的文件 ( dired-prev-marked-file)。

Move up to the previous marked file (dired-prev-marked-file).

t
t
* t
* t

切换所有标记 ( dired-toggle-marks):标有 ' 的文件*' 变为未标记,未标记的文件被标记为 '*'。以任何其他方式标记的文件不受影响。

Toggle all marks (dired-toggle-marks): files marked with ‘*’ become unmarked, and unmarked files are marked with ‘*’. Files marked in any other way are not affected.

* c old-markchar new-markchar
* c old-markchar new-markchar

将使用字符old-markchar的所有标记替换为使用字符new-markchar ( dired-change-marks) 的标记。此命令是创建或使用除 ' 之外的标记的主要方法*' 或者 'D'。参数是单个字符——不要用来 RET终止它们。

通过该命令可以使用几乎任何字符作为标记字符,以区分各类文件。如果old-markchar 是一个空格 (' '),则该命令对所有未标记的文件进行操作;如果new-markchar是空格,则该命令取消标记其作用的文件。

为了说明该命令的强大功能,以下是如何放置 'D' 对所有没有标记的文件进行标记,同时取消标记所有已经有标记的文件 'D' 标志:

* c D t * c SPCD * ctSPC

这假设没有文件已标记为 't'。

Replace all marks that use the character old-markchar with marks that use the character new-markchar (dired-change-marks). This command is the primary way to create or use marks other than ‘*’ or ‘D’. The arguments are single characters—do not use RET to terminate them.

You can use almost any character as a mark character by means of this command, to distinguish various classes of files. If old-markchar is a space (‘ ’), then the command operates on all unmarked files; if new-markchar is a space, then the command unmarks the files it acts on.

To illustrate the power of this command, here is how to put ‘D’ flags on all the files that have no marks, while unflagging all those that already have ‘D’ flags:

* c D t  * c SPC D  * c t SPC

This assumes that no files were already marked with ‘t’.

% m regexp RET
% m regexp RET
* % regexp RET
* % regexp RET

标记(带有 '*') 名称与正则表达式 regexp ( dired-mark-files-regexp) 匹配的所有文件。该命令类似于 % d,只不过它用 ' 标记文件*' 而不是用 ' 标记D'。

仅使用文件名的非目录部分进行匹配。使用 '^' 和 '$' 来锚定比赛。您可以通过暂时隐藏子目录来排除它们(请参阅隐藏子目录)。

Mark (with ‘*’) all files whose names match the regular expression regexp (dired-mark-files-regexp). This command is like % d, except that it marks files with ‘*’ instead of flagging with ‘D’.

Only the non-directory part of the file name is used in matching. Use ‘^’ and ‘$’ to anchor matches. You can exclude subdirectories by temporarily hiding them (see Hiding Subdirectories).

% g regexp RET
% g regexp RET

标记(带有 '*') 其内容包含与正则表达式regexp ( )匹配的所有文件dired-mark-files-containing-regexp。该命令类似于 % m,不同之处在于它搜索文件内容而不是文件名。请注意,如果在 Emacs 缓冲区中访问了一个文件(默认情况),则dired-always-read-filesystemnil命令将在缓冲区中查找而不重新访问该文件,因此如果文件内容自访问以来已发生更改,结果可能与磁盘上的文件不一致。上次访问。如果您不希望这样做,您可能希望在调用此命令之前恢复您在缓冲区中访问过的文件,或者在这些缓冲区中打开自动恢复模式。请参阅恢复缓冲区。如果您希望此命令始终重新访问文件,而不必恢复文件或启用自动恢复模式,则可能需要设置 dired-always-read-filesystem为非nil.

Mark (with ‘*’) all files whose contents contain a match for the regular expression regexp (dired-mark-files-containing-regexp). This command is like % m, except that it searches the file contents instead of the file name. Note that if a file is visited in an Emacs buffer, and dired-always-read-filesystem is nil (the default), this command will look in the buffer without revisiting the file, so the results might be inconsistent with the file on disk if its contents have changed since it was last visited. If you don’t want this, you may wish to revert the files you have visited in your buffers, or to turn on Auto-Revert mode in those buffers, before invoking this command. See Reverting a Buffer. If you prefer that this command should always revisit the file, without you having to revert the file or enable Auto-Revert mode, you might want to set dired-always-read-filesystem to non-nil.

C-/
C-/
C-x u
C-x u
C-_
C-_

撤消 Dired 缓冲区中的更改,例如添加或删除标记 ( dired-undo)。 该命令不会恢复实际的文件操作,也不会恢复丢失的文件! 它只是撤消缓冲区本身的更改。

在某些情况下,在对文件进行操作的命令之后使用此命令可能会导致问题。例如,在重命名一个或多个文件后, dired-undo恢复 Dired 缓冲区中的原始名称,这会使 Dired 缓冲区与目录的实际内容不同步。

Undo changes in the Dired buffer, such as adding or removing marks (dired-undo). This command does not revert the actual file operations, nor recover lost files! It just undoes changes in the buffer itself.

In some cases, using this after commands that operate on files can cause trouble. For example, after renaming one or more files, dired-undo restores the original names in the Dired buffer, which gets the Dired buffer out of sync with the actual contents of the directory.


31.7 文件操作

31.7 Operating on Files

本节介绍对一个或多个文件进行操作的基本 Dired 命令。所有这些命令都是大写字母;他们都使用迷你缓冲区,在行动之前读取参数或请求确认。所有这些都允许您指定要通过以下方式操作的文件:

This section describes the basic Dired commands to operate on one file or several files. All of these commands are capital letters; all of them use the minibuffer, either to read an argument or to ask for confirmation, before they act. All of them let you specify the files to manipulate in these ways:

  • 如果为该命令提供数字前缀参数n,它将对从当前文件开始的接下来的n个文件进行操作。 (如果n 为负数,则该命令对当前行之前的 - n 个文件进行操作。)
  • If you give the command a numeric prefix argument n, it operates on the next n files, starting with the current file. (If n is negative, the command operates on the −n files preceding the current line.)
  • 否则,如果某些文件标有 '*',该命令对所有这些文件进行操作。
  • Otherwise, if some files are marked with ‘*’, the command operates on all those files.
  • 否则,该命令仅对当前文件进行操作。
  • Otherwise, the command operates on the current file only.

某些其他 Dired 命令,例如!和 '%' 命令,使用相同的约定来决定要处理哪些文件。

Certain other Dired commands, such as ! and the ‘%’ commands, use the same conventions to decide which files to work on.

除了此处描述的 Dired 命令之外,您还可以对 Dired 缓冲区中显示的一个或多个文件调用版本控制 (VC) 命令。请参阅版本控制

In addition to Dired commands described here, you can also invoke Version Control (VC) commands on one or more files shown in a Dired buffer. See Version Control.

要求目标目录的命令(例如复制和重命名文件或为其创建链接的命令)会尝试猜测操作的默认目标目录。通常,他们建议 Dired 缓冲区的默认目录,但如果该选项dired-dwim-target 为 non- nil,并且如果某个窗口中显示另一个 Dired 缓冲区,则建议使用其他缓冲区的目录。您可以自定义dired-dwim-target以选择下一个带有 Dired 缓冲区的窗口,或者最近使用的带有 Dired 缓冲区的窗口,或者使用任何其他功能。当该值是一个函数时,它将被不带参数地调用,并预计返回将用作默认值的目录列表(即默认目标和“未来历史记录”)。

Commands which ask for a destination directory, such as those which copy and rename files or create links for them, try to guess the default target directory for the operation. Normally, they suggest the Dired buffer’s default directory, but if the option dired-dwim-target is non-nil, and if there is another Dired buffer displayed in some window, that other buffer’s directory is suggested instead. You can customize dired-dwim-target to prefer either the next window with a Dired buffer, or the most recently used window with a Dired buffer, or to use any other function. When the value is a function, it will be called with no arguments and is expected to return a list of directories which will be used as defaults (i.e. default target and “future history”).

以下是对文件进行操作的 Dired 命令。

Here are the file-manipulating Dired commands that operate on files.

C new RET
C new RET

复制指定文件 ( dired-do-copy)。参数new 是要复制到的目录,或者(如果复制单个文件)新名称。这就像 shell 命令cp

该选项dired-create-destination-dirs控制 Dired 在复制/重命名文件时是否应在目标中创建不存在的目录。默认值nil意味着 Dired 永远不会创建此类丢失的目录; value always,表示 Dired 自动创建它们;该值ask 表示 Dired 在创建它们之前要求您确认。

如果该选项dired-create-destination-dirs-on-trailing-dirsep 是非nil除了 之外dired-create-destination-dirs,则将特殊处理目标目录中的尾随目录分隔符。在这种情况下,当复制到 '测试/'并且没有目录'测试' 已经存在,它将被创建,并将指定的源文件或目录复制到新创建的目录中。

如果dired-copy-preserve-time是 non- nil,则使用此命令进行复制会保留副本中旧文件的修改时间,例如 'cp-p'。

该变量dired-recursive-copies控制是否递归复制目录(例如 'cp-r')。默认值为 top,这意味着在递归复制目录之前询问。

该变量dired-copy-dereference控制是否将符号链接复制为链接或在取消引用后复制(例如 'cp-L')。默认值为nil,这意味着通过创建新符号链接来复制符号链接。

用户dired-keep-marker-copy选项控制该命令如何处理文件标记。默认设置是用 ' 标记文件的所有新副本C' 标记。

Copy the specified files (dired-do-copy). The argument new is the directory to copy into, or (if copying a single file) the new name. This is like the shell command cp.

The option dired-create-destination-dirs controls whether Dired should create non-existent directories in the destination while copying/renaming files. The default value nil means Dired never creates such missing directories; the value always, means Dired automatically creates them; the value ask means Dired asks you for confirmation before creating them.

If the option dired-create-destination-dirs-on-trailing-dirsep is non-nil in addition to dired-create-destination-dirs, a trailing directory separator at the destination directory is treated specially. In that case, when copying to ‘test/’ and no directory ‘test’ exists already, it will be created and the specified source files or directories are copied into the newly created directory.

If dired-copy-preserve-time is non-nil, then copying with this command preserves the modification time of the old file in the copy, like ‘cp -p’.

The variable dired-recursive-copies controls whether to copy directories recursively (like ‘cp -r’). The default is top, which means to ask before recursively copying a directory.

The variable dired-copy-dereference controls whether to copy symbolic links as links or after dereferencing (like ‘cp -L’). The default is nil, which means that the symbolic links are copied by creating new ones.

The dired-keep-marker-copy user option controls how this command handles file marking. The default is to mark all new copies of files with a ‘C’ mark.

D
D

删除指定文件( dired-do-delete)。这就像 shell 命令rm

与本节中的其他命令一样,该命令对 标记的文件或接下来的n 个文件进行操作。相比之下,x ( dired-do-flagged-delete) 会删除所有标记的文件。

Delete the specified files (dired-do-delete). This is like the shell command rm.

Like the other commands in this section, this command operates on the marked files, or the next n files. By contrast, x (dired-do-flagged-delete) deletes all flagged files.

R new RET
R new RET

重命名指定文件 ( dired-do-rename)。如果重命名单个文件,则参数new是该文件的新名称。如果重命名多个文件,则参数new是将文件移动到的目录(这类似于 shell 命令mv)。

该选项控制 Dired 是否应在newdired-create-destination-dirs中创建不存在的目录。

dired-create-destination-dirs-on-trailing-dirsep当除了 之外设置该选项时,该选项dired-create-destination-dirs控制是否特殊处理目标处的尾随目录分隔符。在这种情况下,当重命名目录时'老的' 到 '新的/'并且没有目录'新的' 已经存在,它将被创建并且 '老的' 被移动到新创建的目录中。否则, '老的' 被重命名为 '新的'。

Dired 会自动更改与重命名文件关联的缓冲区的已访问文件名,以便它们引用新名称。

如果变量的值为dired-vc-rename-filenon- nil,则使用底层 VCS 的命令通过 via 重命名文件 vc-rename-file(请参阅删除和重命名版本控制文件)。

Rename the specified files (dired-do-rename). If you rename a single file, the argument new is the new name of the file. If you rename several files, the argument new is the directory into which to move the files (this is like the shell command mv).

The option dired-create-destination-dirs controls whether Dired should create non-existent directories in new.

The option dired-create-destination-dirs-on-trailing-dirsep, when set in addition to dired-create-destination-dirs, controls whether a trailing directory separator at the destination is treated specially. In that case, when renaming a directory ‘old’ to ‘new/’ and no directory ‘new’ exists already, it will be created and ‘old’ is moved into the newly created directory. Otherwise, ‘old’ is renamed to ‘new’.

Dired automatically changes the visited file name of buffers associated with renamed files so that they refer to the new names.

If the value of the variable dired-vc-rename-file is non-nil, files are renamed using the commands of the underlying VCS, via vc-rename-file (see Deleting and Renaming Version-Controlled Files).

H new RET
H new RET

建立指向指定文件的硬链接 ( dired-do-hardlink)。这就像 shell 命令ln。参数new是要在其中创建链接的目录,或者(如果仅创建一个链接)为链接提供的名称。

Make hard links to the specified files (dired-do-hardlink). This is like the shell command ln. The argument new is the directory to make the links in, or (if making just one link) the name to give the link.

S new RET
S new RET

建立指向指定文件的符号链接 ( dired-do-symlink)。这就像'ln-s'。参数new是要在其中创建链接的目录,或者(如果仅创建一个链接)为链接提供的名称。

Make symbolic links to the specified files (dired-do-symlink). This is like ‘ln -s’. The argument new is the directory to make the links in, or (if making just one link) the name to give the link.

Y new RET
Y new RET

建立指向指定文件的相对符号链接 ( dired-do-relsymlink)。参数new是要在其中创建链接的目录,或者(如果仅创建一个链接)为链接提供的名称。这类似于dired-do-symlink但创建了相对的符号链接。例如:

    foo -> ../bar/foo

它不会创建绝对的,例如:

    foo -> /path/that/may/change/any/day/bar/foo

Make relative symbolic links to the specified files (dired-do-relsymlink). The argument new is the directory to make the links in, or (if making just one link) the name to give the link. This is like dired-do-symlink but creates relative symbolic links. For example:

    foo -> ../bar/foo

It does not create absolute ones like:

    foo -> /path/that/may/change/any/day/bar/foo
M modespec RET
M modespec RET

更改指定文件的模式(也称为权限位dired-do-chmod)( )。 modespec可以采用八进制或符号表示法,就像chmod 程序处理的参数一样。此命令不遵循符号链接,因此如果您尝试在此类模式不可变的平台上更改符号链接的模式,它会报告错误。

Change the mode (also called permission bits) of the specified files (dired-do-chmod). modespec can be in octal or symbolic notation, like arguments handled by the chmod program. This command does not follow symbolic links, so it reports an error if you try to change the mode of a symbolic link on a platform where such modes are immutable.

G newgroup RET
G newgroup RET

将指定文件的组更改为newgroup ( dired-do-chgrp)。

Change the group of the specified files to newgroup (dired-do-chgrp).

O newowner RET
O newowner RET

将指定文件的所有者更改为newowner ( dired-do-chown)。 (在大多数系统上,只有超级用户可以执行此操作。)

该变量dired-chown-program指定用于完成工作的程序的名称。 (这个变量是必要的,因为不同的系统放在chown不同的地方)。

Change the owner of the specified files to newowner (dired-do-chown). (On most systems, only the superuser can do this.)

The variable dired-chown-program specifies the name of the program to use to do the work. (This variable is necessary because different systems put chown in different places).

T timestamp RET
T timestamp RET

触摸指定的文件 ( dired-do-touch)。这意味着将它们的修改时间更新为timestamp,默认为当前时间。这就像 shell 命令touch

Touch the specified files (dired-do-touch). This means updating their modification times to timestamp, which defaults to the present time. This is like the shell command touch.

P command RET
P command RET

打印指定文件 ( dired-do-print)。您必须指定用于打印它们的命令,但迷你缓冲区首先使用变量lpr-commandlpr-switches(使用相同的变量lpr-buffer;请参阅打印硬拷贝)进行适当的猜测。

Print the specified files (dired-do-print). You must specify the command to print them with, but the minibuffer starts out with a suitable guess made using the variables lpr-command and lpr-switches (the same variables that lpr-buffer uses; see Printing Hard Copies).

Z
Z

压缩指定文件 ( dired-do-compress)。如果该文件看起来已经是压缩文件,请将其解压缩。每个标记的文件都被压缩到自己的存档中;如果该程序可用,则使用该 gzip程序,否则使用 compress.

对于目录名称,此命令根据dired-compress-directory-default-suffix用户选项生成压缩存档。默认是一个.tar.gztar通过运行命令并将输出通过管道传输到.archive 来包含该目录的所有文件gzip。要允许解压缩压缩目录,请Z键入.tar.gz或者.tgzarchive file 将存档中的所有文件解压到一个目录中,该目录的名称是存档名称并删除扩展名。

Compress the specified files (dired-do-compress). If the file appears to be a compressed file already, uncompress it instead. Each marked file is compressed into its own archive; this uses the gzip program if it is available, otherwise it uses compress.

On a directory name, this command produces a compressed archive depending on the dired-compress-directory-default-suffix user option. The default is a .tar.gz archive containing all of the directory’s files, by running the tar command with output piped to gzip. To allow decompression of compressed directories, typing Z on a .tar.gz or .tgz archive file unpacks all the files in the archive into a directory whose name is the archive name with the extension removed.

c
c

将指定文件 ( dired-do-compress-to) 压缩到文件系统上任意位置的单个存档中。默认存档由用户选项控制dired-compress-directory-default-suffix。另见dired-compress-files-alist

Compress the specified files (dired-do-compress-to) into a single archive anywhere on the file system. The default archive is controlled by the dired-compress-directory-default-suffix user option. Also see dired-compress-files-alist.

:d
:d

解密指定文件 ( epa-dired-do-decrypt)。参见EasyPG Assistant 用户手册中的Dired 集成

Decrypt the specified files (epa-dired-do-decrypt). See Dired integration in EasyPG Assistant User’s Manual.

:v
:v

验证指定文件的数字签名 ( epa-dired-do-verify)。参见EasyPG Assistant 用户手册中的Dired 集成

Verify digital signatures on the specified files (epa-dired-do-verify). See Dired integration in EasyPG Assistant User’s Manual.

:s
:s

对指定文件进行数字签名 ( epa-dired-do-sign)。参见EasyPG Assistant 用户手册中的Dired 集成

Digitally sign the specified files (epa-dired-do-sign). See Dired integration in EasyPG Assistant User’s Manual.

:e
:e

加密指定文件 ( epa-dired-do-encrypt)。参见EasyPG Assistant 用户手册中的Dired 集成

Encrypt the specified files (epa-dired-do-encrypt). See Dired integration in EasyPG Assistant User’s Manual.

L
L

加载指定的 Emacs Lisp 文件 ( dired-do-load)。请参阅Emacs 的 Lisp 代码库

Load the specified Emacs Lisp files (dired-do-load). See Libraries of Lisp Code for Emacs.

B
B

字节编译指定的 Emacs Lisp 文件 ( dired-do-byte-compile)。请参阅Emacs Lisp 参考手册中的字节编译

Byte compile the specified Emacs Lisp files (dired-do-byte-compile). See Byte Compilation in The Emacs Lisp Reference Manual.

I
I

对此文件(假设是 Info 格式的文件)运行 Info。

Run Info on this file (assumed to be a file in Info format).

N
N

对此文件运行 man (假设是nroff格式文件)。

Run man on this file (assumed to be a file in nroff format).

A regexp RET
A regexp RET

在所有指定文件中搜索正则表达式regexp ( dired-do-find-regexp)。

xref-find-references 此命令是(请参阅使用标识符搜索和替换)的变体,它显示*外部参考*缓冲区,您可以在其中在匹配项之间导航并根据需要使用命令中描述的命令显示它们*外部参考*缓冲

如果任何标记的文件是目录,则此命令将递归地搜索这些目录中的所有文件及其任何子目录,但名称匹配的文件 grep-find-ignored-files和名称匹配的子目录 除外grep-find-ignored-directories

Search all the specified files for the regular expression regexp (dired-do-find-regexp).

This command is a variant of xref-find-references (see Searching and Replacing with Identifiers), it displays the *xref* buffer, where you can navigate between matches and display them as needed using the commands described in Commands Available in the *xref* Buffer.

If any of the marked files are directories, then this command searches all of the files in those directories, and any of their subdirectories, recursively, except files whose names match grep-find-ignored-files and subdirectories whose names match grep-find-ignored-directories.

Q regexp RET to RET
Q regexp RET to RET

query-replace-regexp对每个指定文件执行,将regexp的匹配项替换为字符串 ( ) dired-do-find-regexp-and-replace

该命令是xref-query-replace-in-results.它提出了一个*外部参考*列出了regexp的所有匹配项的缓冲区,您可以使用该缓冲区中的特殊命令(请参阅*外部参考*缓冲)。特别是,如果退出查询替换循环,则可以r在该缓冲区中使用来替换更多匹配项。请参阅使用标识符进行搜索和替换

与 一样dired-do-find-regexp,如果任何标记的文件是目录,则此命令会递归地对这些目录及其任何子目录中的所有文件执行替换,但名称匹配的文件grep-find-ignored-files和名称匹配的子目录除外grep-find-ignored-directories

Perform query-replace-regexp on each of the specified files, replacing matches for regexp with the string to (dired-do-find-regexp-and-replace).

This command is a variant of xref-query-replace-in-results. It presents an *xref* buffer that lists all the matches of regexp, and you can use the special commands in that buffer (see Commands Available in the *xref* Buffer). In particular, if you exit the query replace loop, you can use r in that buffer to replace more matches. See Searching and Replacing with Identifiers.

Like with dired-do-find-regexp, if any of the marked files are directories, this command performs replacements in all of the files in those directories, and in any of their subdirectories, recursively, except for files whose names match grep-find-ignored-files and subdirectories whose names match grep-find-ignored-directories.


31.8 Dired 中的 Shell 命令

31.8 Shell Commands in Dired

Dired 命令!( dired-do-shell-command) 读取迷你缓冲区中的 shell 命令字符串,并对一个或多个文件运行该 shell 命令。 shell 命令操作的文件以 Dired 命令的常用方式确定(请参阅操作文件)。该命令X是 的同义词!

The Dired command ! (dired-do-shell-command) reads a shell command string in the minibuffer, and runs that shell command on one or more files. The files that the shell command operates on are determined in the usual way for Dired commands (see Operating on Files). The command X is a synonym for !.

命令&( dired-do-async-shell-command) 执行相同的操作,只不过它异步运行 shell 命令。 (您也可以!通过附加 '&' 字符添加到 shell 命令末尾。)当该命令对多个文件进行操作时,它会运行指定 shell 命令的多个并行副本,每个文件一个。作为例外,如果指定的 shell 命令以 ' 结尾;' 或者 ';&',shell 命令在后台按顺序对每个文件运行; Emacs 等待每个调用的 shell 命令终止,然后再运行下一个命令。

The command & (dired-do-async-shell-command) does the same, except that it runs the shell command asynchronously. (You can also do this with !, by appending a ‘&’ character to the end of the shell command.) When the command operates on more than one file, it runs multiple parallel copies of the specified shell command, one for each file. As an exception, if the specified shell command ends in ‘;’ or ‘;&’, the shell command is run in the background on each file sequentially; Emacs waits for each invoked shell command to terminate before running the next one.

对于!&,shell 命令的工作目录是 Dired 缓冲区的顶级目录。

For both ! and &, the working directory for the shell command is the top-level directory of the Dired buffer.

如果您告诉!&对多个文件进行操作,则 shell 命令字符串将确定如何将这些文件传递给 shell 命令:

If you tell ! or & to operate on more than one file, the shell command string determines how those files are passed to the shell command:

  • 如果你使用'*' 在命令字符串中被空格包围,则该命令仅运行一次,并用文件名列表替换 '*'。文件名的顺序是 Dired 缓冲区中出现的顺序。

    因此,在整个文件名列表上运行,将它们放入一个 tar 文件中! tar cf foo.tar * RETtarfoo.tar

    如果你想使用'*' 作为 shell 通配符,周围有空格,写 '*“”'。在 shell 中,这相当于 '*';但自从'*' 没有被空格包围,Dired 不会特殊对待它。如果您这样做,Emacs 将提示您确认,除非dired-confirm-shell-commandnil

  • If you use ‘*’ surrounded by whitespace in the command string, then the command runs just once, with the list of file names substituted for the ‘*’. The order of file names is the order of appearance in the Dired buffer.

    Thus, ! tar cf foo.tar * RET runs tar on the entire list of file names, putting them into one tar file foo.tar.

    If you want to use ‘*’ as a shell wildcard with whitespace around it, write ‘*""’. In the shell, this is equivalent to ‘*’; but since the ‘*’ is not surrounded by whitespace, Dired does not treat it specially. Emacs will prompt for confirmation if you do this, unless dired-confirm-shell-command is nil.

  • 否则,如果命令字符串包含 '' 被空格包围或 '``?``', Emacs对每个文件运行一次 shell 命令 ,并将当前文件名替换为 '' 和 '``?``' 每一次。您可以同时使用 '' 和 '``?``' 在命令中不止一次;相同的文件名会替换每次出现的情况。如果你将它们与 ' 混合*' 该命令发出错误信号。
  • Otherwise, if the command string contains ‘?’ surrounded by whitespace or ‘`?`’, Emacs runs the shell command once for each file, substituting the current file name for ‘?’ and ‘`?`’ each time. You can use both ‘?’ and ‘`?`’ more than once in the command; the same file name replaces each occurrence. If you mix them with ‘*’ the command signals an error.
  • 如果命令字符串不包含 '*'也不''也不'``?``',Emacs 对每个文件运行一次 shell 命令,并在末尾添加文件名。例如,在每个文件上 运行。! uudecode RETuudecode
  • If the command string contains neither ‘*’ nor ‘?’ nor ‘`?`’, Emacs runs the shell command once for each file, adding the file name at the end. For example, ! uudecode RET runs uudecode on each file.

要以更复杂的方式迭代文件名,您可能更喜欢使用显式 shell 循环。例如,以下是如何对每个文件进行 uuencode,通过附加 ' 来生成输出文件名.uu' 到输入文件名:

To iterate over the file names in a more complicated fashion, you might prefer to use an explicit shell loop. For example, here is how to uuencode each file, making the output file name by appending ‘.uu’ to the input file name:

对于 * 中的文件;做 uuencode "$file" "$file" >"$file".uu;完毕
for file in * ; do uuencode "$file" "$file" >"$file".uu; done

与 ' 相同的示例``?``' 符号:

The same example with ‘`?`’ notation:

uu编码? ? > `?`.uu
uuencode ? ? > `?`.uu

!和命令&不会尝试更新 Dired 缓冲区以显示新的或修改的文件,因为它们不知道哪些文件将被更改。使用该g命令更新 Dired 缓冲区(请参阅更新 Dired 缓冲区)。

The ! and & commands do not attempt to update the Dired buffer to show new or modified files, because they don’t know what files will be changed. Use the g command to update the Dired buffer (see Updating the Dired Buffer).

有关在 Dired 外部运行 shell 命令的信息, 请参阅单个 Shell 命令。

See Single Shell Commands, for information about running shell commands outside Dired.


31.9 Shell命令猜测

31.9 Shell Command Guessing

根据文件名,Dired 尝试猜测您可能想要对其应用什么 shell 命令。例如,如果您指向一个名为foo.tar当你按下时!,Dired 会猜到你想跑’焦油xvf',并建议将其作为默认 shell 命令。

Based upon the name of a file, Dired tries to guess what shell command you might want to apply to it. For example, if you have point on a file named foo.tar and you press !, Dired will guess that you want to run ‘tar xvf’, and suggest that as the default shell command.

您可以键入M-n以将默认值放入迷你缓冲区中进行编辑。如果给定文件有多个命令,请键入 M-n多次以按顺序查看每个匹配的命令。

You can type M-n to get the default into the minibuffer for editing. If there are several commands for a given file, type M-n several times to see each matching command in order.

Dired 只尝试猜测单个文件的命令,而不会尝试猜测标记文件列表。

Dired only tries to guess a command for a single file, never for a list of marked files.

变量:dired-guess-shell-alist-default
Variable: dired-guess-shell-alist-default

该变量指定猜测适合某些文件的 shell 命令的预定义规则。将其设置为nil关闭猜测。dired-guess-shell-alist-user (由用户定义) 的元素将覆盖这些规则。

This variable specifies the predefined rules for guessing shell commands suitable for certain files. Set this to nil to turn guessing off. The elements of dired-guess-shell-alist-user (defined by the user) will override these rules.

变量:dired-guess-shell-alist-user
Variable: dired-guess-shell-alist-user

如果不是nil,则此变量指定用户定义的文件正则表达式列表及其建议的命令。运行dired-guess-shell-alist-default时 这些规则优先于变量中的预定义规则 )。dired-do-shell-command默认为nil.

alist 的每个元素看起来像

正则表达式 命令...)

其中每个命令可以是字符串,也可以是计算结果为字符串的 Lisp 表达式。如果发出多个命令,所有命令都会暂时被推送到历史记录中。

A '*shell 命令中的 ' 代表与 regexp匹配的文件名。当 Emacs 调用该命令时,它会替换 ' 的每个实例*' 与匹配的文件名。

添加规则 '.foo' 和 '。酒吧' 文件扩展名,将其添加到您的 Init 文件中:

(setq dired-guess-shell-alist-用户
      (列表
       (list "\\.foo$" " foo-command ") ;固定规则
       ;;可能还有更多规则...
       (list "\\.bar$" ; 带有条件测试的规则
             '(如果条件bar-command-1 ”
                “ bar-command-2 ”))))

这将覆盖相同扩展名的任何预定义规则。

If non-nil, this variable specifies the user-defined alist of file regexps and their suggested commands. These rules take precedence over the predefined rules in the variable dired-guess-shell-alist-default when dired-do-shell-command is run). The default is nil.

Each element of the alist looks like

(regexp command…)

where each command can either be a string or a Lisp expression that evaluates to a string. If several commands are given, all of them will temporarily be pushed onto the history.

A ‘*’ in the shell command stands for the file name that matched regexp. When Emacs invokes the command, it replaces each instance of ‘*’ with the matched file name.

To add rules for ‘.foo’ and ‘.bar’ file extensions, add this to your Init file:

(setq dired-guess-shell-alist-user
      (list
       (list "\\.foo$" "foo-command")  ; fixed rule
       ;; possibly more rules...
       (list "\\.bar$"  ; rule with condition test
             '(if condition
                  "bar-command-1"
                "bar-command-2"))))

This will override any predefined rules for the same extensions.

您可以通过 找到更多用户选项。 M-x customize-group RET dired-guess RET

You can find more user options with M-x customize-group RET dired-guess RET.


31.10 转换 Dired 中的文件名

31.10 Transforming File Names in Dired

本节介绍以系统方式更改文件名的 Dired 命令。每个命令都对部分或全部标记的文件进行操作,使用通过转换现有名称而生成的新名称。

This section describes Dired commands which alter file names in a systematic way. Each command operates on some or all of the marked files, using a new name made by transforming the existing name.

与基本的 Dired 文件操作命令(请参阅对文件进行操作)类似,此处描述的命令对接下来的 n个文件或所有标有 ' 的文件进行操作*',或在当前文件上。 (要标记文件,请使用Dired Marks 与 Flags中描述的命令。)

Like the basic Dired file-manipulation commands (see Operating on Files), the commands described here operate either on the next n files, or on all files marked with ‘*’, or on the current file. (To mark files, use the commands described in Dired Marks vs. Flags.)

本节中描述的所有命令都是 交互式工作的:它们要求您确认每个候选文件的操作。因此,您可以选择比实际需要操作更多的文件(例如,使用匹配许多文件的正则表达式),然后通过键入yn在命令提示确认时过滤所选名称。

All of the commands described in this section work interactively: they ask you to confirm the operation for each candidate file. Thus, you can select more files than you actually need to operate on (e.g., with a regexp that matches many files), and then filter the selected names by typing y or n when the command prompts for confirmation.

% u
% u

将每个选定的文件重命名为大写名称 ( dired-upcase)。如果旧文件名是酒吧,新名称是FOO酒吧

Rename each of the selected files to an upper-case name (dired-upcase). If the old file names are Foo and bar, the new names are FOO and BAR.

% l
% l

将每个选定的文件重命名为小写名称 ( dired-downcase)。如果旧文件名是酒吧,新名称是酒吧

Rename each of the selected files to a lower-case name (dired-downcase). If the old file names are Foo and bar, the new names are foo and bar.

% R from RET to RET
% R from RET to RET
% C from RET to RET
% C from RET to RET
% H from RET to RET
% H from RET to RET
% S from RET to RET
% S from RET to RET
% Y from RET to RET
% Y from RET to RET

这五个命令重命名、复制、创建硬链接、创建软链接和创建相对软链接,在每种情况下都通过从旧文件的名称进行正则表达式替换来计算新名称。

These five commands rename, copy, make hard links, make soft links, and make relative soft links, in each case computing the new name by regular-expression substitution from the name of the old file.

四个正则表达式替换命令有效地对所选文件名执行搜索和替换。他们读取两个参数:来自 的正则表达式和;替换模式。它们将每个旧文件名与 from进行匹配,然后将匹配部分替换为to。您可以使用 '\&' 和 '\数字' 在to中引用旧文件名中匹配的模式的全部或部分,如 replace-regexp(请参阅Regexp Replacement)。如果正则表达式在文件名中匹配多次,则仅替换第一个匹配项。

The four regular-expression substitution commands effectively perform a search-and-replace on the selected file names. They read two arguments: a regular expression from, and a substitution pattern to; they match each old file name against from, and then replace the matching part with to. You can use ‘\&’ and ‘\digit’ in to to refer to all or part of what the pattern matched in the old file name, as in replace-regexp (see Regexp Replacement). If the regular expression matches more than once in a file name, only the first match is replaced.

例如,通过在前面添加 ' 来重命名每个选定的文件% R ^.*$ RET x-\& RETX-’正如它的名字一样。与此相反,删除 'X-' 从每个文件名的前面,也是可能的:一种方法是;另一个是 。 (使用 '% R ^x-\(.*\)$ RET \1 RET% R ^x- RET RET^' 和 '$' 来锚定应该跨越整个文件名的匹配。)

For example, % R ^.*$ RET x-\& RET renames each selected file by prepending ‘x-’ to its name. The inverse of this, removing ‘x-’ from the front of each file name, is also possible: one method is % R ^x-\(.*\)$ RET \1 RET; another is % R ^x- RET RET. (Use ‘^’ and ‘$’ to anchor matches that should span the whole file name.)

通常,替换过程不考虑文件的目录名;它对目录中的文件名进行操作。如果指定数字参数为零,则替换会影响整个绝对文件名,包括目录名。 (非零参数指定要操作的文件数。)

Normally, the replacement process does not consider the files’ directory names; it operates on the file name within the directory. If you specify a numeric argument of zero, then replacement affects the entire absolute file name including directory name. (A non-zero argument specifies the number of files to operate on.)

您可能希望使用与操作它们相同的正则表达式选择要操作的文件集。为此,请用 标记这些文件,然后在命令中使用相同的正则表达式对文件进行操作。为了更方便,操作文件的命令默认使用任何命令中指定的最后一个正则表达式。 % m from RET%%

You may want to select the set of files to operate on using the same regexp from that you will use to operate on them. To do this, mark those files with % m from RET, then use the same regular expression in the command to operate on the files. To make this more convenient, the % commands to operate on files use the last regular expression specified in any % command as a default.


31.11 与 Dired 进行文件比较

31.11 File Comparison with Dired

=( )命令dired-diff使用程序将当前文件(当前文件)与另一个文件(使用迷你缓冲区读取)进行比较diff。用迷你缓冲区指定的文件是 的第一个参数diff,指向的文件是第二个参数。程序的输出diff使用 Diff 模式显示在缓冲区中(请参阅比较文件)。

The = (dired-diff) command compares the current file (the file at point) with another file (read using the minibuffer) using the diff program. The file specified with the minibuffer is the first argument of diff, and file at point is the second argument. The output of the diff program is shown in a buffer using Diff mode (see Comparing Files).

如果区域处于活动状态,则使用迷你缓冲区读取的文件的默认值是标记处的文件(即普通的 Emacs 标记,而不是 Dired 标记;请参阅设置标记)。否则,如果此时的文件有备份文件(请参阅备份文件),则这是默认设置。

If the region is active, the default for the file read using the minibuffer is the file at the mark (i.e., the ordinary Emacs mark, not a Dired mark; see Setting the Mark). Otherwise, if the file at point has a backup file (see Backup Files), that is the default.

您还可以使用比较文件ediff-files,请参阅 Ediff 用户手册中的主要入口点

You could also compare files using ediff-files, see Major Entry Points in Ediff User’s Manual.


31.12 Dired 中的子目录

31.12 Subdirectories in Dired

Dired 缓冲区通常只显示一个目录,但您也可以选择包含其子目录。

A Dired buffer usually displays just one directory, but you can optionally include its subdirectories as well.

在一个 Dired 缓冲区中包含多个目录的最简单方法是指定选项 '-lR'为了跑步ls。 (如果在运行 Dired 时给出数字参数,则可以在迷你缓冲区中指定这些选项。)这会生成一个递归目录列表,显示所有级别的所有子目录。

The simplest way to include multiple directories in one Dired buffer is to specify the options ‘-lR’ for running ls. (If you give a numeric argument when you run Dired, then you can specify these options in the minibuffer.) That produces a recursive directory listing showing all subdirectories at all levels.

更常见的是,您只想显示特定的子目录。您可以使用i( dired-maybe-insert-subdir) 来执行此操作:

More often, you will want to show only specific subdirectories. You can do this with i (dired-maybe-insert-subdir):

i
i

稍后将子目录的内容插入缓冲区。

Insert the contents of a subdirectory later in the buffer.

如果在描述目录文件的行上使用此命令,它将将该目录的内容插入到同一个 Dired 缓冲区中,并移动到那里。插入的子目录内容遵循 Dired 缓冲区的顶级目录,就像它们在 '1R' 输出。

If you use this command on a line that describes a file which is a directory, it inserts the contents of that directory into the same Dired buffer, and moves there. Inserted subdirectory contents follow the top-level directory of the Dired buffer, just as they do in ‘ls -lR’ output.

如果子目录的内容已存在于缓冲区中,i则命令将移至该子目录。

If the subdirectory’s contents are already present in the buffer, the i command just moves to it.

无论哪种情况,都在i移动之前设置 Emacs 标记,以便 返回到 Dired 缓冲区中的先前位置(请参阅设置标记)。您还可以使用 'C-u C-SPC^' 返回同一 Dired 缓冲区中的父目录(请参阅访问 Dired 中的文件)。

In either case, i sets the Emacs mark before moving, so C-u C-SPC returns to your previous position in the Dired buffer (see Setting the Mark). You can also use ‘^’ to return to the parent directory in the same Dired buffer (see Visiting Files in Dired).

使用l命令 ( dired-do-redisplay) 更新子目录的内容,并使用C-u k子目录标题行删除子目录列表(请参阅更新 Dired 缓冲区)。您还可以隐藏和显示插入的子目录(请参阅隐藏子目录)。

Use the l command (dired-do-redisplay) to update the subdirectory’s contents, and use C-u k on the subdirectory header line to remove the subdirectory listing (see Updating the Dired Buffer). You can also hide and show inserted subdirectories (see Hiding Subdirectories).


31.13 Dired 中的子目录开关

31.13 Subdirectory Switches in Dired

您可以ls使用 Dired 缓冲区中插入带有指定开关的子目录C-u i。您可以ls 使用 更改已插入子目录的开关C-u l

You can insert subdirectories with specified ls switches in Dired buffers using C-u i. You can change the ls switches of an already inserted subdirectory at point using C-u l.

如果您恢复缓冲区,Dired 会保留开关。删除子目录会忘记它的开关。

Dired preserves the switches if you revert the buffer. Deleting a subdirectory forgets about its switches.

使用dired-undo (参见Dired 标记与标志)重新插入或删除使用显式开关插入的子目录可以绕过 Dired 记住(或忘记)开关的机制。使用删除子目录dired-undo不会忘记它的开关。当稍后使用 重新插入时i,它将使用其旧开关重新插入。使用dired-undo重新插入使用常规 Dired 命令(不是 )删除的子目录dired-undo最初将使用旧的开关插入它。但是,恢复缓冲区将使用缓冲区的默认开关重新列出它。如果其中任何一个产生问题,您可以使用C-u i或轻松纠正这种情况C-u l

Using dired-undo (see Dired Marks vs. Flags) to reinsert or delete subdirectories that were inserted with explicit switches can bypass Dired’s machinery for remembering (or forgetting) switches. Deleting a subdirectory using dired-undo does not forget its switches. When later reinserted using i, it will be reinserted using its old switches. Using dired-undo to reinsert a subdirectory that was deleted using the regular Dired commands (not dired-undo) will originally insert it with its old switches. Reverting the buffer, however, will relist it using the buffer’s default switches. If any of this yields problems, you can easily correct the situation using C-u i or C-u l.

Dired 不记得R开关。使用包含该R开关的开关插入子目录相当于使用所有剩余开关插入其每个子目录。例如,更新或终止使用开关插入的子目录R不会更新或终止其子目录。

Dired does not remember the R switch. Inserting a subdirectory with switches that include the R switch is equivalent to inserting each of its subdirectories using all remaining switches. For instance, updating or killing a subdirectory that was inserted with the R switch will not update or kill its subdirectories.

缓冲区的默认开关不会影响使用显式指定的开关插入的子目录。特别是,诸如s更改缓冲区开关之类的命令不会影响此类子目录。 (但是,它们确实会影响没有显式分配开关的子目录。)

The buffer’s default switches do not affect subdirectories that were inserted using explicitly specified switches. In particular, commands such as s that change the buffer’s switches do not affect such subdirectories. (They do, however, affect subdirectories without explicitly assigned switches.)

您可以使 Dired 忘记所有子目录开关,并使用缓冲区的默认开关重新列出所有子目录 M-x dired-reset-subdir-switches。这也会恢复 Dired 缓冲区。

You can make Dired forget about all subdirectory switches and relist all subdirectories with the buffer’s default switches using M-x dired-reset-subdir-switches. This also reverts the Dired buffer.


31.14 移动子目录

31.14 Moving Over Subdirectories

当 Dired 缓冲区列出子目录时,您可以使用页面移动命令C-x [并按C-x ]整个目录移动(请参阅Pages)。

When a Dired buffer lists subdirectories, you can use the page motion commands C-x [ and C-x ] to move by entire directories (see Pages).

以下命令在一个 Dired 缓冲区内的目录树中上下移动。它们移动到目录标题行,即在目录内容的开头给出目录名称的行。

The following commands move across, up and down in the tree of directories within one Dired buffer. They move to directory header lines, which are the lines that give a directory’s name, at the beginning of the directory’s contents.

C-M-n
C-M-n

转到下一个子目录标题行,无论级别如何 ( dired-next-subdir)。

Go to next subdirectory header line, regardless of level (dired-next-subdir).

C-M-p
C-M-p

转到上一个子目录标题行,无论级别如何 ( dired-prev-subdir)。

Go to previous subdirectory header line, regardless of level (dired-prev-subdir).

C-M-u
C-M-u

转到父目录的标题行 ( dired-tree-up)。

Go up to the parent directory’s header line (dired-tree-up).

C-M-d
C-M-d

在目录树中向下移动到第一个子目录的标题行 ( dired-tree-down)。

Go down in the directory tree, to the first subdirectory’s header line (dired-tree-down).

<
<

上移到上一个目录文件行 ( dired-prev-dirline)。这些行将目录描述为其父目录中的文件。

Move up to the previous directory-file line (dired-prev-dirline). These lines are the ones that describe a directory as a file in its parent directory.

>
>

向下移动到下一个目录文件行 ( dired-next-dirline)。

Move down to the next directory-file line (dired-next-dirline).

M-G
M-G

提示输入目录并移至其目录文件行 ( dired-goto-subdir)。

Prompt for a directory and move to its directory-file line (dired-goto-subdir).


31.15 隐藏子目录

31.15 Hiding Subdirectories

隐藏子目录意味着使其不可见,但标题行除外。

Hiding a subdirectory means to make it invisible, except for its header line.

$
$

隐藏或显示该点所在的子目录,并将点移动到下一个子目录(dired-hide-subdir)。这是一个切换。数字参数用作重复计数。

Hide or show the subdirectory that point is in, and move point to the next subdirectory (dired-hide-subdir). This is a toggle. A numeric argument serves as a repeat count.

M-$
M-$

隐藏此 Dired 缓冲区中的所有子目录,仅保留其标题行 ( dired-hide-all)。或者,如果当前隐藏任何子目录,则使所有子目录再次可见。您可以使用此命令来获取非常深的目录树的概览或快速移动到较远的子目录。

Hide all subdirectories in this Dired buffer, leaving only their header lines (dired-hide-all). Or, if any subdirectory is currently hidden, make all subdirectories visible again. You can use this command to get an overview in very deep directory trees or to move quickly to subdirectories far away.

普通 Dired 命令从不考虑隐藏子目录中的文件。例如,对标记文件进行操作的命令会忽略隐藏目录中的文件,即使它们已被标记。因此,您可以使用隐藏功能暂时从操作中排除子目录,而无需删除这些子目录中文件上的 Dired 标记。

Ordinary Dired commands never consider files inside a hidden subdirectory. For example, the commands to operate on marked files ignore files in hidden directories even if they are marked. Thus you can use hiding to temporarily exclude subdirectories from operations without having to remove the Dired marks on files in those subdirectories.

请参阅Dired 中的子目录,了解如何插入子目录列表,并参阅更新 Dired 缓冲区,了解如何删除它。

See Subdirectories in Dired, for how to insert a subdirectory listing, and see Updating the Dired Buffer, for how to delete it.


31.16 更新 Dired 缓冲区

31.16 Updating the Dired Buffer

本节介绍更新 Dired 缓冲区以反映目录和文件中的外部(非 Dired)更改以及删除部分 Dired 缓冲区的命令。

This section describes commands to update the Dired buffer to reflect outside (non-Dired) changes in the directories and files, and to delete part of the Dired buffer.

g
g

更新 Dired 缓冲区 ( revert-buffer) 的全部内容。

Update the entire contents of the Dired buffer (revert-buffer).

l
l

更新指定文件 ( dired-do-redisplay)。您指定文件的方式l与文件操作的方式相同。

Update the specified files (dired-do-redisplay). You specify the files for l in the same way as for file operations.

k
k

删除指定的文件行— 不是文件,只是行 ( dired-do-kill-lines)。

Delete the specified file lines—not the files, just the lines (dired-do-kill-lines).

s
s

在字母顺序和日期/时间顺序之间切换 ( dired-sort-toggle-or-edit)。

Toggle between alphabetical order and date/time order (dired-sort-toggle-or-edit).

C-u s switches RET
C-u s switches RET

使用 开关刷新 Dired 缓冲区: dired-listing-switches

Refresh the Dired buffer using switches as dired-listing-switches.

键入g( revert-buffer) 以根据列出的文件和目录中的更改来更新 Dired 缓冲区的内容。这将保留除已消失文件上的标记之外的所有标记。隐藏的子目录会更新,但仍保持隐藏状态。

Type g (revert-buffer) to update the contents of the Dired buffer, based on changes in the files and directories listed. This preserves all marks except for those on files that have vanished. Hidden subdirectories are updated but remain hidden.

要仅更新部分文件,请键入l ( dired-do-redisplay)。与 Dired 文件操作命令一样,此命令对接下来的n 个文件(或前n 个文件)、或标记的文件(如果有)或当前文件进行操作。更新文件意味着读取它们的当前状态,然后更新缓冲区中的行以指示该状态。

To update only some of the files, type l (dired-do-redisplay). Like the Dired file-operating commands, this command operates on the next n files (or previous −n files), or on the marked files if any, or on the current file. Updating the files means reading their current status, then updating their lines in the buffer to indicate that status.

如果在子目录标题行上使用l,它将更新相应子目录的内容。

If you use l on a subdirectory header line, it updates the contents of the corresponding subdirectory.

如果您使用C-x dDired 或其他一些命令来访问 Dired 缓冲区中已显示的目录,Dired 会切换到该缓冲区但不会更新它。如果缓冲区不是最新的,Dired 会显示一条警告,告诉您键入g以更新它。您还可以通过将变量设置 dired-auto-revert-buffer为非值来告诉 Emacs 在重新访问每个 Dired 缓冲区时自动恢复它nil

If you use C-x d or some other Dired command to visit a directory that is already being shown in a Dired buffer, Dired switches to that buffer but does not update it. If the buffer is not up-to-date, Dired displays a warning telling you to type g to update it. You can also tell Emacs to revert each Dired buffer automatically when you revisit it, by setting the variable dired-auto-revert-buffer to a non-nil value.

要从缓冲区中删除文件行k(而不实际删除文件),请键入( dired-do-kill-lines)。与文件操作命令一样,该命令对接下来的n 个 文件进行操作,或者对标记的文件(如果有)进行操作。但是,它不会对当前文件进行操作,否则输入错误k可能会很烦人。

To delete file lines from the buffer—without actually deleting the files—type k (dired-do-kill-lines). Like the file-operating commands, this command operates on the next n files, or on the marked files if any. However, it does not operate on the current file, since otherwise mistyping k could be annoying.

如果您使用k杀死作为子目录插入 Dired 缓冲区中的目录文件的行(请参阅Dired 中的子目录),它也会删除子目录列表。C-u k在子目录的标题行上 键入也会从 Dired 缓冲区中删除该子目录行。

If you use k to kill the line for a directory file which you had inserted in the Dired buffer as a subdirectory (see Subdirectories in Dired), it removes the subdirectory listing as well. Typing C-u k on the header line for a subdirectory also removes the subdirectory line from the Dired buffer.

g命令会带回您以这种方式杀死的任何单独的行,但不会带回子目录 - 您必须使用它i来重新插入子目录。

The g command brings back any individual lines that you have killed in this way, but not subdirectories—you must use i to reinsert a subdirectory.

Dired 缓冲区中的文件通常按文件名的字母顺序列出。或者 Dired 可以按日期/时间对它们进行排序。 Dired 命令s( dired-sort-toggle-or-edit) 在这两种排序模式之间切换。 Dired 缓冲区中的模式行指示当前的排序方式 - 按名称或按日期。

The files in a Dired buffers are normally listed in alphabetical order by file names. Alternatively Dired can sort them by date/time. The Dired command s (dired-sort-toggle-or-edit) switches between these two sorting modes. The mode line in a Dired buffer indicates which way it is currently sorted—by name, or by date.

C-u s switches RET让您为 指定一个新值 dired-listing-switches

C-u s switches RET lets you specify a new value for dired-listing-switches.


31.17 指令和find

31.17 Dired and find

find通过使用文件选择实用程序, 您可以更灵活地选择一组文件以在 Dired 缓冲区中显示。

You can select a set of files for display in a Dired buffer more flexibly by using the find utility to choose the files.

要搜索名称与通配符模式匹配的文件,请使用 M-x find-name-dired。它读取参数目录模式,并选择目录或其子目录中名称与模式匹配的所有文件。

To search for files with names matching a wildcard pattern use M-x find-name-dired. It reads arguments directory and pattern, and chooses all the files in directory or its subdirectories whose individual names match pattern.

这样选择的文件将显示在 Dired 缓冲区中,其中可以使用普通的 Dired 命令。

The files thus chosen are displayed in a Dired buffer, in which the ordinary Dired commands are available.

如果您想测试文件的内容而不是其名称,请使用M-x find-grep-dired.该命令读取两个迷你缓冲区参数:directoryregexp;它选择目录或其子目录中包含regexp匹配项的 所有文件。它通过运行程序find和 来工作grep。另请参阅M-x grep-findEmacs 下使用 Grep 进行搜索。请记住为 编写正则表达式 grep,而不是为 Emacs 编写。 (显示内容与给定正则表达式匹配的文件的另一种方法是命令,请参阅Dired Marks 与 Flags。) % g regexp

If you want to test the contents of files, rather than their names, use M-x find-grep-dired. This command reads two minibuffer arguments, directory and regexp; it chooses all the files in directory or its subdirectories that contain a match for regexp. It works by running the programs find and grep. See also M-x grep-find, in Searching with Grep under Emacs. Remember to write the regular expression for grep, not for Emacs. (An alternative method of showing files whose contents match a given regexp is the % g regexp command, see Dired Marks vs. Flags.)

本系列中最通用的命令是M-x find-dired,它允许您指定find可以测试的任何条件。它需要两个迷你缓冲区参数,directoryfind-args;它在目录find中运行,传递find-args来告诉要测试的条件。要使用此命令,您需要知道如何使用. findfind

The most general command in this series is M-x find-dired, which lets you specify any condition that find can test. It takes two minibuffer arguments, directory and find-args; it runs find in directory, passing find-args to tell find what condition to test. To use this command, you need to know how to use find.

这些命令生成的列表的格式由变量控制find-ls-option。这是一对选项;第一个指定如何调用find来生成文件列表,第二个告诉 Dired 解析输出。

The format of listing produced by these commands is controlled by the variable find-ls-option. This is a pair of options; the first specifying how to call find to produce the file listing, and the second telling Dired to parse the output.

该命令M-x locate为程序提供了类似的界面 locateM-x locate-with-filter类似,但仅保留名称与给定正则表达式匹配的文件。

The command M-x locate provides a similar interface to the locate program. M-x locate-with-filter is similar, but keeps only files whose names match a given regular expression.

这些缓冲区的工作方式并不完全像普通的 Dired 缓冲区:文件操作可以工作,但并不总是自动更新缓冲区。恢复缓冲区会g删除所有插入的子目录,并删除所有标志和标记。

These buffers don’t work entirely like ordinary Dired buffers: file operations work, but do not always automatically update the buffer. Reverting the buffer with g deletes all inserted subdirectories, and erases all flags and marks.


31.18 编辑定向缓冲区

31.18 Editing the Dired Buffer

Wdired 是一种特殊模式,允许您通过直接编辑 Dired 缓冲区来执行文件操作(“Wdired”中的“W”代表“可写”)。要进入 Wdired 模式,请在 Dired 缓冲区中键入C-x C-q ( )。dired-toggle-read-only或者,使用 '立即/编辑文件名' 菜单项。

Wdired is a special mode that allows you to perform file operations by editing the Dired buffer directly (the “W” in “Wdired” stands for “writable”). To enter Wdired mode, type C-x C-q (dired-toggle-read-only) while in a Dired buffer. Alternatively, use the ‘Immediate / Edit File Names’ menu item.

在 Wdired 模式下,您可以通过编辑 Dired 缓冲区中显示的文件名来重命名文件。所有普通的 Emacs 编辑命令,包括矩形操作 和query-replace,都可用于此。完成编辑后,输入C-c C-c ( wdired-finish-edit)。这将应用您的更改并切换回普通 Dired 模式。

While in Wdired mode, you can rename files by editing the file names displayed in the Dired buffer. All the ordinary Emacs editing commands, including rectangle operations and query-replace, are available for this. Once you are done editing, type C-c C-c (wdired-finish-edit). This applies your changes and switches back to ordinary Dired mode.

除了简单地重命名文件之外,您还可以通过键入新文件名(绝对或相对)将文件移动到另一个目录。要将文件标记为删除,请删除整个文件名。要更改符号链接的目标,请编辑链接名称旁边显示的链接目标名称。

Apart from simply renaming files, you can move a file to another directory by typing in the new file name (either absolute or relative). To mark a file for deletion, delete the entire file name. To change the target of a symbolic link, edit the link target name which appears next to the link name.

如果您编辑文件名来创建新的子目录,Wdired 将自动创建这些新目录。要抑制此行为,请设置wdired-create-parent-directoriesnil

If you edit the file names to create a new subdirectory, Wdired will automatically create these new directories. To inhibit this behavior, set wdired-create-parent-directories to nil.

缓冲区中的其余文本(例如文件大小和修改日期)被标记为只读,因此您无法对其进行编辑。但是,如果设置wdired-allow-to-change-permissionst,则可以编辑文件权限。例如,您可以更改 '-rw-r--r--' 到 '-RW-RW-RW-' 使文件全局可写。这些更改也会在您键入时生效C-c C-c

The rest of the text in the buffer, such as the file sizes and modification dates, is marked read-only, so you can’t edit it. However, if you set wdired-allow-to-change-permissions to t, you can edit the file permissions. For example, you can change ‘-rw-r--r--’ to ‘-rw-rw-rw-’ to make a file world-writable. These changes also take effect when you type C-c C-c.


31.19 在 Dired 中查看图像缩略图

31.19 Viewing Image Thumbnails in Dired

Image-Dired 是浏览图像文件的工具。它提供了在 Emacs 内或通过外部查看器以缩略图或全尺寸形式查看图像的功能。这与访问 Emacs 缓冲区中的图像文件的 图像模式(请参阅查看图像文件)不同。

Image-Dired is a facility for browsing image files. It provides viewing the images either as thumbnails or in full size, either inside Emacs or through an external viewer. This is different from Image mode (see Viewing Image Files) for visiting an image file in the Emacs buffer.

m要进入 Image-Dired,请像往常一样使用 Dired 缓冲区中标记要查看的图像文件。然后输入C-t d ( image-dired-display-thumbs)。这将创建并切换到包含 Image-Dired 的缓冲区,对应于标记的文件。

To enter Image-Dired, mark the image files you want to look at in the Dired buffer, using m as usual. Then type C-t d (image-dired-display-thumbs). This creates and switches to a buffer containing Image-Dired, corresponding to the marked files.

您也可以直接输入 Image-Dired M-x image-dired。这会提示输入一个目录;指定具有图像文件的一个。这会为该目录中的所有图像创建缩略图,并将它们全部显示在缩略图缓冲区中。缩略图在后台生成,并在可用时加载。

You can also enter Image-Dired directly by typing M-x image-dired. This prompts for a directory; specify one that has image files. This creates thumbnails for all the images in that directory, and displays them all in the thumbnail buffer. The thumbnails are generated in the background and are loaded as they become available.

通过在缩略图缓冲区中点,您可以键入RET ( image-dired-display-this) 以在另一个窗口中显示图像。使用标准 Emacs 移动键绑定或箭头键在缩略图缓冲区中移动。为了方便浏览,请使用 SPC( image-dired-display-next) 前进并显示下一个图像。键入DEL( image-dired-display-previous) 将备份到上一个缩略图并显示该缩略图。

With point in the thumbnail buffer, you can type RET (image-dired-display-this) to display the image in another window. Use the standard Emacs movement key bindings or the arrow keys to move around in the thumbnail buffer. For easy browsing, use SPC (image-dired-display-next) to advance and display the next image. Typing DEL (image-dired-display-previous) backs up to the previous thumbnail and displays that instead.

键入 ( ) 以在外部查看器中显示图像。您必须首先配置 . C-RETimage-dired-thumbnail-display-externalimage-dired-external-viewer

Type C-RET (image-dired-thumbnail-display-external) to display the image in an external viewer. You must first configure image-dired-external-viewer.

您也可以通过 Image-Dired 删除图像。键入d ( image-dired-flag-thumb-original-file) 以标记要在 Dired 缓冲区中删除的图像文件。或者,您可以通过键入C-d( )从缩略图缓冲区中删除图像的缩略图,而不将图像标记为删除image-dired-delete-char

You can delete images through Image-Dired also. Type d (image-dired-flag-thumb-original-file) to flag the image file for deletion in the Dired buffer. Alternatively, you can remove an image’s thumbnail from the thumbnail buffer without flagging the image for deletion, by typing C-d (image-dired-delete-char).

您还可以使用 Image-Dired 进行“内联”操作(即直接进入 Dired 缓冲区)。键入C-t C-t,Dired 中所选图像的缩略图将出现在其名称前面 ( image-dired-dired-toggle-marked-thumbs)。 C-t i并将 C-t x分别在 Emacs 或外部查看器中显示该点下的图像。

You could also use Image-Dired for “inline” operations (i.e., right into the Dired buffer). Type C-t C-t, and the thumbnails of the selected images in Dired will appear in front of their names (image-dired-dired-toggle-marked-thumbs). C-t i and C-t x will display the image under the point in Emacs or with the external viewer, respectively.

更高级的功能包括图像标签,它们是用于对图像文件进行分类的元数据。标签存储在由 .config 配置的纯文本文件中image-dired-tags-db-file

More advanced features include image tags, which are metadata used to categorize image files. The tags are stored in a plain text file configured by image-dired-tags-db-file.

要标记图像文件,请在 Dired 缓冲区中标记它们(您也可以通过键入 来标记 Dired 中缩略图缓冲区中的文件m)并键入 C-t t( image-dired-tag-files)。这会读取迷你缓冲区中的标签名称。要标记具有特定标签的文件,请键入C-t f ( image-dired-mark-tagged-files)。将图像文件标记为特定标签后,您可以使用C-t d它来查看它们。

To tag image files, mark them in the Dired buffer (you can also mark files in Dired from the thumbnail buffer by typing m) and type C-t t (image-dired-tag-files). This reads the tag name in the minibuffer. To mark files having a certain tag, type C-t f (image-dired-mark-tagged-files). After marking image files with a certain tag, you can use C-t d to view them.

您还可以通过键入直接从缩略图缓冲区中标记文件 t t,并且可以通过键入删除标记t r。每个文件还有一个名为“comment”的特殊标签(它与其他标签的意义并不完全相同,处理方式略有不同)。用于输入有关图像的评论或描述。您可以通过键入 来注释缩略图缓冲区中的文件 c。系统将提示您发表评论。键入C-t c以添加来自 Dired ( ) 的评论image-dired-dired-comment-filesC-t e会带来一个缓冲区来编辑评论和标签(image-dired-dired-edit-comment-and-tags)。

You can also tag a file directly from the thumbnail buffer by typing t t, and you can remove a tag by typing t r. There is also a special tag called “comment” for each file (it is not a tag in the exact same sense as the other tags, it is handled slightly differently). That is used to enter a comment or description about the image. You comment a file from the thumbnail buffer by typing c. You will be prompted for a comment. Type C-t c to add a comment from Dired (image-dired-dired-comment-files). C-t e will bring a buffer to edit comment and tags (image-dired-dired-edit-comment-and-tags).

image-dired-thumb-visible-marks如果为非nil(默认), 则在 Dired 中标记的文件也将在 Image-Dired 中标记 。

Files that are marked in Dired will also be marked in Image-Dired if image-dired-thumb-visible-marks is non-nil (which is the default).

Image-Dired 还提供简单的图像操作。在缩略图缓冲区中,键入L将原始图像逆时针旋转 90 度,然后R将其顺时针旋转 90 度。此旋转是无损的,并使用名为 的外部实用程序 jpegtran,您需要先安装该实用程序。

Image-Dired also provides simple image manipulation. In the thumbnail buffer, type L to rotate the original image 90 degrees anti clockwise, and R to rotate it 90 degrees clockwise. This rotation is lossless, and uses an external utility called jpegtran, which you need to install first.


31.20 其他令人讨厌的功能

31.20 Other Dired Features

默认情况下,Dired 在目录列表的第一行、目录名称后面显示目录磁盘上的可用空间。您可以通过自定义变量来控制此显示dired-free-space。它的默认值为first,这会在目录名称后生成可用空间。如果您将其自定义为该值separate,Dired 将在单独的行上显示磁盘空间信息,该行位于目录名称行之后,并将在该行中包含当前目录中的文件使用的空间以及可用的空间。磁盘空间。如果将此设置为nil,则根本不会显示可用磁盘空间信息。

By default, Dired displays the available space on the directory’s disk on the first line of that directory’s listing, following the directory name. You can control this display by customizing the variable dired-free-space. Its default value is first, which produces the available space after the directory name. If you customize it to the value separate instead, Dired will display the disk space information on a separate line, following the line with the directory name, and will include in that line the space used by the files in the current directory as well as the available disk space. If you set this to nil, the available disk space information will not be displayed at all.

命令+( dired-create-directory) 读取目录的名称并创建该目录。如果该目录已存在,则会发出错误信号。

The command + (dired-create-directory) reads a directory’s name, and creates that directory. It signals an error if the directory already exists.

命令 ( dired-create-empty-file) 读取文件名并创建该文件。如果文件已存在,则会发出错误信号。

The command (dired-create-empty-file) reads a file name, and creates that file. It signals an error if the file already exists.

命令M-s a C-s( dired-do-isearch) 开始对标记的文件进行多文件增量搜索。如果搜索在文件末尾失败,则键入C-s前进到下一个标记的文件并重复搜索;在最后一个标记文件的末尾,搜索将回绕到第一个标记文件。命令 M-s a M-C-s( dired-do-isearch-regexp) 对正则表达式搜索执行相同的操作。有关搜索重复的信息, 请参阅重复增量搜索。

The command M-s a C-s (dired-do-isearch) begins a multi-file incremental search on the marked files. If a search fails at the end of a file, typing C-s advances to the next marked file and repeats the search; at the end of the last marked file, the search wraps around to the first marked file. The command M-s a M-C-s (dired-do-isearch-regexp) does the same with a regular expression search. See Repeating Incremental Search, for information about search repetition.

命令w( ) 将标记的(或接下来的n 个dired-copy-filename-as-kill)文件的名称放入终止环中,就像您使用 杀死了它们一样。名称之间用空格分隔。 C-w

The command w (dired-copy-filename-as-kill) puts the names of the marked (or next n) files into the kill ring, as if you had killed them with C-w. The names are separated by a space.

如果使用零前缀参数,则使用每个标记文件的绝对文件名。与C-u前缀参数一样,它使用相对于 Dired 缓冲区默认目录的文件名。 (如果在子目录中,它仍然可以包含斜杠。)作为特殊情况,如果点位于目录标题行上,w则为您提供该目录的绝对名称。在这种情况下,任何前缀参数或标记的文件都将被忽略。

With a zero prefix argument, this uses the absolute file name of each marked file. With just C-u as the prefix argument, it uses file names relative to the Dired buffer’s default directory. (This can still contain slashes if in a subdirectory.) As a special case, if point is on a directory header line, w gives you the absolute name of that directory. Any prefix argument or marked files are ignored in this case.

该命令的主要目的是让您可以将文件名拉入其他 Emacs 命令的参数中。它还显示添加到 Kill Ring 的内容,因此您可以使用它在回显区域显示当前标记的文件列表。

The main purpose of this command is so that you can yank the file names into arguments for other Emacs commands. It also displays what it added to the kill ring, so you can use it to display the list of currently marked files in the echo area.

如果文件列表中有 HTML 文件,则使用浏览器查看该文件会很有用。W ( )命令browse-url-of-dired-file将使用标准配置的浏览器来查看该文件。

If you have an HTML file in the file listing, it can be useful to view that file with a browser. The W (browse-url-of-dired-file) command will use the standard configured browser to view that file.

命令(( dired-hide-details-mode) 切换详细信息(例如所有权或文件权限)在当前 Dired 缓冲区中是否可见。默认情况下,它还隐藏符号链接的目标以及除标题行和文件/目录列表之外的所有行。要更改此设置,请分别自定义选项 dired-hide-details-hide-symlink-targetsdired-hide-details-hide-information-lines

The command ( (dired-hide-details-mode) toggles whether details, such as ownership or file permissions, are visible in the current Dired buffer. By default, it also hides the targets of symbolic links, and all lines other than the header line and file/directory listings. To change this, customize the options dired-hide-details-hide-symlink-targets and dired-hide-details-hide-information-lines, respectively.

如果您正在访问的目录受版本控制(请参阅版本控制),则正常的 VC diff 和 log 命令将在选定的文件上运行。

If the directory you are visiting is under version control (see Version Control), then the normal VC diff and log commands will operate on the selected files.

该命令M-x dired-compare-directories用于将当前 Dired 缓冲区与另一个目录进行比较。它标记两个目录之间所有不同的文件。它将这些标记放在列出这些文件的所有 Dired 缓冲区中,其中当然包括当前缓冲区。

The command M-x dired-compare-directories is used to compare the current Dired buffer with another directory. It marks all the files that differ between the two directories. It puts these marks in all Dired buffers where these files are listed, which of course includes the current buffer.

默认的比较方法(如果RET在提示符下键入则使用)是仅比较文件名 - 如果文件名未出现在其他目录中,则文件名会有所不同。您可以通过输入 Lisp 表达式来指定更严格的比较,该表达式可以引用变量size1size2,即各自的文件大小;mtime1mtime2,最后一次修改时间(以秒为单位),为浮点数;和fa1fa2各自的文件属性列表(由函数 返回file-attributes)。针对每对名称相似的文件计算此表达式,如果表达式的值不是 - ,则文件会有所不同nil

The default comparison method (used if you type RET at the prompt) is to compare just the file names—file names differ if they do not appear in the other directory. You can specify more stringent comparisons by entering a Lisp expression, which can refer to the variables size1 and size2, the respective file sizes; mtime1 and mtime2, the last modification times in seconds, as floating point numbers; and fa1 and fa2, the respective file attribute lists (as returned by the function file-attributes). This expression is evaluated for each pair of like-named files, and files differ if the expression’s value is non-nil.

例如,该序列将该目录中的文件标记为比另一目录中的文件新,并将另一目录中的文件标记为比该目录中的文件旧。它还一如既往地在两个目录中标记没有对应项的文件。 M-x dired-compare-directories RET (> mtime1 mtime2) RET

For instance, the sequence M-x dired-compare-directories RET (> mtime1 mtime2) RET marks files newer in this directory than in the other, and marks files older in the other directory than in this one. It also marks files with no counterpart, in both directories, as always.

在 X Window 系统上,Emacs 支持拖放协议。您可以将文件对象从另一个程序中拖放到 Dired 缓冲区中;这会移动、复制或创建指向该目录中文件的链接。具体采取哪种操作由原始程序决定。还支持将文件拖出 Dired 缓冲区,通过启用用户选项dired-mouse-drag-files,可以使用鼠标将文件拖到其他程序上。当设置为 时 link,它将使其他程序(通常是文件管理器)创建到该文件的符号链接;当设置为 时move,它将使其他程序将文件移动到新位置,并将其设置为任何其他非值nil将使其他程序打开或创建文件的副本。在拖放操作期间按下的键盘修饰符还可以控制其他程序对文件采取的操作。

On the X Window System, Emacs supports the drag and drop protocol. You can drag a file object from another program, and drop it onto a Dired buffer; this either moves, copies, or creates a link to the file in that directory. Precisely which action is taken is determined by the originating program. Dragging files out of a Dired buffer is also supported, by enabling the user option dired-mouse-drag-files, the mouse can be used to drag files onto other programs. When set to link, it will make the other program (typically a file manager) create a symbolic link to the file; when set to move, it will make the other program move the file to a new location, and setting it to any other non-nil value will make the other program open or create a copy of the file. The keyboard modifiers pressed during the drag-and-drop operation can also control what action the other program takes towards the file.


32 日历和日记

32 The Calendar and the Diary

Emacs 提供台历的功能,包括计划的或过去的事件的日记。它还具有管理约会的功能,并跟踪您在某些项目上花费的时间。

Emacs provides the functions of a desk calendar, with a diary of planned or past events. It also has facilities for managing your appointments, and keeping track of how much time you spend working on certain projects.

要输入日历,请键入M-x calendar。这将显示以当前月份为中心、点位于当前日期的三个月日历。使用数字参数(如 中)C-u M-x calendar,它会提示您将月份和年份作为三个月日历的中心。日历使用自己的缓冲区,其主要模式是日历模式。

To enter the calendar, type M-x calendar. This displays a three-month calendar centered on the current month, with point on the current date. With a numeric argument, as in C-u M-x calendar, it prompts you for the month and year to be the center of the three-month calendar. The calendar uses its own buffer, whose major mode is Calendar mode.

mouse-3在日历中调出特定日期的操作菜单;mouse-2弹出一个独立于任何特定日期的常用日历功能菜单。要退出日历,请键入q

mouse-3 in the calendar brings up a menu of operations on a particular date; mouse-2 brings up a menu of commonly used calendar features that are independent of any particular date. To exit the calendar, type q.


32.1 日历中的运动

32.1 Movement in the Calendar

日历模式提供了以逻辑时间单位(例如天、周、月和年)浏览日历的命令。如果超出最初显示的三个月,日历显示会自动滚动时间以使所选日期可见。移动到某个日期可以让您查看其假期或日记条目,或将其转换为其他日历;只需滚动日历即可移动较长的时间段。

Calendar mode provides commands to move through the calendar in logical units of time such as days, weeks, months, and years. If you move outside the three months originally displayed, the calendar display scrolls automatically through time to make the selected date visible. Moving to a date lets you view its holidays or diary entries, or convert it to other calendars; moving by long time periods is also useful simply to scroll the calendar.


32.1.1 标准时间长度的运动

32.1.1 Motion by Standard Lengths of Time

日历缓冲区中的移动命令与文本中的移动命令并行。您可以向前或向后移动几天、几周、几个月和几年。

The commands for movement in the calendar buffer parallel the commands for movement in text. You can move forward and backward by days, weeks, months, and years.

C-f
C-f

将点向前移动一天 ( calendar-forward-day)。

Move point one day forward (calendar-forward-day).

C-b
C-b

将点向后移动一天 ( calendar-backward-day)。

Move point one day backward (calendar-backward-day).

C-n
C-n

将点向前移动一周 ( calendar-forward-week)。

Move point one week forward (calendar-forward-week).

C-p
C-p

将点向后移动一周 ( calendar-backward-week)。

Move point one week backward (calendar-backward-week).

M-}
M-}

将点向前移动一个月 ( calendar-forward-month)。

Move point one month forward (calendar-forward-month).

M-{
M-{

将点向后移动一个月(calendar-backward-month)。

Move point one month backward (calendar-backward-month).

C-x ]
C-x ]

将点向前移动一年 ( calendar-forward-year)。

Move point one year forward (calendar-forward-year).

C-x [
C-x [

将点向后移动一年 ( calendar-backward-year)。

Move point one year backward (calendar-backward-year).

日和周命令与常用的按字符和按行移动的 Emacs 命令自然类似。正如C-n 通常移动到下一行中的同一列一样,在日历模式下,它会移动到下周的同一天。并C-p 移至上周的同一天。

The day and week commands are natural analogues of the usual Emacs commands for moving by characters and by lines. Just as C-n usually moves to the same column in the following line, in Calendar mode it moves to the same day in the following week. And C-p moves to the same day in the previous week.

箭头键相当于C-fC-bC-nC-p,就像它们在其他模式下通常的作用一样。

The arrow keys are equivalent to C-f, C-b, C-n and C-p, just as they normally are in other modes.

数月和数年的运动命令与数周的运动命令类似,但移动的距离更大。月份命令M-}M-{向前或向后移动一整月。年份命令C-x ]C-x [向前或向后移动一整年。

The commands for motion by months and years work like those for weeks, but move a larger distance. The month commands M-} and M-{ move forward or backward by an entire month. The year commands C-x ] and C-x [ move forward or backward a whole year.

记住这些命令的最简单方法是分别考虑类似于文本段落和页面的月份和年份。但是日历移动命令本身与通过文本移动的命令不太相似:普通的 Emacs 段落命令移动到段落的开头或结尾,而这些月份和年份命令移动整个月或整年,保持相同月份或年份内的日期。

The easiest way to remember these commands is to consider months and years analogous to paragraphs and pages of text, respectively. But the calendar movement commands themselves do not quite parallel those for movement through text: the ordinary Emacs paragraph commands move to the beginning or end of a paragraph, whereas these month and year commands move by an entire month or an entire year, keeping the same date within the month or year.

所有这些命令都接受数字参数作为重复计数。为了方便起见,即使没有 Meta 修饰符,数字键和减号也可以在日历模式下指定数字参数。例如, 100 C-f将点从当前位置向前移动 100 天。

All these commands accept a numeric argument as a repeat count. For convenience, the digit keys and the minus sign specify numeric arguments in Calendar mode even without the Meta modifier. For example, 100 C-f moves point 100 days forward from its present location.


32.1.2 周、月或年的开始或结束

32.1.2 Beginning or End of Week, Month or Year

一周(或月或年)不仅仅是天数;它还包括天数。我们认为几周(几个月,几年)是从特定日期开始的。因此,日历模式提供了移动到一周、一个月或一年的开始或结束的命令:

A week (or month, or year) is not just a quantity of days; we think of weeks (months, years) as starting on particular dates. So Calendar mode provides commands to move to the start or end of a week, month or year:

C-a
C-a

将点移动到周的开始 ( calendar-beginning-of-week)。

Move point to start of week (calendar-beginning-of-week).

C-e
C-e

将点移至周末 ( calendar-end-of-week)。

Move point to end of week (calendar-end-of-week).

M-a
M-a

将点移至月初 ( calendar-beginning-of-month)。

Move point to start of month (calendar-beginning-of-month).

M-e
M-e

将点移至月末 ( calendar-end-of-month)。

Move point to end of month (calendar-end-of-month).

M-<
M-<

将点移至年初 ( calendar-beginning-of-year)。

Move point to start of year (calendar-beginning-of-year).

M->
M->

将点移至年末 ( calendar-end-of-year)。

Move point to end of year (calendar-end-of-year).

这些命令还采用数字参数作为重复计数,重复计数指示向后或向前移动多少周、几个月或几年。

These commands also take numeric arguments as repeat counts, with the repeat count indicating how many weeks, months, or years to move backward or forward.

默认情况下,每周从星期日开始。要使它们从星期一开始,请将变量设置calendar-week-start-day为 1。要更改突出显示为周末的日期标题,请设置变量calendar-weekend-days

By default, weeks begin on Sunday. To make them begin on Monday instead, set the variable calendar-week-start-day to 1. To change which day headers are highlighted as weekend days, set the variable calendar-weekend-days.


32.1.3 指定日期

32.1.3 Specified Dates

日历模式提供了用于移动到以各种方式指定的特定日期的命令。

Calendar mode provides commands for moving to a particular date specified in various ways.

g d
g d

将点移至指定日期 ( calendar-goto-date)。

Move point to specified date (calendar-goto-date).

g D
g D

将点移动到一年中的指定日期 ( calendar-goto-day-of-year)。

Move point to specified day of year (calendar-goto-day-of-year).

g w
g w

将点移动到一年中的指定周 ( calendar-iso-goto-week)。

Move point to specified week of year (calendar-iso-goto-week).

o
o

以指定月份 ( calendar-other-month) 为中心的日历。

Center calendar around specified month (calendar-other-month).

.
.

将点移至今天的日期 ( calendar-goto-today)。

Move point to today’s date (calendar-goto-today).

g d( calendar-goto-date) 提示输入年、月和该月中的某一天,然后移至该日期。由于日历包含从当前纪元开始的所有日期,因此您必须完整键入年份;也就是说,输入 '2010年', 不是 '10'。

g d (calendar-goto-date) prompts for a year, a month, and a day of the month, and then moves to that date. Because the calendar includes all dates from the beginning of the current era, you must type the year in its entirety; that is, type ‘2010’, not ‘10’.

g D( calendar-goto-day-of-year) 提示输入年份和日期数字,并移至该日期。负日数从年底开始倒数。 g w ( calendar-iso-goto-week) 提示输入年份和周数,并移至该周。

g D (calendar-goto-day-of-year) prompts for a year and day number, and moves to that date. Negative day numbers count backward from the end of the year. g w (calendar-iso-goto-week) prompts for a year and week number, and moves to that week.

o( calendar-other-month) 提示输入月份和年份,然后将三个月的日历以该月为中心。

o (calendar-other-month) prompts for a month and year, then centers the three-month calendar around that month.

. 您可以使用( )返回到今天的日期calendar-goto-today

You can return to today’s date with . (calendar-goto-today).


32.2 滚动日历

32.2 Scrolling in the Calendar

当您移出可见部分时,日历显示会自动滚动时间。您也可以手动滚动它。想象一下日历窗口包含一条长纸条,上面有月份。滚动日历意味着水平移动条带,以便新的月份在窗口中可见。

The calendar display scrolls automatically through time when you move out of the visible portion. You can also scroll it manually. Imagine that the calendar window contains a long strip of paper with the months on it. Scrolling the calendar means moving the strip horizontally, so that new months become visible in the window.

>
>

将日历向前滚动一个月 ( calendar-scroll-left)。

Scroll calendar one month forward (calendar-scroll-left).

<
<

将日历向后滚动一个月 ( calendar-scroll-right)。

Scroll calendar one month backward (calendar-scroll-right).

C-v
C-v
PageDown
PageDown
next
next

向前滚动三个月 ( calendar-scroll-left-three-months)。

Scroll forward by three months (calendar-scroll-left-three-months).

M-v
M-v
PageUp
PageUp
prior
prior

向后滚动三个月 ( calendar-scroll-right-three-months)。

Scroll backward by three months (calendar-scroll-right-three-months).

最基本的日历滚动命令一次滚动一个月。这意味着命令之前的显示和命令之后的显示之间有两个月的重叠。 >将日历内容向前滚动一个月。 <将内容向后滚动一个月。

The most basic calendar scroll commands scroll by one month at a time. This means that there are two months of overlap between the display before the command and the display after. > scrolls the calendar contents one month forward in time. < scrolls the contents one month backwards in time.

这些命令C-vM-v日历滚动一整屏(三个月),与这些命令的通常含义类似。 C-v使较晚的日期可见并使M-v较早的日期可见。这些命令采用数字参数作为重复计数;特别是,由于C-u将下一个命令乘以四,因此键入C-u C-v会将日历向前滚动一年,键入C-u M-v会将日历向后滚动一年。

The commands C-v and M-v scroll the calendar by an entire screenful—three months—in analogy with the usual meaning of these commands. C-v makes later dates visible and M-v makes earlier dates visible. These commands take a numeric argument as a repeat count; in particular, since C-u multiplies the next command by four, typing C-u C-v scrolls the calendar forward by a year and typing C-u M-v scrolls the calendar backward by a year.

功能键PageDown(或next)和PageUp (或prior)与C-v和等效M-v,就像在其他模式下一样。

The function keys PageDown (or next) and PageUp (or prior) are equivalent to C-v and M-v, just as they are in other modes.


32.3 计算天数

32.3 Counting Days

M-=
M-=

显示当前区域的天数 ( calendar-count-days-region)。

Display the number of days in the current region (calendar-count-days-region).

要确定某个范围内的天数,请使用 在一个日期上设置标记,将点移至另一日期,然后键入 ( )。显示的天数包括 在内;也就是说,它包括标记和点指定的日期。 C-SPCM-=calendar-count-days-region

To determine the number of days in a range, set the mark on one date using C-SPC, move point to another date, and type M-= (calendar-count-days-region). The numbers of days shown is inclusive; that is, it includes the days specified by mark and point.


32.4 其他日历命令

32.4 Miscellaneous Calendar Commands

p d
p d

显示一年中的某天 ( calendar-print-day-of-year)。

Display day-in-year (calendar-print-day-of-year).

C-c C-l
C-c C-l

重新生成日历窗口 ( calendar-redraw)。

Regenerate the calendar window (calendar-redraw).

SPC
SPC

向上滚动下一个窗口 ( scroll-other-window)。

Scroll the next window up (scroll-other-window).

DEL
DEL
S-SPC
S-SPC

向下滚动下一个窗口 ( scroll-other-window-down)。

Scroll the next window down (scroll-other-window-down).

q
q

退出日历 ( calendar-exit)。

Exit from calendar (calendar-exit).

要显示自年初以来经过的天数或该年剩余的天数,请键入命令p d( calendar-print-day-of-year)。这将在回显区域中显示这两个数字。已过去的天数包括所选日期。剩余天数不包括该日期。

To display the number of days elapsed since the start of the year, or the number of days remaining in the year, type the p d command (calendar-print-day-of-year). This displays both of those numbers in the echo area. The count of days elapsed includes the selected date. The count of days remaining does not include that date.

如果日历窗口文本损坏,请键入C-c C-l ( calendar-redraw) 重新绘制它。 (只有当您使用非日历模式编辑命令时才会发生这种情况。)

If the calendar window text gets corrupted, type C-c C-l (calendar-redraw) to redraw it. (This can only happen if you use non-Calendar-mode editing commands.)

在日历模式下,您可以使用SPC( scroll-other-window) 和DEL( scroll-other-window-down) 分别向上或向下滚动另一个窗口(如果有)。当您在另一个窗口中显示假期列表或日记条目时,这非常方便。

In Calendar mode, you can use SPC (scroll-other-window) and DEL (scroll-other-window-down) to scroll the other window (if there is one) up or down, respectively. This is handy when you display a list of holidays or diary entries in another window.

要退出日历,请键入q( calendar-exit)。这会隐藏与日历相关的所有缓冲区,并选择其他缓冲区。 (如果框架包含专用日历窗口,则退出日历会根据 的值删除或图标化该框架 calendar-remove-frame-by-deleting。)

To exit from the calendar, type q (calendar-exit). This buries all buffers related to the calendar, selecting other buffers. (If a frame contains a dedicated calendar window, exiting from the calendar deletes or iconifies that frame depending on the value of calendar-remove-frame-by-deleting.)


32.5 写入日历文件

32.5 Writing Calendar Files

您可以将日历和日记条目写入 HTML 和 LaTeX 文件。

You can write calendars and diary entries to HTML and LaTeX files.

日历 HTML 命令生成包含日历、假日和日记条目的 HTML 代码文件。每个文件适用一个月,并有一个格式的名称yyyy -毫米.html,其中 yyyymm分别是四位数的年份和两位数的月份。该变量cal-html-directory指定 HTML 文件的默认输出目录。要防止显示假期,请自定义cal-html-holidays.

The Calendar HTML commands produce files of HTML code that contain calendar, holiday, and diary entries. Each file applies to one month, and has a name of the format yyyy-mm.html, where yyyy and mm are the four-digit year and two-digit month, respectively. The variable cal-html-directory specifies the default output directory for the HTML files. To prevent holidays from being shown, customize cal-html-holidays.

<由和包围的日记条目>被解释为 HTML 标签(例如:这是一个带有 <font color=”red”>一些红色文本</font>的日记条目)。您可以通过样式表更改显示的 HTML 页面的整体外观(例如,各种页面元素的颜色、标题样式)卡尔.CSS在包含 HTML 文件的目录中( cal-html-css-default有关相关样式设置,请参阅变量的值)。

Diary entries enclosed by < and > are interpreted as HTML tags (for example: this is a diary entry with <font color=”red”>some red text</font>). You can change the overall appearance of the displayed HTML pages (for example, the color of various page elements, header styles) via a stylesheet cal.css in the directory containing the HTML files (see the value of the variable cal-html-css-default for relevant style settings).

H m
H m

生成一个月日历 ( cal-html-cursor-month)。

Generate a one-month calendar (cal-html-cursor-month).

H y
H y

生成一年中每个月的日历文件以及索引页 ( cal-html-cursor-year)。默认情况下,此命令将文件写入yyyy子目录 - 如果更改此设置,年份之间的某些超链接将不起作用。

Generate a calendar file for each month of a year, as well as an index page (cal-html-cursor-year). By default, this command writes files to a yyyy subdirectory—if this is altered some hyperlinks between years will not work.

如果变量cal-html-print-day-number-flag为非nil,则月历显示一年中的日期数字。该变量cal-html-year-index-cols指定年度索引页中的列数。

If the variable cal-html-print-day-number-flag is non-nil, then the monthly calendars show the day-of-the-year number. The variable cal-html-year-index-cols specifies the number of columns in the yearly index page.

Calendar LaTeX 命令生成一个 LaTeX 代码缓冲区,打印为日历。根据您使用的命令,打印的日历涵盖该点所在的日、周、月或年。

The Calendar LaTeX commands produce a buffer of LaTeX code that prints as a calendar. Depending on the command you use, the printed calendar covers the day, week, month or year that point is in.

t m
t m

生成一个月日历 ( cal-tex-cursor-month)。

Generate a one-month calendar (cal-tex-cursor-month).

t M
t M

生成横向打印的一个月日历 ( cal-tex-cursor-month-landscape)。

Generate a sideways-printing one-month calendar (cal-tex-cursor-month-landscape).

t d
t d

生成一日日历 ( cal-tex-cursor-day)。

Generate a one-day calendar (cal-tex-cursor-day).

t w 1
t w 1

生成一周的一页日历,包含小时 ( cal-tex-cursor-week)。

Generate a one-page calendar for one week, with hours (cal-tex-cursor-week).

t w 2
t w 2

生成一周的两页日历,其中包含小时 ( cal-tex-cursor-week2)。

Generate a two-page calendar for one week, with hours (cal-tex-cursor-week2).

t w 3
t w 3

生成一周的 ISO 样式日历,不含小时 ( cal-tex-cursor-week-iso)。

Generate an ISO-style calendar for one week, without hours (cal-tex-cursor-week-iso).

t w 4
t w 4

生成一个从星期一开始的一周的日历,其中包含小时 ( cal-tex-cursor-week-monday)。

Generate a calendar for one Monday-starting week, with hours (cal-tex-cursor-week-monday).

t w W
t w W

生成一周的两页日历,不含小时 ( cal-tex-cursor-week2-summary)。

Generate a two-page calendar for one week, without hours (cal-tex-cursor-week2-summary).

t f w
t f w

生成 Filofax 风格的两周一目了然的日历 ( cal-tex-cursor-filofax-2week)。

Generate a Filofax-style two-weeks-at-a-glance calendar (cal-tex-cursor-filofax-2week).

t f W
t f W

生成 Filofax 风格的一周一目了然的日历 ( cal-tex-cursor-filofax-week)。

Generate a Filofax-style one-week-at-a-glance calendar (cal-tex-cursor-filofax-week).

t y
t y

生成一年的日历 ( cal-tex-cursor-year)。

Generate a calendar for one year (cal-tex-cursor-year).

t Y
t Y

生成一年的横向打印日历 ( cal-tex-cursor-year-landscape)。

Generate a sideways-printing calendar for one year (cal-tex-cursor-year-landscape).

t f y
t f y

生成一年的 filofax 样式日历 ( cal-tex-cursor-filofax-year)。

Generate a Filofax-style calendar for one year (cal-tex-cursor-filofax-year).

其中一些命令横向打印日历(在横向模式下),因此它的宽度可以大于长度。其中一些使用 Filofax 纸张尺寸(3.75 英寸 x 6.75 英寸)。所有这些命令都接受一个前缀参数,该参数指定要打印的天数、周数、月数或年数(始终从选定的日期开始)。

Some of these commands print the calendar sideways (in landscape mode), so it can be wider than it is long. Some of them use Filofax paper size (3.75in x 6.75in). All of these commands accept a prefix argument, which specifies how many days, weeks, months or years to print (starting always with the selected one).

如果变量cal-tex-holidays为非nil(默认),则打印的日历将显示节假日calendar-holidays。如果变量cal-tex-diary为非nil(默认为 nil),则还包括日记条目(仅在月历、Filofax 日历和 iso-week 日历中)。如果变量cal-tex-rules为非nil(默认为nil),则日历以具有足够空间的样式显示规则页面。请查阅各个 cal-tex 函数的文档,了解哪些日历支持哪些功能。

If the variable cal-tex-holidays is non-nil (the default), then the printed calendars show the holidays in calendar-holidays. If the variable cal-tex-diary is non-nil (the default is nil), diary entries are included also (in monthly, Filofax, and iso-week calendars only). If the variable cal-tex-rules is non-nil (the default is nil), the calendar displays ruled pages in styles that have sufficient room. Consult the documentation of the individual cal-tex functions to see which calendars support which features.

cal-tex-preamble-extra如果需要, 您可以使用该变量在生成文档的序言中插入额外的 LaTeX 命令。

You can use the variable cal-tex-preamble-extra to insert extra LaTeX commands in the preamble of the generated document if you need to.


32.6 假期

32.6 Holidays

Emacs 日历知道许多主要和次要假期,并且可以显示它们。您可以将自己的假期添加到默认列表中。

The Emacs calendar knows about many major and minor holidays, and can display them. You can add your own holidays to the default list.

mouse-3 Holidays
mouse-3 Holidays
h
h

显示所选日期 ( calendar-cursor-holidays) 的假期。

Display holidays for the selected date (calendar-cursor-holidays).

x
x

在日历窗口 ( calendar-mark-holidays) 中标记假期。

Mark holidays in the calendar window (calendar-mark-holidays).

u
u

取消标记日历窗口 ( calendar-unmark)。

Unmark calendar window (calendar-unmark).

a
a

calendar-list-holidays在另一个窗口 ( ) 中列出显示的三个月的所有假期。

List all holidays for the displayed three months in another window (calendar-list-holidays).

M-x holidays
M-x holidays

在另一个窗口中列出今天日期前后三个月内的所有假期。

List all holidays for three months around today’s date in another window.

M-x list-holidays
M-x list-holidays

在另一个窗口中列出指定年份范围的假期。

List holidays in another window for a specified range of years.

要查看给定日期是否有假期,请将点定位在日历窗口中的该日期上并使用该h命令。或者,单击该日期mouse-3,然后Holidays 从出现的菜单中进行选择。无论哪种方式,这都会在回显区域中显示该日期的假期(如果适合),否则在单独的窗口中显示。

To see if any holidays fall on a given date, position point on that date in the calendar window and use the h command. Alternatively, click on that date with mouse-3 and then choose Holidays from the menu that appears. Either way, this displays the holidays for that date, in the echo area if they fit there, otherwise in a separate window.

要查看日历中显示的所有日期的假期分布,请使用该x命令。这会以不同的方式显示假期日期。请参阅日历假期标记。该命令既适用于当前可见的月份,也适用于随后通过滚动可见的其他月份。要关闭标记并删除当前标记,请键入u,这也会删除所有日记标记(请参阅日记)。如果变量 calendar-mark-holidays-flag为非nil,则创建或更新日历会自动标记假期。

To view the distribution of holidays for all the dates shown in the calendar, use the x command. This displays the dates that are holidays in a different face. See calendar-holiday-marker. The command applies both to the currently visible months and to other months that subsequently become visible by scrolling. To turn marking off and erase the current marks, type u, which also erases any diary marks (see The Diary). If the variable calendar-mark-holidays-flag is non-nil, creating or updating the calendar marks holidays automatically.

要获取更详细的信息,请使用该a命令,该命令显示一个单独的缓冲区,其中包含当前三个月范围内所有假期的列表。您可以在日历窗口中使用SPCDEL分别向上和向下滚动该列表。

To get even more detailed information, use the a command, which displays a separate buffer containing a list of all holidays in the current three-month range. You can use SPC and DEL in the calendar window to scroll that list up and down, respectively.

该命令M-x holidays显示当月及前后月份的节假日列表;即使您没有日历窗口,这也有效。如果变量 calendar-view-holidays-initially-flag为非nil,则创建日历以这种方式显示假期。如果您希望假期列表以不同月份为中心,请使用C-u M-x holidays,它会提示输入月份和年份。

The command M-x holidays displays the list of holidays for the current month and the preceding and succeeding months; this works even if you don’t have a calendar window. If the variable calendar-view-holidays-initially-flag is non-nil, creating the calendar displays holidays in this way. If you want the list of holidays centered around a different month, use C-u M-x holidays, which prompts for the month and year.

Emacs 已知的节日包括美国节日以及主要的巴哈伊、中国、基督教、伊斯兰教和犹太教节日;还有至日和春分。

The holidays known to Emacs include United States holidays and the major Bahá’í, Chinese, Christian, Islamic, and Jewish holidays; also the solstices and equinoxes.

该命令M-x holiday-list显示一系列年份的假期列表。此功能会询问您的起始年份和终止年份,并允许您选择所有假期或几类假期之一。即使您没有日历窗口,也可以使用此命令。

The command M-x holiday-list displays the list of holidays for a range of years. This function asks you for the starting and stopping years, and allows you to choose all the holidays or one of several categories of holidays. You can use this command even if you don’t have a calendar window.

Emacs 使用的假期日期基于当前实践,而不是历史事实。例如,退伍军人节始于 1919 年,但显示时间较早。

The dates used by Emacs for holidays are based on current practice, not historical fact. For example Veteran’s Day began in 1919, but is shown in earlier years.


32.7 日出和日落的时间

32.7 Times of Sunrise and Sunset

特殊的日历命令可以在一两分钟内告诉您任何日期的日出和日落时间。

Special calendar commands can tell you, to within a minute or two, the times of sunrise and sunset for any date.

mouse-3 Sunrise/sunset
mouse-3 Sunrise/sunset
S
S

显示所选日期 ( calendar-sunrise-sunset) 的日出和日落时间。

Display times of sunrise and sunset for the selected date (calendar-sunrise-sunset).

M-x sunrise-sunset
M-x sunrise-sunset

显示今天日期的日出和日落时间。

Display times of sunrise and sunset for today’s date.

C-u M-x sunrise-sunset
C-u M-x sunrise-sunset

显示指定日期的日出和日落时间。

Display times of sunrise and sunset for a specified date.

M-x calendar-sunrise-sunset-month
M-x calendar-sunrise-sunset-month

显示所选月份的日出和日落时间。

Display times of sunrise and sunset for the selected month.

在日历中,要在回波区域显示当地时间的日出和日落时间,请将光标移至所需日期,然后键入 S。或者,单击mouse-3日期,然后选择“日出日落' 从出现的菜单中。该命令M-x sunrise-sunset可在日历外部使用,以显示今天日期或指定日期的此信息。要指定今天以外的日期,请使用C-u M-x sunrise-sunset,它会提示输入年、月和日。

Within the calendar, to display the local times of sunrise and sunset in the echo area, move point to the date you want, and type S. Alternatively, click mouse-3 on the date, then choose ‘Sunrise/sunset’ from the menu that appears. The command M-x sunrise-sunset is available outside the calendar to display this information for today’s date or a specified date. To specify a date other than today, use C-u M-x sunrise-sunset, which prompts for the year, month, and day.

您可以使用 来显示任何地点和任何日期的日出和日落时间C-u C-u M-x sunrise-sunset。这会要求您提供经度、纬度、与协调世界时的分钟差和日期,然后告诉您该日期该位置的日出和日落时间。

You can display the times of sunrise and sunset for any location and any date with C-u C-u M-x sunrise-sunset. This asks you for a longitude, latitude, number of minutes difference from Coordinated Universal Time, and date, and then tells you the times of sunrise and sunset for that location on that date.

由于日出和日落的时间取决于地球上的位置,因此在使用这些命令之前,您需要告诉 Emacs 您的纬度、经度和位置名称。以下是设置内容的示例:

Because the times of sunrise and sunset depend on the location on earth, you need to tell Emacs your latitude, longitude, and location name before using these commands. Here is an example of what to set:

(setq 日历-纬度 40.1)
(setq 日历经度 -88.2)
(setq 日历位置名称“伊利诺伊州厄巴纳”)
(setq calendar-latitude 40.1)
(setq calendar-longitude -88.2)
(setq calendar-location-name "Urbana, IL")

calendar-latitude和 的值使用一位小数calendar-longitude

Use one decimal place in the values of calendar-latitude and calendar-longitude.

您的时区也会影响当地时间的日出和日落时间。 Emacs 通常从操作系统获取时区信息,但如果这些值不是您想要的(或者操作系统不提供它们),您必须自己设置它们。这是一个例子:

Your time zone also affects the local time of sunrise and sunset. Emacs usually gets time zone information from the operating system, but if these values are not what you want (or if the operating system does not supply them), you must set them yourself. Here is an example:

(setq 日历时区 -360)
(setq 日历标准时区名称“CST”)
(setq 日历-夏令时-时区-名称“CDT”)
(setq calendar-time-zone -360)
(setq calendar-standard-time-zone-name "CST")
(setq calendar-daylight-time-zone-name "CDT")

的值calendar-time-zone是当地标准时间与协调世界时间(格林威治时间)之间的分钟差。calendar-standard-time-zone-name和 的值 calendar-daylight-time-zone-name是您所在时区使用的缩写。 Emacs 显示 根据夏令时校正的日出和日落时间。有关如何确定夏令时, 请参阅夏令时。

The value of calendar-time-zone is the number of minutes difference between your local standard time and Coordinated Universal Time (Greenwich time). The values of calendar-standard-time-zone-name and calendar-daylight-time-zone-name are the abbreviations used in your time zone. Emacs displays the times of sunrise and sunset corrected for daylight saving time. See Daylight Saving Time, for how daylight saving time is determined.

如果你想显示数字时区(例如'“+0100”') 而不是象征性的(如 '“英语六级考试”'),将其设置为numeric.

If you want to display numerical time zones (like ‘"+0100"’) instead of symbolic ones (like ‘"CET"’), set this to numeric.

作为用户,您可能会发现为您通常的物理位置设置日历位置变量很方便.emacs文件。如果您是系统管理员,您可能希望为一个系统中的所有用户设置这些变量默认值.el文件。请参阅Emacs 初始化文件

As a user, you might find it convenient to set the calendar location variables for your usual physical location in your .emacs file. If you are a system administrator, you may want to set these variables for all users in a default.el file. See The Emacs Initialization File.


32.8 月相

32.8 Phases of the Moon

这些日历命令显示月相的日期和时间(新月、上弦月、满月、下弦月)。此功能对于调试取决于月相的问题非常有用。

These calendar commands display the dates and times of the phases of the moon (new moon, first quarter, full moon, last quarter). This feature is useful for debugging problems that depend on the phase of the moon.

M
M

显示 ( ) 所示三个月期间所有月球的日期和时间calendar-lunar-phases

Display the dates and times for all the quarters of the moon for the three-month period shown (calendar-lunar-phases).

M-x lunar-phases
M-x lunar-phases

显示当前日期周围三个月的四分之一月的日期和时间。

Display dates and times of the quarters of the moon for three months around today’s date.

在日历中,使用该M命令显示当前三个月范围内月相的单独缓冲区。列出的日期和时间精确到几分钟之内。

Within the calendar, use the M command to display a separate buffer of the phases of the moon for the current three-month range. The dates and times listed are accurate to within a few minutes.

在日历之外,使用该命令M-x lunar-phases显示当月和前后月份的月相列表。有关不同月份的信息,请使用C-u M-x lunar-phases,它会提示输入月份和年份。

Outside the calendar, use the command M-x lunar-phases to display the list of the phases of the moon for the current month and the preceding and succeeding months. For information about a different month, use C-u M-x lunar-phases, which prompts for the month and year.

月相的日期和时间均以当地时间给出(根据夏令时进行了适当修正)。请参阅上一节中的讨论。请参阅日出和日落时间

The dates and times given for the phases of the moon are given in local time (corrected for daylight saving, when appropriate). See the discussion in the previous section. See Times of Sunrise and Sunset.


32.9 与其他日历的转换

32.9 Conversion To and From Other Calendars

Emacs 显示的日历始终是公历,有时称为新式日历,当今世界大部分地区都使用这种日历。然而,这种历法在十六世纪之前并不存在,并且在十八世纪之前也没有被广泛使用;直到二十世纪初,它才完全取代儒略历并获得普遍接受。 Emacs 日历可以显示自当前纪元第一年 1 月以来的任何月份,但显示的日历始终是公历,即使对于公历不存在的日期也是如此。

The Emacs calendar displayed is always the Gregorian calendar, sometimes called the New Style calendar, which is used in most of the world today. However, this calendar did not exist before the sixteenth century and was not widely used before the eighteenth century; it did not fully displace the Julian calendar and gain universal acceptance until the early twentieth century. The Emacs calendar can display any month since January, year 1 of the current era, but the calendar displayed is always the Gregorian, even for a date at which the Gregorian calendar did not exist.

虽然 Emacs 无法显示其他日历,但它可以在多个其他日历之间进行日期转换。

While Emacs cannot display other calendars, it can convert dates to and from several other calendars.


32.9.1 支持的日历系统

32.9.1 Supported Calendar Systems

ISO商业日历在商业中经常使用。

The ISO commercial calendar is often used in business.

儒略历以朱利叶斯·凯撒命名,是整个中世纪欧洲以及十九世纪之前许多国家使用的历法。

The Julian calendar, named after Julius Caesar, was the one used in Europe throughout medieval times, and in many countries up until the nineteenth century.

天文学家使用儒略历来简单计算自公元前 4713 年 1 月 1 日星期一中午以来经过的天数。经过的天数称为儒略日数天文日数

Astronomers use a simple counting of days elapsed since noon, Monday, January 1, 4713 BC on the Julian calendar. The number of days elapsed is called the Julian day number or the Astronomical day number.

犹太教传统上使用希伯来历。 Emacs 日历程序使用希伯来历来确定犹太节日的日期。希伯来历日期从日落开始和结束。

The Hebrew calendar is used by tradition in the Jewish religion. The Emacs calendar program uses the Hebrew calendar to determine the dates of Jewish holidays. Hebrew calendar dates begin and end at sunset.

许多以伊斯兰为主的国家都使用伊斯兰历。 Emacs 使用它来确定伊斯兰节日的日期。伊斯兰世界对于历法没有统一的看法。 Emacs 使用广泛接受的版本,但伊斯兰节日的确切日期通常取决于宗教当局的宣布,而不是计算。因此,实际的纪念日期可能与 Emacs 计算的日期略有不同。伊斯兰历日期从日落开始和结束。

The Islamic calendar is used in many predominantly Islamic countries. Emacs uses it to determine the dates of Islamic holidays. There is no universal agreement in the Islamic world about the calendar; Emacs uses a widely accepted version, but the precise dates of Islamic holidays often depend on proclamation by religious authorities, not on calculations. As a consequence, the actual dates of observance can vary slightly from the dates computed by Emacs. Islamic calendar dates begin and end at sunset.

法国大革命历法是由雅各宾派在 1789 年革命后创建的,旨在代表一种更世俗和基于自然的年度周期观点,并以类似于公制的合理化措施设置每周 10 天。 1805年底,法国政府正式放弃了这个历法。

The French Revolutionary calendar was created by the Jacobins after the 1789 revolution, to represent a more secular and nature-based view of the annual cycle, and to install a 10-day week in a rationalization measure similar to the metric system. The French government officially abandoned this calendar at the end of 1805.

中美洲的玛雅人使用三种独立的、重叠的历法系统:长历法卓尔金历法哈布历法。 Emacs 了解所有这三个日历。专家们对玛雅历法和我们的历法之间的确切关联存在争议; Emacs 在计算中使用 Goodman-Martinez-Thompson 相关性。

The Maya of Central America used three separate, overlapping calendar systems, the long count, the tzolkin, and the haab. Emacs knows about all three of these calendars. Experts dispute the exact correlation between the Mayan calendar and our calendar; Emacs uses the Goodman-Martinez-Thompson correlation in its calculations.

科普特人使用基于古埃及太阳历的日历。他们的日历由 12 个 30 天的月份组成,后面还有一个额外的 5 天的周期。每四年一次,他们会在这个额外的时期中添加一个闰日,使其达到六天。埃塞俄比亚历法结构相同,但年份和月份名称不同。

The Copts use a calendar based on the ancient Egyptian solar calendar. Their calendar consists of twelve 30-day months followed by an extra five-day period. Once every fourth year they add a leap day to this extra period to make it six days. The Ethiopic calendar is identical in structure, but has different year numbers and month names.

波斯人使用基于奥马尔·海亚姆设计的太阳历。他们的日历由十二个月组成,其中前六个月有31天,接下来的五个月有30天,最后一个平年有29天,闰年有30天。闰年以复杂的模式每四到五年出现一次。这里实现的历法是 Birashk 倡导的算术波斯历,以 2,820 年为一个周期。它与基于天文事件的天文波斯历不同。截至撰写本文时,首次未来差异预计将在 2025 年 3 月 20 日发生。目前尚不清楚届时伊朗的官方日历是什么。

The Persians use a solar calendar based on a design of Omar Khayyam. Their calendar consists of twelve months of which the first six have 31 days, the next five have 30 days, and the last has 29 in ordinary years and 30 in leap years. Leap years occur in a complicated pattern every four or five years. The calendar implemented here is the arithmetical Persian calendar championed by Birashk, based on a 2,820-year cycle. It differs from the astronomical Persian calendar, which is based on astronomical events. As of this writing the first future discrepancy is projected to occur on March 20, 2025. It is currently not clear what the official calendar of Iran will be at that time.

中国历法是一个复杂的系统,将阴历月份排列成太阳年。年以六十为一个周期,每年包含十二个月的平年或十三个月的闰年;每个月有 29 天或 30 天。年、月、日的命名,以十天干之一与十二地支之一相结合,共六十个名称,六十个循环。

The Chinese calendar is a complicated system of lunar months arranged into solar years. The years go in cycles of sixty, each year containing either twelve months in an ordinary year or thirteen months in a leap year; each month has either 29 or 30 days. Years, ordinary months, and days are named by combining one of ten celestial stems with one of twelve terrestrial branches for a total of sixty names that are repeated in a cycle of sixty.

巴哈伊历法基于 19 个月、每个 19 天的太阳周期。剩下的四个闰日位于第十八个月和第十九个月之间。

The Bahá’í calendar system is based on a solar cycle of 19 months with 19 days each. The four remaining intercalary days are placed between the 18th and 19th months.


32.9.2 转换为其他日历

32.9.2 Converting To Other Calendars

以下命令描述了各种其他日历系统中的选定日期(此时的日期):

The following commands describe the selected date (the date at point) in various other calendar systems:

mouse-3 Other calendars
mouse-3 Other calendars
p o
p o

在各种其他日历中显示所选日期。 ( calendar-print-other-dates)。

Display the selected date in various other calendars. (calendar-print-other-dates).

p c
p c

显示所选日期 ( ) 的等效 ISO 商业日历calendar-iso-print-date

Display ISO commercial calendar equivalent for selected day (calendar-iso-print-date).

p j
p j

显示所选日期 ( calendar-julian-print-date) 的儒略日期。

Display Julian date for selected day (calendar-julian-print-date).

p a
p a

显示所选日期 ( ) 的天文(儒略)日数calendar-astro-print-day-number

Display astronomical (Julian) day number for selected day (calendar-astro-print-day-number).

p h
p h

显示所选日期 ( calendar-hebrew-print-date) 的希伯来语日期。

Display Hebrew date for selected day (calendar-hebrew-print-date).

p i
p i

显示所选日期 ( calendar-islamic-print-date) 的伊斯兰日期。

Display Islamic date for selected day (calendar-islamic-print-date).

p f
p f

显示所选日期 ( calendar-french-print-date) 的法国大革命日期。

Display French Revolutionary date for selected day (calendar-french-print-date).

p b
p b

显示所选日期 ( calendar-bahai-print-date) 的巴哈伊日期。

Display Bahá’í date for selected day (calendar-bahai-print-date).

p C
p C

显示所选日期 ( calendar-chinese-print-date) 的中文日期。

Display Chinese date for selected day (calendar-chinese-print-date).

p k
p k

显示所选日期 ( calendar-coptic-print-date) 的科普特日期。

Display Coptic date for selected day (calendar-coptic-print-date).

p e
p e

显示所选日期 ( calendar-ethiopic-print-date) 的埃塞俄比亚日期。

Display Ethiopic date for selected day (calendar-ethiopic-print-date).

p p
p p

显示所选日期 ( calendar-persian-print-date) 的波斯日期。

Display Persian date for selected day (calendar-persian-print-date).

p m
p m

显示所选日期 ( calendar-mayan-print-date) 的玛雅日期。

Display Mayan date for selected day (calendar-mayan-print-date).

否则,将点移动到要转换的日期,然后键入从p上表开始的适当命令。该前缀p是“print”的助记符,因为 Emacs 在回显区域“打印”等效日期。 p o以 Emacs 已知的所有形式显示日期。您还可以使用mouse-3,然后Other calendars从出现的菜单中进行选择。这会以菜单的形式显示 Emacs 理解的所有日历中日期的等效形式。 (从此菜单中选择替代项实际上不会执行任何操作 - 该菜单仅用于显示。)

Otherwise, move point to the date you want to convert, then type the appropriate command starting with p from the table above. The prefix p is a mnemonic for “print”, since Emacs “prints” the equivalent date in the echo area. p o displays the date in all forms known to Emacs. You can also use mouse-3 and then choose Other calendars from the menu that appears. This displays the equivalent forms of the date in all the calendars Emacs understands, in the form of a menu. (Choosing an alternative from this menu doesn’t actually do anything—the menu is used only for display.)


32.9.3 从其他日历转换

32.9.3 Converting From Other Calendars

您可以使用其他支持的日历来指定要移至的日期。本节介绍使用 Mayan 以外的日历执行此操作的命令;对于玛雅历法,请参阅以下部分。

You can use the other supported calendars to specify a date to move to. This section describes the commands for doing this using calendars other than Mayan; for the Mayan calendar, see the following section.

g c
g c

移至 ISO 商业日历 ( ) 中指定的日期calendar-iso-goto-date

Move to a date specified in the ISO commercial calendar (calendar-iso-goto-date).

g w
g w

移至 ISO 商业日历 ( ) 中指定的一周calendar-iso-goto-week

Move to a week specified in the ISO commercial calendar (calendar-iso-goto-week).

g j
g j

移至儒略历 ( ) 中指定的日期calendar-julian-goto-date

Move to a date specified in the Julian calendar (calendar-julian-goto-date).

g a
g a

移至用天文(儒略)日数 ( calendar-astro-goto-day-number) 指定的日期。

Move to a date specified with an astronomical (Julian) day number (calendar-astro-goto-day-number).

g b
g b

移至巴哈伊历中指定的日期 ( calendar-bahai-goto-date)。

Move to a date specified in the Bahá’í calendar (calendar-bahai-goto-date).

g h
g h

移至希伯来历 ( ) 中指定的日期calendar-hebrew-goto-date

Move to a date specified in the Hebrew calendar (calendar-hebrew-goto-date).

g i
g i

移至伊斯兰历 ( ) 中指定的日期calendar-islamic-goto-date

Move to a date specified in the Islamic calendar (calendar-islamic-goto-date).

g f
g f

移至法国大革命日历 ( ) 中指定的日期calendar-french-goto-date

Move to a date specified in the French Revolutionary calendar (calendar-french-goto-date).

g C
g C

移至农历 ( calendar-chinese-goto-date) 中指定的日期。

Move to a date specified in the Chinese calendar (calendar-chinese-goto-date).

g p
g p

移至波斯历 ( ) 中指定的日期calendar-persian-goto-date

Move to a date specified in the Persian calendar (calendar-persian-goto-date).

g k
g k

移至科普特日历 ( ) 中指定的日期calendar-coptic-goto-date

Move to a date specified in the Coptic calendar (calendar-coptic-goto-date).

g e
g e

移至埃塞俄比亚历 ( ) 中指定的日期calendar-ethiopic-goto-date

Move to a date specified in the Ethiopic calendar (calendar-ethiopic-goto-date).

这些命令要求您输入其他日历上的日期,将指针移动到与该日期等效的公历日期,并在回显区域中显示其他日历的日期。每当Emacs 要求您输入月份名称时,它都会使用严格的完成(请参阅完成退出),因此您不必担心希伯来语、伊斯兰语或法语名称的拼写。

These commands ask you for a date on the other calendar, move point to the Gregorian calendar date equivalent to that date, and display the other calendar’s date in the echo area. Emacs uses strict completion (see Completion Exit) whenever it asks you to type a month name, so you don’t have to worry about the spelling of Hebrew, Islamic, or French names.

关于希伯来历的一个常见问题是死亡日期周年纪念日的计算,称为yahrzeit。 Emacs 日历包含用于此类计算的工具。如果您在日历中,该命令M-x calendar-hebrew-list-yahrzeits会要求您输入年份范围,然后显示这些年份的 yahrzeit 日期列表,这些年份对应于 point 给定的日期。如果您不在日历中,此命令首先会询问您的死亡日期和年份范围,然后显示耶尔泽特日期列表。

One common issue concerning the Hebrew calendar is the computation of the anniversary of a date of death, called a yahrzeit. The Emacs calendar includes a facility for such calculations. If you are in the calendar, the command M-x calendar-hebrew-list-yahrzeits asks you for a range of years and then displays a list of the yahrzeit dates for those years for the date given by point. If you are not in the calendar, this command first asks you for the date of death and the range of years, and then displays the list of yahrzeit dates.


32.10 日记

32.10 The Diary

Emacs 日记结合日历每天跟踪约会或其他事件。要使用日记功能,您必须首先创建一个包含事件及其日期列表的日记文件。然后,Emacs 可以自动挑选并显示今天、不久的将来或任何指定日期的事件。

The Emacs diary keeps track of appointments or other events on a daily basis, in conjunction with the calendar. To use the diary feature, you must first create a diary file containing a list of events and their dates. Then Emacs can automatically pick out and display the events for today, for the immediate future, or for any specified date.

尽管您可能会首先手动创建日记,但 Emacs 提供了许多命令来让您查看、添加和更改日记条目。

Although you probably will start by creating a diary manually, Emacs provides a number of commands to let you view, add, and change diary entries.


32.10.1 日记文件

32.10.1 The Diary File

您的日记文件是记录与特定日期相关的事件的文件。日记文件的名称由变量指定diary-file。默认为〜/.emacs.d/日记,但为了与旧版本兼容,Emacs 将使用 〜/日记如果存在的话。

Your diary file is a file that records events associated with particular dates. The name of the diary file is specified by the variable diary-file. The default is ~/.emacs.d/diary, though for compatibility with older versions Emacs will use ~/diary if it exists.

日记文件中的每个条目描述一个事件并由一行或多行组成。条目始终以左侧空白处的日期规范开始。条目的其余部分只是描述事件的文本。如果条目有多于一行,则第一行之后的行必须以空格开头,以指示它们继续上一个条目。不以有效日期开头且不继续前面条目的行将被忽略。这是一个例子:

Each entry in the diary file describes one event and consists of one or more lines. An entry always begins with a date specification at the left margin. The rest of the entry is simply text to describe the event. If the entry has more than one line, then the lines after the first must begin with whitespace to indicate they continue a previous entry. Lines that do not begin with valid dates and do not continue a preceding entry are ignored. Here’s an example:

2015年12月22日结婚二十周年纪念日!
10/22 露丝生日。
* 21,*:发薪日
周二——每周上午 10 点与研究生会面
         Supowit、Shen、Bitner 和 Kapoor 出席。
89 年 1 月 13 日,十三号星期五!!
周四下午 4 点与劳埃德 (Lloyd) 进行壁球比赛。
3月16日 爸爸生日
2016 年 4 月 15 日应缴纳所得税。
* 15 张考勤卡到期。
12/22/2015  Twentieth wedding anniversary!
10/22       Ruth's birthday.
* 21, *:    Payday
Tuesday--weekly meeting with grad students at 10am
         Supowit, Shen, Bitner, and Kapoor to attend.
1/13/89     Friday the thirteenth!!
thu 4pm     squash game with Lloyd.
mar 16      Dad's birthday
April 15, 2016 Income tax due.
* 15        time cards due.

此示例使用额外的空格来对齐大多数条目的事件描述。这种格式纯粹是一个品味问题。

This example uses extra spaces to align the event descriptions of most of the entries. Such formatting is purely a matter of taste.

您还可以使用日记条目的第一行仅包含日期或日期名称(后面没有空格或标点符号)的格式。例如:

You can also use a format where the first line of a diary entry consists only of the date or day name (with no following blanks or punctuation). For example:

2012年2月11日
      Bill B. 今天访问普林斯顿
      下午 2 点认知研究委员会会议
      2:30-5:30 莉兹在劳伦斯维尔
      4:00 PM 牙医预约
      7:30 PM 在乔治餐厅享用晚餐
      8:00-10:00 PM 音乐会
02/11/2012
      Bill B. visits Princeton today
      2pm Cognitive Studies Committee meeting
      2:30-5:30 Liz at Lawrenceville
      4:00pm Dentist appt
      7:30pm Dinner at George's
      8:00-10:00pm concert

如果您使用简单的日记显示,则此条目将具有不同的外观(请参阅日记显示)。简单的日记显示省略了开头的日期线;仅出现续行。当您仅显示一天的条目时,这种条目样式看起来更整洁,但如果您要求多于一天的条目,则可能会造成混乱。

This entry will have a different appearance if you use the simple diary display (see Diary Display). The simple diary display omits the date line at the beginning; only the continuation lines appear. This style of entry looks neater when you display just a single day’s entries, but can cause confusion if you ask for more than one day’s entries.


32.10.2 显示日记

32.10.2 Displaying the Diary

创建日记文件后,您可以使用日历来查看它。您还可以在日历模式之外查看今天的事件。在下文中,键绑定指的是日历缓冲区。

Once you have created a diary file, you can use the calendar to view it. You can also view today’s events outside of Calendar mode. In the following, key bindings refer to the Calendar buffer.

mouse-3 Diary
mouse-3 Diary
d
d

显示所选日期 ( diary-view-entries) 的所有日记条目。

Display all diary entries for the selected date (diary-view-entries).

s
s

显示整个日记文件 ( diary-show-all-entries)。

Display the entire diary file (diary-show-all-entries).

m
m

标记所有有日记条目的可见日期 ( diary-mark-entries)。

Mark all visible dates that have diary entries (diary-mark-entries).

u
u

取消标记日历窗口 ( calendar-unmark)。

Unmark the calendar window (calendar-unmark).

M-x diary-print-entries
M-x diary-print-entries

打印日记显示的硬拷贝。

Print hard copy of the diary display as it appears.

M-x diary
M-x diary

显示今天的所有日记条目。

Display all diary entries for today’s date.

M-x diary-mail-entries
M-x diary-mail-entries

向自己发送有关即将到来的日记条目的电子邮件提醒。

Mail yourself email reminders about upcoming diary entries.

显示日记条目d在单独的缓冲区中显示日历中选定日期的日记条目。新缓冲区的模式行显示日记条目的日期。假期显示在缓冲区或模式行中,具体取决于您选择的显示方法(请参阅日记显示)。如果您使用 指定数字参数d,它将显示连续多天的所有日记条目。因此,2 d显示所选日期和第二天的所有条目。

Displaying the diary entries with d shows in a separate buffer the diary entries for the selected date in the calendar. The mode line of the new buffer shows the date of the diary entries. Holidays are shown either in the buffer or in the mode line, depending on the display method you choose (see Diary Display). If you specify a numeric argument with d, it shows all the diary entries for that many successive days. Thus, 2 d displays all the entries for the selected date and for the following day.

显示日期日记条目的另一种方法是单击 mouse-3日期,然后Diary entries从出现的菜单中进行选择。如果变量 calendar-view-diary-initially-flag为非nil,则创建日历会列出当前日期的日记条目(前提是当前日期可见)。

Another way to display the diary entries for a date is to click mouse-3 on the date, and then choose Diary entries from the menu that appears. If the variable calendar-view-diary-initially-flag is non-nil, creating the calendar lists the diary entries for the current date (provided the current date is visible).

要更广泛地了解日记中提到的日子,请使用该m命令。这标志着日记条目以不同面貌出现的日期。请参阅日记条目标记

To get a broader view of which days are mentioned in the diary, use the m command. This marks the dates that have diary entries in a different face. See diary-entry-marker.

此命令既适用于当前可见的月份,也适用于滚动后随后变得可见的月份。要关闭标记并删除当前标记,请键入u,这也会关闭假日标记(请参阅假日)。如果变量 calendar-mark-diary-entries-flag为非nil,则创建或更新日历会自动标记日记日期。

This command applies both to the months that are currently visible and to those that subsequently become visible after scrolling. To turn marking off and erase the current marks, type u, which also turns off holiday marks (see Holidays). If the variable calendar-mark-diary-entries-flag is non-nil, creating or updating the calendar marks diary dates automatically.

要防止在日历中标记单个日记条目,请插入diary-nonmarking-symbol 指定的字符串(默认为 '&') 位于条目开头、日期之前。这对日记缓冲区中条目的显示没有影响;它只影响日历中日期的标记。非标记条目对于否则会标记许多不同日期的通用条目很有用。

To prevent an individual diary entry from being marked in the calendar, insert the string that diary-nonmarking-symbol specifies (the default is ‘&’) at the beginning of the entry, before the date. This has no effect on display of the entry in the diary buffer; it only affects marks on dates in the calendar. Nonmarking entries can be useful for generic entries that would otherwise mark many different dates.

要查看完整的日记文件,而不仅仅是某些条目,请使用该s命令。

To see the full diary file, rather than just some of the entries, use the s command.

该命令M-x diary显示当前日期的日记条目,与日历显示无关,也可以选择显示接下来几天的日记条目;该变量diary-number-of-entries指定要包含的天数。请参阅日记条目数

The command M-x diary displays the diary entries for the current date, independently of the calendar display, and optionally for the next few days as well; the variable diary-number-of-entries specifies how many days to include. See diary-number-of-entries.

如果你把(diary)你的.emacs文件,当您启动 Emacs 时,这会自动显示一个窗口,其中包含当天的日记条目。

If you put (diary) in your .emacs file, this automatically displays a window with the day’s diary entries when you start Emacs.

有些人喜欢接收日记中事件的电子邮件通知。要向自己发送此类邮件,请使用命令M-x diary-mail-entries。前缀参数指定要检查的天数(从今天开始);否则,该变量 diary-mail-days表示多少天。

Some people like to receive email notifications of events in their diary. To send such mail to yourself, use the command M-x diary-mail-entries. A prefix argument specifies how many days (starting with today) to check; otherwise, the variable diary-mail-days says how many days.


32.10.3 日期格式

32.10.3 Date Formats

以下是一些示例日记条目,说明了格式化日期的不同方法。这些示例均以美国顺序(月、日、年)显示日期,但日历模式支持欧洲顺序(日、月、年)和 ISO 顺序(年、月、日)作为选项。

Here are some sample diary entries, illustrating different ways of formatting a date. The examples all show dates in American order (month, day, year), but Calendar mode supports European order (day, month, year) and ISO order (year, month, day) as options.

2012年4月20日 切换至新的制表系统
四月25 开始将年度业绩制成表格
4/30 四月份的结果即将公布
*/25 每月周期结束
星期五 不要在没有备份文件的情况下离开
4/20/12  Switch-over to new tabulation system
apr. 25  Start tabulating annual results
4/30  Results for April are due
*/25  Monthly cycle finishes
Friday  Don't leave without backing up files

第一个条目仅在 2012 年 4 月 20 日出现一次。第二个和第三个条目每年在指定日期出现,第四个条目使用通配符(星号)表示月份,因此它出现在每个月的 25 日。最终条目每周周五出现。

The first entry appears only once, on April 20, 2012. The second and third appear every year on the specified dates, and the fourth uses a wildcard (asterisk) for the month, so it appears on the 25th of every month. The final entry appears every week on Friday.

您可以仅使用数字来表示日期,如 '' 或者 ''。后面必须跟一个非数字。在日期本身中,月份日期是一位或两位数字。可选的年份 也是一个数字,并且可以缩写为最后两位数字;也就是说,您可以使用 '2012年11月12日' 或者 '12年11月12日'。

You can use just numbers to express a date, as in ‘month/day’ or ‘month/day/year’. This must be followed by a nondigit. In the date itself, month and day are numbers of one or two digits. The optional year is also a number, and may be abbreviated to the last two digits; that is, you can use ‘11/12/2012’ or ‘11/12/12’.

日期也可以采用以下形式 '月名 ' 或者 '月名 ,',其中月份名称可以拼写为全称或缩写(带或不带句点)。月份和日期名称的首选缩写可以使用变量calendar-abbrev-lengthcalendar-month-abbrev-array和 来设置calendar-day-abbrev-array。默认情况下使用名称的前三个字母作为其缩写。案例并不重要。

Dates can also have the form ‘monthname day’ or ‘monthname day, year’, where the month’s name can be spelled in full or abbreviated (with or without a period). The preferred abbreviations for month and day names can be set using the variables calendar-abbrev-length, calendar-month-abbrev-array, and calendar-day-abbrev-array. The default is to use the first three letters of a name as its abbreviation. Case is not significant.

日期可以是通用的;也就是说,部分未指定。然后该条目适用于与规范匹配的所有日期。如果日期不包含年份,则它是通用的并且适用于任何年份。或者,可以是 '*';这分别匹配任何月份、日期或年份。因此,日记条目'3/*/*' 匹配任何一年三月的任何一天;也是如此'行进 *'。

A date may be generic; that is, partially unspecified. Then the entry applies to all dates that match the specification. If the date does not contain a year, it is generic and applies to any year. Alternatively, month, day, or year can be ‘*’; this matches any month, day, or year, respectively. Thus, a diary entry ‘3/*/*’ matches any day in March of any year; so does ‘march *’.

如果您更喜欢欧洲日期书写风格(其中日期在月份之前)或 ISO 风格(其中顺序为年、月、日),请M-x calendar-set-date-style在日历中键入 while ,或自定义变量calendar-date-style。这会影响日记日期的解释方式、日期显示以及某些命令期望给出参数的顺序。

If you prefer the European style of writing dates (in which the day comes before the month), or the ISO style (in which the order is year, month, day), type M-x calendar-set-date-style while in the calendar, or customize the variable calendar-date-style. This affects how diary dates are interpreted, date display, and the order in which some commands expect their arguments to be given.

您可以使用一周中某一天的名称作为通用日期,该日期适用于一周中这一天的任何日期。您可以如上所述缩写星期几,或完整拼写;案例并不重大。

You can use the name of a day of the week as a generic date which applies to any date falling on that day of the week. You can abbreviate the day of the week as described above, or spell it in full; case is not significant.


32.10.4 添加到日记的命令

32.10.4 Commands to Add to the Diary

在日历中,有几个用于创建日记条目的命令。这里列出了基本命令;更复杂的命令在下一节中(请参阅特殊日记条目)。条目也可以基于非公历。请参阅使用非公历的日记条目

While in the calendar, there are several commands to create diary entries. The basic commands are listed here; more sophisticated commands are in the next section (see Special Diary Entries). Entries can also be based on non-Gregorian calendars. See Diary Entries Using non-Gregorian Calendars.

i d
i d

添加所选日期 ( diary-insert-entry) 的日记条目。

Add a diary entry for the selected date (diary-insert-entry).

i w
i w

添加一周中选定日期的日记条目 ( diary-insert-weekly-entry)。

Add a diary entry for the selected day of the week (diary-insert-weekly-entry).

i m
i m

添加该月选定日期 ( diary-insert-monthly-entry) 的日记条目。

Add a diary entry for the selected day of the month (diary-insert-monthly-entry).

i y
i y

添加一年中选定日期 ( diary-insert-yearly-entry) 的日记条目。

Add a diary entry for the selected day of the year (diary-insert-yearly-entry).

您可以通过在日历窗口中选择该日期并键入命令来为特定日期创建日记条目i d。此命令在另一个窗口中显示日记文件的末尾并插入日期;然后您可以输入日记条目的其余部分。

You can make a diary entry for a specific date by selecting that date in the calendar window and typing the i d command. This command displays the end of your diary file in another window and inserts the date; you can then type the rest of the diary entry.

如果您想创建适用于一周中特定一天的日记条目,请选择一周中的那一天(任何出现的情况都可以)并输入 i w。这将插入星期几作为通用日期;然后您可以输入日记条目的其余部分。您可以用相同的方式创建每月日记条目:选择该月的某一天,使用命令i m ,然后键入条目的其余部分。同样,您可以使用该命令插入年度日记条目i y

If you want to make a diary entry that applies to a specific day of the week, select that day of the week (any occurrence will do) and type i w. This inserts the day-of-week as a generic date; you can then type the rest of the diary entry. You can make a monthly diary entry in the same fashion: select the day of the month, use the i m command, and type the rest of the entry. Similarly, you can insert a yearly diary entry with the i y command.

所有上述命令默认都会标记日记条目。要创建非标记日记条目,请为命令提供前缀参数。例如,C-u i w每周写一篇无标记日记。

All of the above commands make marking diary entries by default. To make a nonmarking diary entry, give a prefix argument to the command. For example, C-u i w makes a nonmarking weekly diary entry.

当您修改日记文件时,请务必在退出 Emacs 之前保存该文件。使用上述任何插入命令后保存日记文件将自动更新日历窗口中的日记标记(如果适用)。您可以 calendar-redraw随时使用该命令强制更新。

When you modify the diary file, be sure to save the file before exiting Emacs. Saving the diary file after using any of the above insertion commands will automatically update the diary marks in the calendar window, if appropriate. You can use the command calendar-redraw to force an update at any time.


32.10.5 特殊日记条目

32.10.5 Special Diary Entries

除了基于日历日期的条目之外,日记文件还可以包含定期事件(例如周年纪念日)的sexp 条目。这些条目基于 Emacs 在扫描日记文件时计算的 Lisp 表达式 (sexp)。 sexp 条目包含“而不是日期”%%' 后跟 Lisp 表达式,必须以括号开头和结尾。 Lisp 表达式确定条目适用于哪些日期。

In addition to entries based on calendar dates, the diary file can contain sexp entries for regular events such as anniversaries. These entries are based on Lisp expressions (sexps) that Emacs evaluates as it scans the diary file. Instead of a date, a sexp entry contains ‘%%’ followed by a Lisp expression which must begin and end with parentheses. The Lisp expression determines which dates the entry applies to.

日历模式提供了插入某些常用 sexp 条目的命令:

Calendar mode provides commands to insert certain commonly used sexp entries:

i a
i a

添加所选日期 ( diary-insert-anniversary-entry) 的周年纪念日记条目。

Add an anniversary diary entry for the selected date (diary-insert-anniversary-entry).

i b
i b

为当前区域添加块日记条目 ( diary-insert-block-entry)。

Add a block diary entry for the current region (diary-insert-block-entry).

i c
i c

添加从日期 ( diary-insert-cyclic-entry) 开始的循环日记条目。

Add a cyclic diary entry starting at the date (diary-insert-cyclic-entry).

如果要创建适用于特定日期的周年纪念日的日记条目,请将点移至该日期并使用该i a命令。这将在另一个窗口中显示日记文件的末尾并插入周年纪念日描述;然后您可以输入日记条目的其余部分。该条目看起来像这样:

If you want to make a diary entry that applies to the anniversary of a specific date, move point to that date and use the i a command. This displays the end of your diary file in another window and inserts the anniversary description; you can then type the rest of the diary entry. The entry looks like this:

%%(日记-周年纪念日 10 31 1988) 亚瑟的生日
%%(diary-anniversary 10 31 1988) Arthur's birthday

此条目适用于 1988 年之后任何一年的 10 月 31 日; '1988年10月31日' 指定日期。 (如果您使用欧洲或 ISO 日历样式,月、日、年的输入顺序会有所不同。)此表达式需要起始年份的原因是高级日记函数可以使用它来计算经过的年数。

This entry applies to October 31 in any year after 1988; ‘10 31 1988’ specifies the date. (If you are using the European or ISO calendar style, the input order of month, day and year is different.) The reason this expression requires a beginning year is that advanced diary functions can use it to calculate the number of elapsed years.

块日记条目适用于指定连续日期范围。以下是适用于 2012 年 6 月 24 日至 2012 年 7 月 10 日期间所有日期的块日记条目:

A block diary entry applies to a specified range of consecutive dates. Here is a block diary entry that applies to all dates from June 24, 2012 through July 10, 2012:

%%(日记块 6 24 2012 7 10 2012) 假期
%%(diary-block 6 24 2012 7 10 2012) Vacation

这 '2012年6月24日' 表示开始日期,'2012年7月10日' 表示停止日期。 (同样,如果您使用欧洲或 ISO 日历样式,月、日、年的输入顺序是不同的。)

The ‘6 24 2012’ indicates the starting date and the ‘7 10 2012’ indicates the stopping date. (Again, if you are using the European or ISO calendar style, the input order of month, day and year is different.)

要插入块条目,请将点和标记放置在范围开始和结束的两个日期上,然后键入i b。此命令在另一个窗口中显示日记文件的末尾并插入块描述;然后您可以输入日记条目。

To insert a block entry, place point and the mark on the two dates that begin and end the range, and type i b. This command displays the end of your diary file in another window and inserts the block description; you can then type the diary entry.

循环日记条目在固定的天数间隔后重复。要创建一个,请选择开始日期并使用该i c命令。该命令提示输入间隔长度,然后插入条目,如下所示:

Cyclic diary entries repeat after a fixed interval of days. To create one, select the starting date and use the i c command. The command prompts for the length of interval, then inserts the entry, which looks like this:

%%(日记循环 50 3 1 2012) 更新药物
%%(diary-cyclic 50 3 1 2012) Renew medication

此条目适用于 2012 年 3 月 1 日及之后的每 50 天; '3 1 2012' 指定开始日期。 (如果您使用欧洲或ISO日历样式,月、日、年的输入顺序不同。)

This entry applies to March 1, 2012 and every 50th day following; ‘3 1 2012’ specifies the starting date. (If you are using the European or ISO calendar style, the input order of month, day and year is different.)

所有这三个命令都会标记日记条目。要插入非标记条目,请为命令提供前缀参数。例如, C-u i a制作一个无标记的周年纪念日记条目。

All three of these commands make marking diary entries. To insert a nonmarking entry, give a prefix argument to the command. For example, C-u i a makes a nonmarking anniversary diary entry.

在日历中标记 sexp 日记条目可能非常耗时,因为必须单独检查日历窗口中可见的每个日期。因此,最好将 sexp 日记条目设置为非标记(使用 '&') 如果可能。

Marking sexp diary entries in the calendar can be time-consuming, since every date visible in the calendar window must be individually checked. So it’s a good idea to make sexp diary entries nonmarking (with ‘&’) when possible.

另一种复杂的 sexp 条目是浮动日记条目,它通过以天、周和月为单位指定的偏移量来指定定期发生的事件。它与实用程序解释的 crontab 条目相当cron。这是一个无标记的浮动日记条目,适用于 11 月的第四个星期四:

Another sophisticated kind of sexp entry, a floating diary entry, specifies a regularly occurring event by offsets specified in days, weeks, and months. It is comparable to a crontab entry interpreted by the cron utility. Here is a nonmarking, floating diary entry that applies to the fourth Thursday in November:

&%%(diary-float 11 4 4) 美国感恩节
&%%(diary-float 11 4 4) American Thanksgiving

11 指定十一月(第十一个月),4 指定星期四(一周的第四天,星期日编号为零),第二个 4 指定第四个星期四(1 表示“第一个”,2 表示“第二个”) ”,-2 表示“倒数第二个”,依此类推)。该月份可以是单个月份或月份列表。因此你可以将上面的 11 更改为 ''(1 2 3)' 并将该条目应用于一月、二月和三月的最后一个星期四。如果月份是t,则该条目适用于一年中的所有月份。

The 11 specifies November (the eleventh month), the 4 specifies Thursday (the fourth day of the week, where Sunday is numbered zero), and the second 4 specifies the fourth Thursday (1 would mean “first”, 2 would mean “second”, −2 would mean “second-to-last”, and so on). The month can be a single month or a list of months. Thus you could change the 11 above to ‘'(1 2 3)’ and have the entry apply to the last Thursday of January, February, and March. If the month is t, the entry applies to all months of the year.

%%(diary-offset '(diary-float t 3 4) 2) 每月委员会会议
%%(diary-offset '(diary-float t 3 4) 2) Monthly committee meeting

此条目适用于每月第三个星期四之后的星期六。 2 指定 sexp '(diary-float t 3 4)计算结果为后的天数t。例如,当您的组织在第三个星期四举行的每月会议两天后召开委员会会议,或者您想参加安排在不同时区的虚拟会议导致日期不同时,这非常有用。

This entry applies to the Saturday after the third Thursday of each month. The 2 specifies number of days after when the sexp '(diary-float t 3 4) would evaluate to t. This is useful when for example your organization has a committee meeting two days after every monthly meeting which takes place on the third Thursday, or if you would like to attend a virtual meeting scheduled in a different timezone causing a difference in the date.

每个标准 sexp 日记条目都采用一个可选参数,指定在日历中标记条目时要使用的面孔名称或单字符字符串。最一般地,sexp 日记条目可以执行任意计算以确定它们何时应用。请参阅性爱条目和精美日记显示

Each of the standard sexp diary entries takes an optional parameter specifying the name of a face or a single-character string to use when marking the entry in the calendar. Most generally, sexp diary entries can perform arbitrary computations to determine when they apply. See Sexp Entries and the Fancy Diary Display.


32.10.6 约会

32.10.6 Appointments

如果您有一个约会的日记条目,并且该日记条目以一天中可识别的时间开始,则 Emacs 可以提前警告您约会正在等待处理。 Emacs 通过以您选择的格式(由变量 指定)显示消息来提醒您约会appt-display-format。如果 的值为 appt-audible非 - nil,则警告包括声音提醒。此外,如果appt-display-mode-line是非- nil,Emacs 将在模式行上显示约会的分钟数。

If you have a diary entry for an appointment, and that diary entry begins with a recognizable time of day, Emacs can warn you in advance that an appointment is pending. Emacs alerts you to the appointment by displaying a message in your chosen format, as specified by the variable appt-display-format. If the value of appt-audible is non-nil, the warning includes an audible reminder. In addition, if appt-display-mode-line is non-nil, Emacs displays the number of minutes to the appointment on the mode line.

如果appt-display-format值为window,则该变量appt-display-duration控制提醒窗口可见的时间长度;变量 appt-disp-window-functionappt-delete-window-function 分别给出用于创建和销毁窗口的函数的名称。

If appt-display-format has the value window, then the variable appt-display-duration controls how long the reminder window is visible for; and the variables appt-disp-window-function and appt-delete-window-function give the names of functions used to create and destroy the window, respectively.

要启用预约通知,请键入M-x appt-activate。有了积极的论点,它就可以发出通知;如果参数为负,则禁用通知;没有参数,它会切换。启用通知还会从日记文件中设置今天的约会列表,提供在一天中可识别时间找到的所有日记条目,并在每个条目之前提醒您。

To enable appointment notification, type M-x appt-activate. With a positive argument, it enables notification; with a negative argument, it disables notification; with no argument, it toggles. Enabling notification also sets up an appointment list for today from the diary file, giving all diary entries found with recognizable times of day, and reminds you just before each of them.

例如,假设日记文件包含以下几行:

For example, suppose the diary file contains these lines:

周一
  上午 9:30 茶歇
 中午 12:00 午餐
Monday
  9:30am Coffee break
 12:00pm Lunch

然后在周一,系统会在上午 9:20 左右提醒您休息时间,并在上午 11:50 左右提醒您午餐时间。该变量 appt-message-warning-time指定提前多少分钟(默认 12)向您发出警告。这是默认警告时间。每个约会都可以通过添加件匹配来指定不同的警告时间appt-warning-time-regexp(有关详细信息,请参阅该变量的文档)。

Then on Mondays, you will be reminded at around 9:20am about your coffee break and at around 11:50am about lunch. The variable appt-message-warning-time specifies how many minutes (default 12) in advance to warn you. This is a default warning time. Each appointment can specify a different warning time by adding a piece matching appt-warning-time-regexp (see that variable’s documentation for details).

您可以以 am/pm 风格编写时间(使用 '12:00 AM' 站到午夜并且 '12:00 PM' 代表中午),或 24 小时欧洲/军事风格。你不需要保持一致;您的日记文件可以混合使用两种样式。如果日记要被识别,时间必须位于日记的开头。

You can write times in am/pm style (with ‘12:00am’ standing for midnight and ‘12:00pm’ standing for noon), or 24-hour European/military style. You need not be consistent; your diary file can have a mixture of the two styles. Times must be at the beginning of diary entries if they are to be recognized.

Emacs 会在午夜过后自动更新日记文件中的约会列表。您可以随时通过重新启用预约通知来强制更新。这两个操作也会显示当天的日记缓冲区,除非您设置 appt-display-diarynil。每当保存日记文件(或其包含的文件;请参阅 精美日记显示)时,约会列表也会更新。如果您使用组织模式并在组织议程文件中保留约会,则可以使用以下命令将这些约会添加到列表中 org-agenda-to-appt。有关该命令的更多信息, 请参阅《组织手册》中的约会提醒。

Emacs updates the appointments list from the diary file automatically just after midnight. You can force an update at any time by re-enabling appointment notification. Both these actions also display the day’s diary buffer, unless you set appt-display-diary to nil. The appointments list is also updated whenever the diary file (or a file it includes; see Fancy Diary Display) is saved. If you use the Org Mode and keep appointments in your Org agenda files, you can add those appointments to the list using the org-agenda-to-appt command. See Appointment reminders in The Org Manual, for more about that command.

您还可以使用闹钟等预约通知功能。该命令M-x appt-add将条目添加到约会列表,而不影响您的日记文件。您可以使用 删除约会列表中的条目M-x appt-delete

You can also use the appointment notification facility like an alarm clock. The command M-x appt-add adds entries to the appointment list without affecting your diary file. You delete entries from the appointment list with M-x appt-delete.


32.10.7 导入和导出日记条目

32.10.7 Importing and Exporting Diary Entries

您可以在 Emacs 日记文件和各种其他格式之间传输日记条目。

You can transfer diary entries between Emacs diary files and a variety of other formats.

您可以从 Outlook 生成的约会消息导入日记条目。在 Rmail 或 Gnus 中查看此类消息时,请M-x diary-from-outlook导入该条目。您可以通过自定义变量使该命令识别其他约会消息格式diary-outlook-formats。其他邮件客户端可以设置 diary-from-outlook-function为适当的值。

You can import diary entries from Outlook-generated appointment messages. While viewing such a message in Rmail or Gnus, do M-x diary-from-outlook to import the entry. You can make this command recognize additional appointment message formats by customizing the variable diary-outlook-formats. Other mail clients can set diary-from-outlook-function to an appropriate value.

icalendar 包允许您在 Emacs 日记文件和 iCalendar 文件之间传输数据,这些文件在RFC 2445 — Internet 日历和计划核心对象规范 (iCalendar)(以及早期的 vCalendar 格式) 中定义。

The icalendar package allows you to transfer data between your Emacs diary file and iCalendar files, which are defined in RFC 2445—Internet Calendaring and Scheduling Core Object Specification (iCalendar) (as well as the earlier vCalendar format).

该命令icalendar-import-buffer从当前缓冲区中提取 iCalendar 数据并将其添加到您的日记文件中。该功能也适用于iCalendar数据的自动提取;例如,可以使用 Rmail 邮件客户端:

The command icalendar-import-buffer extracts iCalendar data from the current buffer and adds it to your diary file. This function is also suitable for automatic extraction of iCalendar data; for example with the Rmail mail client one could use:

(添加钩子'rmail-show-message-hook'icalendar-import-buffer)
(add-hook 'rmail-show-message-hook 'icalendar-import-buffer)

该命令icalendar-import-file导入 iCalendar 文件并将结果添加到 Emacs 日记文件中。例如:

The command icalendar-import-file imports an iCalendar file and adds the results to an Emacs diary file. For example:

(icalendar-导入文件“/此处/is/calendar.ics”
                       “/那里/去/ical-日记”)
(icalendar-import-file "/here/is/calendar.ics"
                       "/there/goes/ical-diary")

如果这些是不同的文件,您可以使用#include指令将导入文件内容添加到主日记文件中。请参阅精美日记显示

You can use an #include directive to add the import file contents to the main diary file, if these are different files. See Fancy Diary Display.

用于icalendar-export-file以交互方式将整个 Emacs 日记文件导出为 iCalendar 格式。要仅导出日记文件的一部分,请标记相关区域,然后调用icalendar-export-region.在这两种情况下,Emacs 都会将结果附加到目标文件中。

Use icalendar-export-file to interactively export an entire Emacs diary file to iCalendar format. To export only a part of a diary file, mark the relevant area, and call icalendar-export-region. In both cases, Emacs appends the result to the target file.


32.11 夏令时

32.11 Daylight Saving Time

Emacs 了解标准时间和夏令时之间的差异 - 给出的日出、日落、至日、春分和月相的时间都考虑到了这一点。夏令时的规则因地而异,而且每年也有不同的历史。为了正确完成这项工作,Emacs 需要知道要使用哪些规则。

Emacs understands the difference between standard time and daylight saving time—the times given for sunrise, sunset, solstices, equinoxes, and the phases of the moon take that into account. The rules for daylight saving time vary from place to place and have also varied historically from year to year. To do the job properly, Emacs needs to know which rules to use.

有些操作系统会记录适用于您所在位置的规则;在这些系统上,Emacs 自动从系统获取所需的信息。如果部分或全部信息丢失,Emacs 会使用马萨诸塞州剑桥当前使用的规则来填补空白。如果生成的规则不是您想要的,您可以通过设置某些变量来告诉 Emacs 要使用的规则: calendar-daylight-savings-startscalendar-daylight-savings-ends

Some operating systems keep track of the rules that apply to the place where you are; on these systems, Emacs gets the information it needs from the system automatically. If some or all of this information is missing, Emacs fills in the gaps with the rules currently used in Cambridge, Massachusetts. If the resulting rules are not what you want, you can tell Emacs the rules to use by setting certain variables: calendar-daylight-savings-starts and calendar-daylight-savings-ends.

这些值应该是引用变量 的 Lisp 表达式 year,并以列表的形式计算夏令时开始或(分别)结束的公历日期 。如果您所在的地区不使用夏令时,则 该值应为该值 。(month day year)nil

These values should be Lisp expressions that refer to the variable year, and evaluate to the Gregorian date on which daylight saving time starts or (respectively) ends, in the form of a list (month day year). The values should be nil if your area does not use daylight saving time.

Emacs 使用这些表达式来确定假日列表的夏令时的开始日期以及校正太阳和月亮计算中的时间。

Emacs uses these expressions to determine the starting date of daylight saving time for the holiday list and for correcting times of day in the solar and lunar calculations.

马萨诸塞州剑桥的值如下:

The values for Cambridge, Massachusetts are as follows:

(日历第 n 个命名日 2 0 3 年)
(日历-第 n 个命名日 1 0 11 年)
(calendar-nth-named-day 2 0 3 year)
(calendar-nth-named-day 1 0 11 year)

即 指定年份的第三个月(3 月)的第 2 个第 0 天(星期日)year,以及该年的 11 个月(11 月)的第一个星期日。如果夏令时更改为从 10 月 1 日开始,您将设置 calendar-daylight-savings-starts为:

That is, the second 0th day (Sunday) of the third month (March) in the year specified by year, and the first Sunday of the eleventh month (November) of that year. If daylight saving time were changed to start on October 1, you would set calendar-daylight-savings-starts to this:

(列出 10 1 年)
(list 10 1 year)

如果您所在的位置没有夏令时,或者您希望所有时间均为标准时间,请将calendar-daylight-savings-starts 和设置calendar-daylight-savings-endsnil

If there is no daylight saving time at your location, or if you want all times in standard time, set calendar-daylight-savings-starts and calendar-daylight-savings-ends to nil.

该变量calendar-daylight-time-offset指定夏令时和标准时间之间的差异(以分钟为单位)。马萨诸塞州剑桥的值为 60。

The variable calendar-daylight-time-offset specifies the difference between daylight saving time and standard time, measured in minutes. The value for Cambridge, Massachusetts is 60.

最后,这两个变量 calendar-daylight-savings-starts-time指定 calendar-daylight-savings-ends-time当地时间午夜之后应发生夏令时和夏令时之间转换的分钟数。对于马萨诸塞州剑桥,两个变量的值为 120。

Finally, the two variables calendar-daylight-savings-starts-time and calendar-daylight-savings-ends-time specify the number of minutes after midnight local time when the transition to and from daylight saving time should occur. For Cambridge, Massachusetts both variables’ values are 120.


32.12 求和时间间隔

32.12 Summing Time Intervals

timeclock 包添加了时间间隔,因此您可以(例如)跟踪您在特定项目上花费的时间。 (更高级的替代方法是使用组织模式的工具来计时,请参阅组织手册中的计时工作时间)。

The timeclock package adds up time intervals, so you can (for instance) keep track of how much time you spend working on particular projects. (A more advanced alternative is to use the Org Mode’s facilities for clocking time, see Clocking Work Time in The Org Manual).

M-x timeclock-in开始处理项目时使用命令,M-x timeclock-out完成项目后使用命令。每次执行此操作时,都会在项目记录中添加一个时间间隔。您可以更改为使用 来处理不同的项目M-x timeclock-change

Use the M-x timeclock-in command when you start working on a project, and M-x timeclock-out command when you’re done. Each time you do this, it adds one time interval to the record of the project. You can change to working on a different project with M-x timeclock-change.

一旦您收集了多个时间间隔的数据,您就可以 M-x timeclock-workday-remaining查看今天还剩多少时间可以工作(假设通常平均每天工作 8 小时),并M-x timeclock-when-to-leave计算您何时完成。

Once you’ve collected data from a number of time intervals, you can use M-x timeclock-workday-remaining to see how much time is left to work today (assuming a typical average of 8 hours a day), and M-x timeclock-when-to-leave which will calculate when you’re done.

如果您希望 Emacs 在模式行中显示工作日的剩余时间,请自定义该 timeclock-mode-line-display变量并将其值设置为 t,或者调用该M-x timeclock-mode-line-display命令。

If you want Emacs to display the amount of time left of your workday in the mode line, either customize the timeclock-mode-line-display variable and set its value to t, or invoke the M-x timeclock-mode-line-display command.

终止当前的 Emacs 会话可能意味着也可能不意味着您已停止处理该项目,默认情况下,Emacs 会询问您。但是,您可以自定义变量的值 timeclock-ask-before-exitingnil避免出现此问题;那么,只有显式的M-x timeclock-outorM-x timeclock-change才会告诉 Emacs 当前间隔已经结束。

Terminating the current Emacs session might or might not mean that you have stopped working on the project and, by default, Emacs asks you. You can, however, customize the value of the variable timeclock-ask-before-exiting to nil to avoid the question; then, only an explicit M-x timeclock-out or M-x timeclock-change will tell Emacs that the current interval is over.

时钟功能通过将数据累积到名为的文件中来工作〜/.emacs.d/timelog。您可以通过自定义变量为此文件指定不同的名称 timeclock-file。如果您手动编辑 timeclock 文件,或者更改 timeclock 的任何可自定义变量的值,则应运行命令M-x timeclock-reread-log以从文件更新 Emacs 中的数据。

The timeclock functions work by accumulating the data in a file called ~/.emacs.d/timelog. You can specify a different name for this file by customizing the variable timeclock-file. If you edit the timeclock file manually, or if you change the value of any of timeclock’s customizable variables, you should run the command M-x timeclock-reread-log to update the data in Emacs from the file.


32.13 日历和日记的更多高级功能

32.13 More advanced features of the Calendar and Diary

本节介绍日历和日记的一些更高级/专业的功能。首先,您可以通过多种方式自定义日历和日记,以满足您的个人品味。

This section describes some of the more advanced/specialized features of the calendar and diary. It starts with some of the many ways in which you can customize the calendar and diary to suit your personal tastes.


32.13.1 自定义日历

32.13.1 Customizing the Calendar

不幸的是,日历显示从三个月开始就无法更改,但您可以通过设置变量来自定义使用的空白:calendar-left-margincalendar-day-header-widthcalendar-day-digit-widthcalendar-column-widthcalendar-intermonth-spacing。要显示月份之间的文本(例如周数),请自定义变量calendar-intermonth-headercalendar-intermonth-text按照其文档中的说明进行操作。

The calendar display unfortunately cannot be changed from three months, but you can customize the whitespace used by setting the variables: calendar-left-margin, calendar-day-header-width, calendar-day-digit-width, calendar-column-width, and calendar-intermonth-spacing. To display text between the months, for example week numbers, customize the variables calendar-intermonth-header and calendar-intermonth-text as described in their documentation.

该变量calendar-month-header控制日历中每个月上方显示的文本。默认情况下,它显示月份和年份。该变量calendar-day-header-array 控制每月每天列上方显示的文本。默认情况下,它显示每天名称的前两个字母。

The variable calendar-month-header controls the text that appears above each month in the calendar. By default, it shows the month and year. The variable calendar-day-header-array controls the text that appears above each day’s column in every month. By default, it shows the first two letters of each day’s name.

该变量calendar-holiday-marker指定如何标记假日日期。它的值可以是插入日期旁边的单字符字符串,也可以是用于显示日期的面孔名称。同样,该变量diary-entry-marker指定如何标记具有日记条目的日期。该函数calendar-mark-today 用于calendar-today-marker标记今天的日期。默认情况下,日历使用名为holidaydiary和 的面来calendar-today实现这些目的。

The variable calendar-holiday-marker specifies how to mark a date that is a holiday. Its value may be a single-character string to insert next to the date, or a face name to use for displaying the date. Likewise, the variable diary-entry-marker specifies how to mark a date that has diary entries. The function calendar-mark-today uses calendar-today-marker to mark today’s date. By default, the calendar uses faces named holiday, diary, and calendar-today for these purposes.

启动日历运行正常的钩子 calendar-initial-window-hook。日历显示的重新计算不会运行此挂钩。但是,如果您将日历保留在 q命令中并重新输入,则挂钩会再次运行。

Starting the calendar runs the normal hook calendar-initial-window-hook. Recomputation of the calendar display does not run this hook. But if you leave the calendar with the q command and reenter it, the hook runs again.

当当前日期在窗口中可见时,该变量calendar-today-visible-hook是在日历缓冲区与日历一起准备之后运行的正常挂钩。这个钩子的用途之一是标记今天的日期;为此,请使用以下函数 calendar-mark-todaycalendar-star-date

The variable calendar-today-visible-hook is a normal hook run after the calendar buffer has been prepared with the calendar, when the current date is visible in the window. One use of this hook is to mark today’s date; to do that use either of the functions calendar-mark-today or calendar-star-date:

(添加钩子'日历-今天-可见-钩'日历-标记-今天)
(add-hook 'calendar-today-visible-hook 'calendar-mark-today)

calendar-today-invisible-hook如果当前日期在窗口中 可见,则会运行类似的正常挂钩。

A similar normal hook, calendar-today-invisible-hook is run if the current date is not visible in the window.

每个日历光标移动命令 calendar-move-hook在移动光标后都会运行挂钩。

Each of the calendar cursor motion commands runs the hook calendar-move-hook after it moves the cursor.


32.13.2 自定义假期

32.13.2 Customizing the Holidays

有几个变量列出了 Emacs 知道的默认假期。它们是:holiday-general-holidaysholiday-local-holidaysholiday-solar-holidaysholiday-bahai-holidaysholiday-christian-holidaysholiday-hebrew-holidaysholiday-islamic-holidaysholiday-oriental-holidaysholiday-other-holidays。名称应该是不言自明的;例如,holiday-solar-holidays 列出与太阳和月亮相关的假期。

There are several variables listing the default holidays that Emacs knows about. These are: holiday-general-holidays, holiday-local-holidays, holiday-solar-holidays, holiday-bahai-holidays, holiday-christian-holidays, holiday-hebrew-holidays, holiday-islamic-holidays, holiday-oriental-holidays, and holiday-other-holidays. The names should be self-explanatory; e.g., holiday-solar-holidays lists sun- and moon-related holidays.

您可以根据自己的需要自定义这些假期列表,删除或添加假期,如下所述。将它们中的任何一个设置为nil不显示相关的假期。

You can customize these lists of holidays to your own needs, deleting or adding holidays as described below. Set any of them to nil to not show the associated holidays.

默认情况下,公众假期是美国各地的公共假期。相反,holiday-local-holidaysholiday-other-holidays都默认为空。这些分别用于系统范围的设置和您的个人使用。

The general holidays are, by default, holidays common throughout the United States. In contrast, holiday-local-holidays and holiday-other-holidays are both empty by default. These are intended for system-wide settings and your individual use, respectively.

默认情况下,Emacs 不包括它所知道的所有宗教节日,仅包括世俗日历中常见的节日。对于更广泛的宗教节日集合,您可以将任意(或全部)变量calendar-bahai-all-holidays-flagcalendar-christian-all-holidays-flagcalendar-hebrew-all-holidays-flagcalendar-islamic-all-holidays-flagto设置t

By default, Emacs does not include all the holidays of the religions that it knows, only those commonly found in secular calendars. For a more extensive collection of religious holidays, you can set any (or all) of the variables calendar-bahai-all-holidays-flag, calendar-christian-all-holidays-flag, calendar-hebrew-all-holidays-flag, or calendar-islamic-all-holidays-flag to t.

每个假期变量都是一个假期表单列表,每个表单描述一个假期(或者有时是一个假期列表)。这是可能的假期形式的表格。天数和月数从 1 开始计数,但日名数字将星期日计为 0。参数字符串始终是假日的描述(作为字符串)。

Each of the holiday variables is a list of holiday forms, each form describing a holiday (or sometimes a list of holidays). Here is a table of the possible kinds of holiday form. Day numbers and month numbers count starting from 1, but dayname numbers count Sunday as 0. The argument string is always the description of the holiday, as a string.

(holiday-fixed month day string)
(holiday-fixed month day string)

公历上的固定日期。

A fixed date on the Gregorian calendar.

(holiday-float month dayname k string
(holiday-float month dayname k string

&可选day )在公历日期MonthDay之前或之后的第k 个日期名称dayname =0 表示星期日,依此类推)。负k 表示从月底开始倒数。如果k为正数,可选日期默认为 1 ,否则为每月的最后一天。

&optional day) The kth dayname (dayname=0 for Sunday, and so on) after or before Gregorian date month, day. Negative k means count back from the end of the month. Optional day defaults to 1 if k is positive, and the last day of month otherwise.

(holiday-chinese month day string)
(holiday-chinese month day string)

中国日历上的固定日期。

A fixed date on the Chinese calendar.

(holiday-hebrew month day string)
(holiday-hebrew month day string)

希伯来历上的固定日期。

A fixed date on the Hebrew calendar.

(holiday-islamic month day string)
(holiday-islamic month day string)

伊斯兰历上的固定日期。

A fixed date on the Islamic calendar.

(holiday-julian month day string)
(holiday-julian month day string)

儒略历上的固定日期。

A fixed date on the Julian calendar.

(holiday-sexp sexp string)
(holiday-sexp sexp string)

由 Lisp 表达式sexp计算的日期。表达式应使用变量year来计算并以 list 的形式返回假期的日期,或者如果今年没有假期。 (month day year)nil

A date calculated by the Lisp expression sexp. The expression should use the variable year to compute and return the date of a holiday in the form of a list (month day year), or nil if the holiday doesn’t happen this year.

(if condition holiday-form)
(if condition holiday-form)

仅当条件为真 时才会发生的假期。

A holiday that happens only if condition is true.

(function [args])
(function [args])

由函数function计算的日期列表,使用参数args调用。

A list of dates calculated by the function function, called with arguments args.

例如,假设您要添加法国于 7 月 14 日(即七月十四日)庆祝的巴士底日。您可以按如下方式执行此操作:

For example, suppose you want to add Bastille Day, celebrated in France on July 14 (i.e., the fourteenth day of the seventh month). You can do this as follows:

(setq 假期-其他-假期 '((假期固定 7 14“巴士底日”)))
(setq holiday-other-holidays '((holiday-fixed 7 14 "Bastille Day")))

许多假期发生在一周中的特定一天、每月的特定时间。以下是描述飓风祈求日的节日表格,该日在维尔京群岛于七月的第四个星期一庆祝:

Many holidays occur on a specific day of the week, at a specific time of month. Here is a holiday form describing Hurricane Supplication Day, celebrated in the Virgin Islands on the fourth Monday in July:

(holiday-float 7 1 4“飓风祈求日”)
(holiday-float 7 1 4 "Hurricane Supplication Day")

这里 7 指定七月,1 指定星期一(星期日为 0,星期二为 2,依此类推),4 指定该月中的第四次出现(1 指定第一次出现,2 指定第二次出现,-1 指定最后一次出现)出现,-2 倒数第二次出现,依此类推)。

Here the 7 specifies July, the 1 specifies Monday (Sunday is 0, Tuesday is 2, and so on), and the 4 specifies the fourth occurrence in the month (1 specifies the first occurrence, 2 the second occurrence, −1 the last occurrence, −2 the second-to-last occurrence, and so on).

您也可以指定巴哈伊历、中国历、希伯来历、伊斯兰教历和儒略历的固定日期发生的假期。例如,

You can specify holidays that occur on fixed days of the Bahá’í, Chinese, Hebrew, Islamic, and Julian calendars too. For example,

(setq 假期-其他-假期
      '((holiday-hebrew 10 2“光明节的最后一天”)
        (伊斯兰节日 3 月 12 日“穆罕默德诞辰”)
        (假日朱利安 4 2“杰斐逊生日”)))
(setq holiday-other-holidays
      '((holiday-hebrew 10 2 "Last day of Hanukkah")
        (holiday-islamic 3 12 "Mohammed's Birthday")
        (holiday-julian 4 2 "Jefferson's Birthday")))

添加光明节的最后一天(因为希伯来月份从尼散月开始编号为 1)、庆祝穆罕默德生日的伊斯兰节日(因为伊斯兰月份从穆哈拉姆开始编号)以及托马斯·杰斐逊的生日(1743 年 4 月 2 日)在儒略历上。

adds the last day of Hanukkah (since the Hebrew months are numbered with 1 starting from Nisan), the Islamic feast celebrating Mohammed’s birthday (since the Islamic months are numbered from 1 starting with Muharram), and Thomas Jefferson’s birthday, which is 2 April 1743 on the Julian calendar.

要有条件地包含假日,请使用 Emacs Lispifholiday-sexp表单。例如,美国总统选举发生在可被 4 整除的年份中 11 月第一个星期一之后的第一个星期二:

To include a holiday conditionally, use either Emacs Lisp’s if or the holiday-sexp form. For example, American presidential elections occur on the first Tuesday after the first Monday in November of years divisible by 4:

(holiday-sexp '(if (zerop (% 第 4 年))
                   (日历公历从绝对
                    (1+ (日历日期名称日期或之前
                          1 (+ 6 (日历-绝对公历
                                  (列出 11 1 年)))))))
              《美国总统选举》)
(holiday-sexp '(if (zerop (% year 4))
                   (calendar-gregorian-from-absolute
                    (1+ (calendar-dayname-on-or-before
                          1 (+ 6 (calendar-absolute-from-gregorian
                                  (list 11 1 year)))))))
              "US Presidential Election")

或者

or

(if (zerop (% 显示-第 4 年))
    (节假日固定 11
           (日历-提取-日
             (日历公历从绝对
               (1+ (日历日期名称日期或之前
                     1 (+ 6 (日历-绝对公历
                              (列表 11 1 显示-年份)))))))
           “美国总统选举”))
(if (zerop (% displayed-year 4))
    (holiday-fixed 11
           (calendar-extract-day
             (calendar-gregorian-from-absolute
               (1+ (calendar-dayname-on-or-before
                     1 (+ 6 (calendar-absolute-from-gregorian
                              (list 11 1 displayed-year)))))))
           "US Presidential Election"))

有些假期不适合任何这些形式,因为它们的确定涉及特殊的计算。在这种情况下,您必须编写一个 Lisp 函数来进行计算。例如,要包含日食,请添加(eclipses)holiday-other-holidays 编写一个 Emacs Lisp 函数eclipses,该函数返回日历窗口中可见范围内的相关公历日期(可能为空)列表,并带有描述性字符串,如下所示:

Some holidays just don’t fit into any of these forms because special calculations are involved in their determination. In such cases you must write a Lisp function to do the calculation. To include eclipses, for example, add (eclipses) to holiday-other-holidays and write an Emacs Lisp function eclipses that returns a (possibly empty) list of the relevant Gregorian dates among the range visible in the calendar window, with descriptive strings, like this:

(((2012年6月4日)“月食”)((2012年11月13日)“日食”)...)
(((6 4 2012) "Lunar Eclipse") ((11 13 2012) "Solar Eclipse") ... )

32.13.3 从玛雅历法转换

32.13.3 Converting from the Mayan Calendar

以下是根据玛雅日历选择日期的命令:

Here are the commands to select dates based on the Mayan calendar:

g m l
g m l

移至长计数日历 ( ) 指定的日期calendar-mayan-goto-long-count-date

Move to a date specified by the long count calendar (calendar-mayan-goto-long-count-date).

g m n t
g m n t

移至 tzolkin 日历中下一个出现的地点 ( calendar-mayan-next-tzolkin-date)。

Move to the next occurrence of a place in the tzolkin calendar (calendar-mayan-next-tzolkin-date).

g m p t
g m p t

移至 tzolkin 日历中上一个出现的地点 ( calendar-mayan-previous-tzolkin-date)。

Move to the previous occurrence of a place in the tzolkin calendar (calendar-mayan-previous-tzolkin-date).

g m n h
g m n h

移至 haab 日历中下一个出现的地点 ( calendar-mayan-next-haab-date)。

Move to the next occurrence of a place in the haab calendar (calendar-mayan-next-haab-date).

g m p h
g m p h

移至 haab 日历中某个地点的上一个出现位置 ( calendar-mayan-previous-haab-date)。

Move to the previous occurrence of a place in the haab calendar (calendar-mayan-previous-haab-date).

g m n c
g m n c

移至日历轮中下一个出现的位置 ( calendar-mayan-next-calendar-round-date)。

Move to the next occurrence of a place in the calendar round (calendar-mayan-next-calendar-round-date).

g m p c
g m p c

移至日历轮中上一个出现的位置 ( calendar-mayan-previous-calendar-round-date)。

Move to the previous occurrence of a place in the calendar round (calendar-mayan-previous-calendar-round-date).

要理解这些命令,您需要了解玛雅历法。长计数是使用这些单位的天数计数:

To understand these commands, you need to understand the Mayan calendars. The long count is a counting of days with these units:

1 kin = 1 天 1 uinal = 20 kin 1 tun = 18 uinal
1 katun = 20 tun 1 baktun = 20 katun
1 kin = 1 day   1 uinal = 20 kin   1 tun = 18 uinal
1 katun = 20 tun   1 baktun = 20 katun

因此,长计数日期 12.16.11.16.6 意味着 12 baktun、16 katun、11 tun、16 uinal 和 6 kin。 Emacs 日历可以处理早于 7.17.18.13.3 的玛雅长计数日期,但不能处理更早的日期。使用该 g m l命令时,请键入玛雅长计数日期,其中 baktun、katun、tun、uinal 和 kin 以句点分隔。

Thus, the long count date 12.16.11.16.6 means 12 baktun, 16 katun, 11 tun, 16 uinal, and 6 kin. The Emacs calendar can handle Mayan long count dates as early as 7.17.18.13.3, but no earlier. When you use the g m l command, type the Mayan long count date with the baktun, katun, tun, uinal, and kin separated by periods.

玛雅卓尔金历是一个260天的周期,由一对独立的13天和20天周期组成。由于这个循环无限重复,Emacs 提供了命令来向后和向前移动到循环中的上一个或下一个点。键入g m p t以转到上一个 tzolkin 日期; Emacs 要求您提供 tzolkin 日期,并将指向该日期的上一个出现位置。同样,键入g m n t 可转到下一个出现的 tzolkin 日期。

The Mayan tzolkin calendar is a cycle of 260 days formed by a pair of independent cycles of 13 and 20 days. Since this cycle repeats endlessly, Emacs provides commands to move backward and forward to the previous or next point in the cycle. Type g m p t to go to the previous tzolkin date; Emacs asks you for a tzolkin date and moves point to the previous occurrence of that date. Similarly, type g m n t to go to the next occurrence of a tzolkin date.

玛雅哈布历以 365 天为一个周期,分为 18 个月,每月 20 天,随后是 5 天的无月期。与 tzolkin 循环一样,此循环无限重复,并且有命令向后和向前移动到循环中的上一个或下一个点。输入 g m p h以转到上一个 Haab 日期; Emacs 要求您输入 haab 日期并将指针移至该日期的上一个出现位置。同样,键入g m n h可转到下一个出现的 haab 日期。

The Mayan haab calendar is a cycle of 365 days arranged as 18 months of 20 days each, followed by a 5-day monthless period. Like the tzolkin cycle, this cycle repeats endlessly, and there are commands to move backward and forward to the previous or next point in the cycle. Type g m p h to go to the previous haab date; Emacs asks you for a haab date and moves point to the previous occurrence of that date. Similarly, type g m n h to go to the next occurrence of a haab date.

玛雅人还使用了卓尔金日期和哈布日期的组合。这种组合大约以52年为一个周期,称为一个 日历轮。如果您输入g m p c,Emacs 会要求您输入 haab 和 tzolkin 日期,然后将指针移动到该组合的上一个出现位置。用于g m n c将点移动到下一个出现的组合。如果您输入的 haab/tzolkin 日期组合不可能,这些命令会发出错误信号。

The Maya also used the combination of the tzolkin date and the haab date. This combination is a cycle of about 52 years called a calendar round. If you type g m p c, Emacs asks you for both a haab and a tzolkin date and then moves point to the previous occurrence of that combination. Use g m n c to move point to the next occurrence of a combination. These commands signal an error if the haab/tzolkin date combination you have typed is impossible.

每当Emacs 要求您输入玛雅名称时,它都会使用严格的完成(请参阅完成退出),因此您不必担心拼写问题。

Emacs uses strict completion (see Completion Exit) whenever it asks you to type a Mayan name, so you don’t have to worry about spelling.


32.13.4 日期显示格式

32.13.4 Date Display Format

您可以通过设置自定义日期在日记、模式行和消息中的显示方式calendar-date-display-form。该变量保存一个表达式列表,这些表达式可以涉及变量 monthdayyear,它们都是字符串形式的数字,以及monthnamedayname,它们都是字母字符串。在美式风格中,该列表的默认值如下:

You can customize the way dates are displayed in the diary, mode lines, and messages by setting calendar-date-display-form. This variable holds a list of expressions that can involve the variables month, day, and year, which are all numbers in string form, and monthname and dayname, which are both alphabetic strings. In the American style, the default value of this list is as follows:

((if dayname (concat dayname ", ")) Monthname " " 日 ", " 年)
((if dayname (concat dayname ", ")) monthname " " day ", " year)

而在欧洲风格中,该值是默认值:

while in the European style this value is the default:

((if dayname (concat dayname ", ")) 日 " " 月名 " " 年)
((if dayname (concat dayname ", ")) day " " monthname " " year)

默认 ISO 日期表示形式为:

The default ISO date representation is:

((格式“%s-%.2d-%.2d”年(字符串到数字月份)
         (字符串到数字日期)))
((format "%s-%.2d-%.2d" year (string-to-number month)
         (string-to-number day)))

另一种典型的美式格式是:

Another typical American format is:

(月“/”日“/”(子字符串年-2))
(month "/" day "/" (substring year -2))

32.13.5 时间显示格式

32.13.5 Time Display Format

默认情况下,日历和日记以传统美式风格显示一天中的时间,包括从 1 到 12 的小时、分钟以及“' 或者 '下午'。如果您更喜欢欧洲风格(在美国也称为军用风格),其中时间从 00 点到 23 点,您可以更改变量calendar-time-display-form。该变量是一个表达式列表,可以涉及变量 12-hours24-hoursminutes,它们都是字符串形式的数字,以及am-pmtime-zone,它们都是字母字符串。默认值为:

The calendar and diary by default display times of day in the conventional American style with the hours from 1 through 12, minutes, and either ‘am’ or ‘pm’. If you prefer the European style, also known in the US as military, in which the hours go from 00 to 23, you can alter the variable calendar-time-display-form. This variable is a list of expressions that can involve the variables 12-hours, 24-hours, and minutes, which are all numbers in string form, and am-pm and time-zone, which are both alphabetic strings. The default value is:

(上午至下午 12 小时“:”分钟
          (如果时区“(”)时区(如果时区“)”))
(12-hours ":" minutes am-pm
          (if time-zone " (") time-zone (if time-zone ")"))

这是提供欧洲风格时间的值:

Here is a value that provides European style times:

(24小时“:”分钟
          (如果时区“(”)时区(如果时区“)”))
(24-hours ":" minutes
          (if time-zone " (") time-zone (if time-zone ")"))

请注意,很少有日历函数返回一天中的时间(目前,只有太阳函数)。

Note that few calendar functions return a time of day (at present, only solar functions).


32.13.6 自定义日记

32.13.6 Customizing the Diary

通常,日记窗口会在模式行或缓冲区本身中指示日记条目日期的任何假期。检查假期的过程可能会很慢,具体取决于定义的假期。在这种情况下,设置diary-show-holidays-flagnil将加快日记显示速度。

Ordinarily, the diary window indicates any holidays that fall on the date of the diary entries, either in the mode line or the buffer itself. The process of checking for holidays can be slow, depending on the defined holidays. In that case, setting diary-show-holidays-flag to nil will speed up the diary display.

该变量diary-number-of-entries控制一次显示日记条目的天数。它会影响初始显示calendar-view-diary-initially-flag以及 t命令M-x diary。例如,值 1(默认值)仅显示当天的日记条目,而值 2 还将显示第二天的条目。该值也可以是七个整数的向量:例如,如果该值为 , [0 2 2 2 2 4 1]则周日不会出现日记条目,周一到周四会出现当前日期和第二天的日记条目,周五到周一的条目会在周五出现,而周六仅显示当天的条目。

The variable diary-number-of-entries controls the number of days of diary entries to be displayed at one time. It affects the initial display when calendar-view-diary-initially-flag is t, as well as the command M-x diary. For example, a value of 1 (the default) displays only the current day’s diary entries, whereas a value of 2 will also show the next day’s entries. The value can also be a vector of seven integers: for example, if the value is [0 2 2 2 2 4 1] then no diary entries appear on Sunday, the current date’s and the next day’s diary entries appear Monday through Thursday, Friday through Monday’s entries appear on Friday, while on Saturday only that day’s entries appear.

您可以通过设置变量来自定义日记文件中日期的形式diary-date-forms。该变量是用于识别日期的模式列表。每个日期模式都是一个列表,其元素可以是正则表达式(请参阅Emacs Lisp 参考手册中的正则表达式)或符号、、 、和。所有这些元素都充当与日记文件中某些类型的文本相匹配的模式。为了使日期模式作为一个整体匹配,其所有元素必须连续匹配。 monthdayyearmonthnamedayname

You can customize the form of dates in your diary file by setting the variable diary-date-forms. This variable is a list of patterns for recognizing a date. Each date pattern is a list whose elements may be regular expressions (see Regular Expressions in the Emacs Lisp Reference Manual) or the symbols month, day, year, monthname, and dayname. All these elements serve as patterns that match certain kinds of text in the diary file. In order for the date pattern as a whole to match, all of its elements must match consecutively.

日期模式中的正则表达式以通常的方式匹配,使用更改后的标准语法表,以便 '*' 是一个词的组成部分。

A regular expression in a date pattern matches in its usual fashion, using the standard syntax table altered so that ‘*’ is a word constituent.

符号monthdayyearmonthname和 与dayname所考虑日期的月数、日数、年数、月份名称和日期名称相匹配。与数字匹配的符号允许前导零;那些与名称匹配的允许大写和缩写(由 calendar-month-abbrev-array和 指定calendar-day-abbrev-array)。所有符号都可以匹配 '*';自从 '*' 在日记条目中表示“任何一天”、“任何月份”等,无论考虑的日期如何,它都应该匹配。

The symbols month, day, year, monthname, and dayname match the month number, day number, year number, month name, and day name of the date being considered. The symbols that match numbers allow leading zeros; those that match names allow capitalization and abbreviation (as specified by calendar-month-abbrev-array and calendar-day-abbrev-array). All the symbols can match ‘*’; since ‘*’ in a diary entry means “any day”, “any month”, and so on, it should match regardless of the date being considered.

美式风格中的默认值diary-date-forms由以下提供diary-american-date-forms

The default value of diary-date-forms in the American style is provided by diary-american-date-forms:

((月“/”日“[^/0-9]”)
 (月“/”日“/”年“[^0-9]”)
 (月名“*”日“[^,0-9]”)
 (月名“*”日“,*”年“[^0-9]”)
 (日名“\\W”))
((month "/" day "[^/0-9]")
 (month "/" day "/" year "[^0-9]")
 (monthname " *" day "[^,0-9]")
 (monthname " *" day ", *" year "[^0-9]")
 (dayname "\\W"))

变量diary-european-date-formsdiary-iso-date-forms提供其他默认样式。

The variables diary-european-date-forms and diary-iso-date-forms provide other default styles.

列表中的日期模式必须是互斥的,并且不能与日记条目本身的任何部分匹配,只能匹配日期和一个空格字符。如果为了互斥,模式必须匹配日记条目文本的一部分(超出日期结束的空格),则日期模式的第一个元素 必须backup。这会导致日期识别器在完成匹配后备份到日记条目当前单词的开头。即使您使用backup,日期模式也绝对不能匹配日记条目第一个单词的一部分。例如,默认值为 diary-european-date-forms

The date patterns in the list must be mutually exclusive and must not match any portion of the diary entry itself, just the date and one character of whitespace. If, to be mutually exclusive, the pattern must match a portion of the diary entry text—beyond the whitespace that ends the date—then the first element of the date pattern must be backup. This causes the date recognizer to back up to the beginning of the current word of the diary entry, after finishing the match. Even if you use backup, the date pattern must absolutely not match more than a portion of the first word of the diary entry. For example, the default value of diary-european-date-forms is:

((日“/”月“[^/0-9]”)
 (日“/”月“/”年“[^0-9]”)
 (备份日“*”月名“\\W+\\<\\([^*0-9]\\|\\([0-9]+[:aApP]\\)\\)”)
 (日“*”月名“*”年“[^0-9]”)
 (日名“\\W”))
((day "/" month "[^/0-9]")
 (day "/" month "/" year "[^0-9]")
 (backup day " *" monthname "\\W+\\<\\([^*0-9]\\|\\([0-9]+[:aApP]\\)\\)")
 (day " *" monthname " *" year "[^0-9]")
 (dayname "\\W"))

请注意第三个模式中的使用backup,因为它需要匹配日期本身之外的单词的一部分,以将其与第四个模式区分开来。

Notice the use of backup in the third pattern, because it needs to match part of a word beyond the date itself to distinguish it from the fourth pattern.


32.13.7 使用非公历的日记条目

32.13.7 Diary Entries Using non-Gregorian Calendars

除了基于标准公历的条目外,您的日记还可以包含基于巴哈伊、中国、希伯来或伊斯兰日期的条目。然而,识别此类条目可能非常耗时,并且由于大多数人不使用它们,因此您必须明确启用它们的使用。例如,如果您希望日记能够识别希伯来语日期的日记条目,则必须执行以下操作:

As well as entries based on the standard Gregorian calendar, your diary can have entries based on Bahá’í, Chinese, Hebrew, or Islamic dates. Recognition of such entries can be time-consuming, however, and since most people don’t use them, you must explicitly enable their use. If you want the diary to recognize Hebrew-date diary entries, for example, you must do this:

(添加钩子“日记-nongregorian-列表钩子”日记希伯来语列表条目)
(添加钩子“日记-nongregorian-标记钩子”日记希伯来语标记条目)
(add-hook 'diary-nongregorian-listing-hook 'diary-hebrew-list-entries)
(add-hook 'diary-nongregorian-marking-hook 'diary-hebrew-mark-entries)

同样,对于伊斯兰教、巴哈伊教和中文条目,添加 diary-islamic-list-entriesand diary-islamic-mark-entriesdiary-bahai-list-entriesand diary-bahai-mark-entries、 or diary-chinese-list-entriesand diary-chinese-mark-entries

Similarly, for Islamic, Bahá’í and Chinese entries, add diary-islamic-list-entries and diary-islamic-mark-entries, diary-bahai-list-entries and diary-bahai-mark-entries, or diary-chinese-list-entries and diary-chinese-mark-entries.

这些日记条目与公历日期日记条目具有相同的格式;除了diary-bahai-entry-symbol(默认'') 必须先于巴哈伊日期,diary-chinese-entry-symbol(默认 'C') 一个中文日期,diary-hebrew-entry-symbol(默认'H') 希伯来语日期,以及diary-islamic-entry-symbol(默认 '') 伊斯兰日期。此外,非公历月份名称可能不会缩写(因为前三个字母通常不是唯一的)。 (另请注意,如果您想要通用希伯来年份的 Adar,则必须使用“Adar I”。)例如,希伯来日期 Heshvan 25 的日记条目可能如下所示:

These diary entries have the same formats as Gregorian-date diary entries; except that diary-bahai-entry-symbol (default ‘B’) must precede a Bahá’í date, diary-chinese-entry-symbol (default ‘C’) a Chinese date, diary-hebrew-entry-symbol (default ‘H’) a Hebrew date, and diary-islamic-entry-symbol (default ‘I’) an Islamic date. Moreover, non-Gregorian month names may not be abbreviated (because the first three letters are often not unique). (Note also that you must use “Adar I” if you want Adar of a common Hebrew year.) For example, a diary entry for the Hebrew date Heshvan 25 could look like this:

HHeshvan 25 希伯来语生日快乐!
HHeshvan 25 Happy Hebrew birthday!

并且会出现在日记中对应于希伯来历 Heshvan 25 的任何日期。这是与 Dhu al-Qada 25 相匹配的伊斯兰日期日记条目:

and would appear in the diary for any date that corresponds to Heshvan 25 on the Hebrew calendar. And here is an Islamic-date diary entry that matches Dhu al-Qada 25:

IDhu al-Qada 25 岁伊斯兰生日快乐!
IDhu al-Qada 25 Happy Islamic birthday!

与公历日期日记条目一样,如果前面带有diary-nonmarking-symbol(默认 '&')。

As with Gregorian-date diary entries, non-Gregorian entries are nonmarking if preceded by diary-nonmarking-symbol (default ‘&’).

以下是日历中使用的命令表,用于创建与所选日期以及巴哈伊历、中国历、希伯来历或伊斯兰历中类似的其他日期相匹配的日记条目:

Here is a table of commands used in the calendar to create diary entries that match the selected date and other dates that are similar in the Bahá’í, Chinese, Hebrew, or Islamic calendars:

i h d
i h d

diary-hebrew-insert-entry

diary-hebrew-insert-entry

i h m
i h m

diary-hebrew-insert-monthly-entry

diary-hebrew-insert-monthly-entry

i h y
i h y

diary-hebrew-insert-yearly-entry

diary-hebrew-insert-yearly-entry

i i d
i i d

diary-islamic-insert-entry

diary-islamic-insert-entry

i i m
i i m

diary-islamic-insert-monthly-entry

diary-islamic-insert-monthly-entry

i i y
i i y

diary-islamic-insert-yearly-entry

diary-islamic-insert-yearly-entry

i B d
i B d

diary-bahai-insert-entry

diary-bahai-insert-entry

i B m
i B m

diary-bahai-insert-monthly-entry

diary-bahai-insert-monthly-entry

i B y
i B y

diary-bahai-insert-yearly-entry

diary-bahai-insert-yearly-entry

i C d
i C d

diary-chinese-insert-entry

diary-chinese-insert-entry

i C m
i C m

diary-chinese-insert-monthly-entry

diary-chinese-insert-monthly-entry

i C y
i C y

diary-chinese-insert-yearly-entry

diary-chinese-insert-yearly-entry

i C a
i C a

diary-chinese-insert-anniversary-entry

diary-chinese-insert-anniversary-entry

这些命令的工作方式与普通日记条目的相应命令非常相似:它们适用于日历窗口中该点所在的日期,并且它们所做的只是将日记条目的日期部分插入日记文件的末尾。然后您必须插入日记条目的其余部分。基本命令添加特定非公历日期的条目,即 '每月' 每个月中给定的非公历月内日的命令,以及 '每年' 每年给定非公历日期和月份的命令。

These commands work much like the corresponding commands for ordinary diary entries: they apply to the date that point is on in the calendar window, and what they do is insert just the date portion of a diary entry at the end of your diary file. You must then insert the rest of the diary entry. The basic commands add an entry for the specific non-Gregorian date, the ‘monthly’ commands for the given non-Gregorian day-within-month in every month, and the ‘yearly’ commands for the given non-Gregorian day and month in every year.


32.13.8 日记显示

32.13.8 Diary Display

日记显示的工作原理是准备日记条目列表,然后运行变量指定的函数 diary-display-function。默认值 diary-fancy-display通过将日记条目和假期复制到仅用于显示目的的特殊缓冲区来显示它们。将日记条目复制到单独的缓冲区提供了更改显示文本以使其更漂亮的机会,例如,按条目适用的日期对条目进行排序。

Diary display works by preparing the list of diary entries and then running the function specified by the variable diary-display-function. The default value diary-fancy-display displays diary entries and holidays by copying them into a special buffer that exists only for the sake of display. Copying diary entries to a separate buffer provides an opportunity to change the displayed text to make it prettier—for example, to sort the entries by the dates they apply to.

通常,精美的日记缓冲区不会显示没有日记条目的日子,即使那天是假期。如果您希望这些日子显示在精美日记缓冲区中,请将变量设置 diary-list-include-blankst

Ordinarily, the fancy diary buffer does not show days for which there are no diary entries, even if that day is a holiday. If you want such days to be shown in the fancy diary buffer, set the variable diary-list-include-blanks to t.

精美的日记缓冲区启用查看模式(请参阅查看模式)。

The fancy diary buffer enables View mode (see View Mode).

另一种显示方法diary-simple-display显示实际的日记缓冲区,并使用不可见文本隐藏不适用的条目。假期显示在模式行中。这种方法的优点是您可以编辑缓冲区并将更改直接保存到日记文件中。然而,这种方法不像花哨的方法那么灵活。例如,它无法对条目进行排序。另一个缺点是不可见的文本可能会令人困惑。例如,如果您复制文本区域以便将其粘贴到其他位置,则可能会包含不可见文本。同样,由于您所看到的日记缓冲区是一种幻觉,因此仅打印缓冲区可能无法打印您在屏幕上看到的内容。

The alternative display method diary-simple-display shows the actual diary buffer, and uses invisible text to hide entries that don’t apply. Holidays are shown in the mode line. The advantage of this method is that you can edit the buffer and save your changes directly to the diary file. This method is not as flexible as the fancy method, however. For example, it cannot sort entries. Another disadvantage is that invisible text can be confusing. For example, if you copy a region of text in order to paste it elsewhere, invisible text may be included. Similarly, since the diary buffer as you see it is an illusion, simply printing the buffer may not print what you see on your screen.

因此,有一个特殊的命令可以打印日记缓冲区的硬拷贝;这个命令是M-x diary-print-entries.它适用于任何一种显示方法,尽管使用精美的显示,您也可以像其他任何方法一样打印缓冲区。要打印一周的每日日记的硬拷贝,请将点定位在一周的第一天,键入7 d,然后执行M-x diary-print-entries。与往常一样,包含假期会稍微减慢显示速度;您可以通过将变量设置diary-show-holidays-flag为 来加快速度nil

For this reason, there is a special command to print hard copy of the diary buffer as it appears; this command is M-x diary-print-entries. It works with either display method, although with the fancy display you can also print the buffer like any other. To print a hard copy of a day-by-day diary for a week, position point on the first day of the week, type 7 d, and then do M-x diary-print-entries. As usual, the inclusion of the holidays slows down the display slightly; you can speed things up by setting the variable diary-show-holidays-flag to nil.

此命令准备一个临时缓冲区,其中仅包含日记缓冲区中当前可见的日记条目。与简单的显示不同,其他不相关的条目实际上不存在,而不仅仅是隐藏。准备好缓冲区后,它运行钩子 diary-print-entries-hook。该挂钩的默认值使用命令将数据直接发送到打印机lpr-buffer (请参阅打印硬拷贝)。如果您想使用不同的命令进行打印,只需更改此挂钩的值即可。其他用途可能包括,例如,按日期和时间重新排列线路。

This command prepares a temporary buffer that contains only the diary entries currently visible in the diary buffer. Unlike with the simple display, the other irrelevant entries are really absent, not just hidden. After preparing the buffer, it runs the hook diary-print-entries-hook. The default value of this hook sends the data directly to the printer with the command lpr-buffer (see Printing Hard Copies). If you want to use a different command to do the printing, just change the value of this hook. Other uses might include, for example, rearranging the lines into order by day and time.

您可以编辑简单日记窗口中显示的日记条目,但请务必记住,显示的缓冲区包含整个日记文件,其中部分内容隐藏在视图之外。例如,这意味着C-f ( forward-char) 命令可以将点放置在看似线的末尾的位置,但实际上是某些隐藏线的中间。

You can edit the diary entries as they appear in the simple diary window, but it is important to remember that the buffer displayed contains the entire diary file, with portions of it concealed from view. This means, for instance, that the C-f (forward-char) command can put point at what appears to be the end of the line, but what is in reality the middle of some concealed line.

在简单显示中编辑日记条目时要小心! 在可见行中间插入其他行或添加/删除字符不会导致问题,但在行尾进行编辑可能不会达到您的预期。删除一行可能会删除该行后面的其他不可见条目。在编辑简单日记缓冲区之前,最好用s ( diary-show-all-entries) 显示整个文件。

Be careful when editing the diary entries in the simple display! Inserting additional lines or adding/deleting characters in the middle of a visible line cannot cause problems, but editing at the end of a line may not do what you expect. Deleting a line may delete other invisible entries that follow it. Before editing the simple diary buffer, it is best to display the entire file with s (diary-show-all-entries).


32.13.9 精美日记展示

32.13.9 Fancy Diary Display

以下功能仅适用于精美的日记显示。

The following features only work with the fancy diary display.

您可以使用普通的钩子diary-list-entries-hook按一天中的时间对每天的日记条目进行排序。就是这样:

You can use the normal hook diary-list-entries-hook to sort each day’s diary entries by their time of day. Here’s how:

(add-hook 'diary-list-entries-hook 'diary-sort-entries t)
(add-hook 'diary-list-entries-hook 'diary-sort-entries t)

对于每一天,这都会根据时间对以一天中可识别时间开头的日记条目进行排序。没有时间的日记条目在每天中排在第一位。请注意排序命令如何放置在挂钩列表的末尾,以防列表中较早的成员更改日记条目的顺序或添加项目。

For each day, this sorts diary entries that begin with a recognizable time of day according to their times. Diary entries without times come first within each day. Note how the sort command is placed at the end of the hook list, in case earlier members of the list change the order of the diary entries, or add items.

你可以写 '评论' 在日记条目中,通过设置变量diary-comment-startdiary-comment-end分隔注释的字符串。精美的显示不打印注释。您可能希望将元数据放入注释内 以供其他包(例如,约会包,请参阅约会)使用。

You can write ‘comments’ in diary entries, by setting the variables diary-comment-start and diary-comment-end to strings that delimit comments. The fancy display does not print comments. You might want to put meta-data for the use of other packages (e.g., the appointment package, see Appointments) inside comments.

您的主日记文件可以包含其他文件。这允许一群人共享适用于他们所有人的事件的日记文件。日记文件中以以下内容开头的行diary-include-string

Your main diary file can include other files. This permits a group of people to share a diary file for events that apply to all of them. Lines in the diary file starting with diary-include-string:

#include“文件名
#include "filename"

将文件filename中的日记条目包含在精美日记缓冲区中。包含机制是递归的,因此包含的文件可以包含其他文件,依此类推(当然,必须注意不要出现循环包含)。以下是启用包含功能的方法:

include the diary entries from the file filename in the fancy diary buffer. The include mechanism is recursive, so that included files can include other files, and so on (you must be careful not to have a cycle of inclusions, of course). Here is how to enable the include facility:

(add-hook 'diary-list-entries-hook 'diary-include-other-diary-files)
(添加钩子“日记标记条目钩子”日记标记包含的日记文件)
(add-hook 'diary-list-entries-hook 'diary-include-other-diary-files)
(add-hook 'diary-mark-entries-hook 'diary-mark-included-diary-files)

包含机制仅适用于精美的日记显示,因为简单的日记显示直接显示日记文件中的条目。

The include mechanism works only with the fancy diary display, because simple diary display shows the entries directly from your diary file.


32.13.10 性爱条目和精美日记显示

32.13.10 Sexp Entries and the Fancy Diary Display

性爱日记条目允许您做的不仅仅是日记条目适用的复杂条件。 Sexp 条目前面应带有diary-sexp-entry-symbol(默认 '%%')在日记文件中。通过精美的日记显示,sexp 条目可以根据日期本身生成条目的文本。

Sexp diary entries allow you to do more than just have complicated conditions under which a diary entry applies. Sexp entries should be preceded by diary-sexp-entry-symbol (default ‘%%’) in the diary file. With the fancy diary display, sexp entries can generate the text of the entry depending on the date itself.

例如,周年纪念日记条目可以将自周年纪念日起的年数插入日记条目的文本中。就这样 '%d' 在这篇日记中:

For example, an anniversary diary entry can insert the number of years since the anniversary date into the text of the diary entry. Thus the ‘%d’ in this diary entry:

%%(diary-anniversary 10 31 1948) 亚瑟的生日(%d岁)
%%(diary-anniversary 10 31 1948) Arthur's birthday (%d years old)

被年龄取代,因此 1990 年 10 月 31 日,该条目出现在精美日记缓冲区中,如下所示:

gets replaced by the age, so on October 31, 1990 the entry appears in the fancy diary buffer like this:

亚瑟生日(42 岁)
Arthur's birthday (42 years old)

如果日记文件包含此条目:

If the diary file instead contains this entry:

%%(日记-周年纪念日 10 31 1948) 亚瑟的 %d%s 生日
%%(diary-anniversary 10 31 1948) Arthur's %d%s birthday

1990 年 10 月 31 日的精美日记缓冲区中的条目如下所示:

the entry in the fancy diary buffer for October 31, 1990 appears like this:

亚瑟 42 岁生日
Arthur's 42nd birthday

同样,循环日记条目可以插入已发生的重复次数:

Similarly, cyclic diary entries can interpolate the number of repetitions that have occurred:

%%(日记循环 50 1 1 2012) 更新药物(%d%s 次)
%%(diary-cyclic 50 1 1 2012) Renew medication (%d%s time)

看起来像这样:

looks like this:

更新药物(第5次)
Renew medication (5th time)

2012年9月7日的精美日记展示中。

in the fancy diary display on September 7, 2012.

有一个早期提醒日记 sexp,它不仅在日记中包含了发生日期的条目,还包含了更早日期的条目。例如,如果您想在周年纪念日前一周收到提醒,您可以使用

There is an early-reminder diary sexp that includes its entry in the diary not only on the date of occurrence, but also on earlier dates. For example, if you want a reminder a week before your anniversary, you can use

%%(diary-remind '(diary-anniversary 12 22 1968) 7) Ed 周年纪念日
%%(diary-remind '(diary-anniversary 12 22 1968) 7) Ed's anniversary

精美的日记将显示'艾德周年纪念日”分别在12月15日和12月22日。

and the fancy diary will show ‘Ed's anniversary’ both on December 15 and on December 22.

该函数diary-date适用于由月、日、年组合描述的日期,每个日期可以是整数、整数列表或t(表示所有值)。例如,

The function diary-date applies to dates described by a month, day, year combination, each of which can be an integer, a list of integers, or t (meaning all values). For example,

%%(diary-date '(10 11 12) 22 t) 耙叶
%%(diary-date '(10 11 12) 22 t) Rake leaves

导致精美日记显示

causes the fancy diary to show

耙树叶
Rake leaves

每年10月22日、11月22日、12月22日。

on October 22, November 22, and December 22 of every year.

该功能diary-float允许您描述适用于十一月第三个星期五或四月最后一个星期二等日期的日记条目。参数是月份日期名称和索引n。该条目出现在该月 第一天之后的第 ndayname上,其中dayname =0 表示星期日,1 表示星期一,依此类推。如果n为负数,则从月底开始倒数。月份的值可以是月份列表、单个月份或指定所有月份。您还可以使用可选参数day来指定每月某天或之后/之前的n名称;如果n为正数,则day的值 默认为 1 ;如果n为负数,则 day 的值默认为该的最后一天 。例如, t

The function diary-float allows you to describe diary entries that apply to dates like the third Friday of November, or the last Tuesday in April. The parameters are the month, dayname, and an index n. The entry appears on the nth dayname after the first day of month, where dayname=0 means Sunday, 1 means Monday, and so on. If n is negative it counts backward from the end of month. The value of month can be a list of months, a single month, or t to specify all months. You can also use an optional parameter day to specify the nth dayname on or after/before day of month; the value of day defaults to 1 if n is positive and to the last day of month if n is negative. For example,

%%(diary-float t 1 -1) 支付租金
%%(diary-float t 1 -1) Pay rent

导致精美日记显示

causes the fancy diary to show

交房租
Pay rent

每个月的最后一个星期一。

on the last Monday of every month.

sexp 日记条目的通用性使您可以指定可以通过算法描述的任何日记条目。 sexp 日记条目包含一个表达式,用于计算该条目是否适用于任何给定日期。如果其值为非- nil,则该条目适用于该日期;否则,它不会。表达式可以使用变量 date来查找正在考虑的日期;它的值是一个引用公历的 列表( 年)。

The generality of sexp diary entries lets you specify any diary entry that you can describe algorithmically. A sexp diary entry contains an expression that computes whether the entry applies to any given date. If its value is non-nil, the entry applies to that date; otherwise, it does not. The expression can use the variable date to find the date being considered; its value is a list (month day year) that refers to the Gregorian calendar.

sexp 日记条目适用于表达式的值为 non- 的日期nil,但某些值具有更具体的含义。如果该值是字符串,则该字符串是对该日期发生的事件的描述。该值还可以具有以下形式 :然后mark指定如何在日历中标记日期,string是事件的描述。如果mark是单字符字符串,则该字符将显示在日历中的日期旁边。如果标记是面名称,则日期将显示在该面中。如果mark为 ,则指定不特别突出显示日期。 (mark . string)nil

The sexp diary entry applies to a date when the expression’s value is non-nil, but some values have more specific meanings. If the value is a string, that string is a description of the event which occurs on that date. The value can also have the form (mark . string); then mark specifies how to mark the date in the calendar, and string is the description of the event. If mark is a single-character string, that character appears next to the date in the calendar. If mark is a face name, the date is displayed in that face. If mark is nil, that specifies no particular highlighting for the date.

假设您在该月的 21 号(如果是工作日)收到付款,如果 21 号是周末,则在之前的星期五收到付款。以下是如何编写与这些日期匹配的 sexp 日记条目:

Suppose you get paid on the 21st of the month if it is a weekday, and on the Friday before if the 21st is on a weekend. Here is how to write a sexp diary entry that matches those dates:

&%%(let ((日期名称(日历-星期几日期))
         (天(干部日期)))
      (或(和(=第21天)(memq日名'(1 2 3 4 5)))
          (和(memq 日 '(19 20)) (= 日名 5)))
         ) 支付支票存入
&%%(let ((dayname (calendar-day-of-week date))
         (day (cadr date)))
      (or (and (= day 21) (memq dayname '(1 2 3 4 5)))
          (and (memq day '(19 20)) (= dayname 5)))
         ) Pay check deposited

以下 sexp 日记条目利用(在精美日记显示中)的能力来编造日记条目,其文本根据日期而变化:

The following sexp diary entries take advantage of the ability (in the fancy diary display) to concoct diary entries whose text varies based on the date:

%%(diary-sunrise-sunset)
%%(diary-sunrise-sunset)

在日记中记录今天当地的日出和日落时间。

Make a diary entry for today’s local times of sunrise and sunset.

%%(diary-lunar-phases)
%%(diary-lunar-phases)

为月相(四分之一)写一篇日记。

Make a diary entry for the phases (quarters) of the moon.

%%(diary-day-of-year)
%%(diary-day-of-year)

用当年今天的天数和当年剩余的天数记下日记。

Make a diary entry with today’s day number in the current year and the number of days remaining in the current year.

%%(diary-iso-date)
%%(diary-iso-date)

用今天等效的 ISO 商业日期记入日记。

Make a diary entry with today’s equivalent ISO commercial date.

%%(diary-julian-date)
%%(diary-julian-date)

用今天对应的儒略历日期记录日记。

Make a diary entry with today’s equivalent Julian calendar date.

%%(diary-astro-day-number)
%%(diary-astro-day-number)

用今天的天文(儒略)日数记录日记。

Make a diary entry with today’s equivalent astronomical (Julian) day number.

%%(diary-bahai-date)
%%(diary-bahai-date)

在日记中注明今天的巴哈伊日历日期。

Make a diary entry with today’s equivalent Bahá’í calendar date.

%%(diary-chinese-date)
%%(diary-chinese-date)

用今天的相应农历日期写日记。

Make a diary entry with today’s equivalent Chinese calendar date.

%%(diary-coptic-date)
%%(diary-coptic-date)

在日记中记录今天的相应科普特日历日期。

Make a diary entry with today’s equivalent Coptic calendar date.

%%(diary-ethiopic-date)
%%(diary-ethiopic-date)

用今天对应的埃塞俄比亚日历日期记录日记。

Make a diary entry with today’s equivalent Ethiopic calendar date.

%%(diary-french-date)
%%(diary-french-date)

在日记中记录下法国大革命日历上今天的相应日期。

Make a diary entry with today’s equivalent date on the French Revolutionary calendar.

%%(diary-hebrew-date)
%%(diary-hebrew-date)

用今天对应的希伯来历日期记录日记。

Make a diary entry with today’s equivalent Hebrew calendar date.

%%(diary-islamic-date)
%%(diary-islamic-date)

在日记中记下今天的相应伊斯兰历日期。

Make a diary entry with today’s equivalent Islamic calendar date.

%%(diary-mayan-date)
%%(diary-mayan-date)

用今天对应的玛雅日历日期记下日记。

Make a diary entry with today’s equivalent Mayan calendar date.

%%(diary-persian-date)
%%(diary-persian-date)

用今天的波斯日历日期记下日记。

Make a diary entry with today’s equivalent Persian calendar date.

例如,包括日记条目

For example, including the diary entry

&%%(日记-希伯来语-日期)
&%%(diary-hebrew-date)

如果您使用精美的日记显示,则使每天的日记显示包含希伯来日历上的等效日期。 (使用简单的日记显示,文字行'&%%(日记-希伯来语-日期)' 出现在日记中的任何日期。)

causes every day’s diary display to contain the equivalent date on the Hebrew calendar, if you are using the fancy diary display. (With simple diary display, the literal line ‘&%%(diary-hebrew-date)’ appears in the diary for any date.)

此函数已用于构造某些标准希伯来语 sexp 日记条目:

This function has been used to construct certain standard Hebrew sexp diary entries:

%%(diary-hebrew-rosh-hodesh)
%%(diary-hebrew-rosh-hodesh)

写一篇日记,记录每个新希伯来月份的发生和仪式公告。

Make a diary entry that tells the occurrence and ritual announcement of each new Hebrew month.

%%(diary-hebrew-parasha)
%%(diary-hebrew-parasha)

写一篇周六日记,讲述每周犹太教堂的经文阅读。

Make a Saturday diary entry that tells the weekly synagogue scripture reading.

%%(diary-hebrew-sabbath-candles)
%%(diary-hebrew-sabbath-candles)

写一份周五日记,记录安息日蜡烛点燃的 当地时间。

Make a Friday diary entry that tells the local time of Sabbath candle lighting.

%%(diary-hebrew-omer)
%%(diary-hebrew-omer)

在适当的时候,记下日记,注明奥玛数。

Make a diary entry that gives the omer count, when appropriate.

%%(diary-hebrew-yahrzeit month day year) name
%%(diary-hebrew-yahrzeit month day year) name

写一篇日记来纪念死亡日期。该日期是公历(民事)死亡日期。日记条目出现在正确的希伯来历周年纪念日和前一天。 (参数的顺序根据日历日期样式而变化;例如,在欧洲样式中为daymonthyear。)

Make a diary entry marking the anniversary of a date of death. The date is the Gregorian (civil) date of death. The diary entry appears on the proper Hebrew calendar anniversary and on the day before. (The order of the parameters changes according to the calendar date style; for example in the European style to day, month, year.)

%%(diary-hebrew-birthday month day year)
%%(diary-hebrew-birthday month day year)

在日记中记录希伯来日历上的生日。

Make a diary entry for a birthday on the Hebrew calendar.

上面记录的所有函数都带有一个可选参数 mark,它指定如何在日历显示中标记日期。如果这些函数之一决定它适用于特定日期,它将返回一个包含mark的值,如上所述。

All the functions documented above take an optional argument mark which specifies how to mark the date in the calendar display. If one of these functions decides that it applies to a certain date, it returns a value that contains mark, as described above.


33 发送邮件

33 Sending Mail

要从 Emacs 发送电子邮件,请键入C-x m。这会切换到名为的缓冲区*未发送的邮件*,您可以在其中编辑消息的文本和标题。完成后,键入C-c C-sC-c C-c发送。

To send an email message from Emacs, type C-x m. This switches to a buffer named *unsent mail*, where you can edit the text and headers of the message. When done, type C-c C-s or C-c C-c to send it.

C-x m
C-x m

开始撰写邮件 ( compose-mail)。

Begin composing mail (compose-mail).

C-x 4 m
C-x 4 m

同样,在另一个窗口 ( compose-mail-other-window) 中。

Likewise, in another window (compose-mail-other-window).

C-x 5 m
C-x 5 m

同样,但在新框架中 ( compose-mail-other-frame)。

Likewise, but in a new frame (compose-mail-other-frame).

C-c C-s
C-c C-s

在邮件缓冲区中,发送消息 ( message-send)。

In the mail buffer, send the message (message-send).

C-c C-c
C-c C-c

在邮件缓冲区中,发送消息并埋葬缓冲区(message-send-and-exit)。

In the mail buffer, send the message and bury the buffer (message-send-and-exit).

邮件缓冲区是一个普通的 Emacs 缓冲区,因此您可以在撰写邮件时切换到其他缓冲区。如果您想在完成当前邮件之前发送另一封邮件,请C-x m再次键入以打开名称具有不同数字后缀的新邮件缓冲区(请参阅其他缓冲区操作)。 (这仅在您使用默认消息模式撰写电子邮件时有效;请参阅邮件命令。)如果您知道要继续撰写正在编辑的未发送消息,请使用前缀参数 调用此命令,Emacs 将切换到您使用的最后一个邮件缓冲区,并让您从上次中断的地方开始编辑消息。 C-u C-x m

The mail buffer is an ordinary Emacs buffer, so you can switch to other buffers while composing the mail. If you want to send another message before finishing the current one, type C-x m again to open a new mail buffer whose name has a different numeric suffix (see Miscellaneous Buffer Operations). (This only works if you use the default Message mode to compose email; see Mail Commands.) If you know that you’d like to continue composing the unsent message you were editing, invoke this command with a prefix argument, C-u C-x m, and Emacs will switch to the last mail buffer you used and let you pick up editing the message where you left off.

命令C-x 4 m( compose-mail-other-window) 的作用与 相同C-x m,只是它在不同的窗口中显示邮件缓冲区。命令C-x 5 m ( compose-mail-other-frame) 在新框架中执行此操作。

The command C-x 4 m (compose-mail-other-window) does the same as C-x m, except it displays the mail buffer in a different window. The command C-x 5 m (compose-mail-other-frame) does it in a new frame.

当您键入C-c C-cC-c C-s发送邮件时,Emacs 可能会询问您如何发送邮件 - 直接通过 SMTP,或使用其他方法。详情 请参见邮件发送。

When you type C-c C-c or C-c C-s to send the mail, Emacs may ask you how it should deliver the mail—either directly via SMTP, or using some other method. See Mail Sending, for details.


33.1 邮件缓冲区的格式

33.1 The Format of the Mail Buffer

以下是邮件缓冲区内容的示例:

Here is an example of the contents of a mail buffer:

至:subotai@example.org
抄送:mongol.soldier@example.net、rms@gnu.org
主题:回复:生命中最好的是什么?
来自:conan@example.org
--文本遵循这一行--
粉碎你的敌人,看着他们被赶到你面前,然后
听他们的女人的哀叹。
To: subotai@example.org
CC: mongol.soldier@example.net, rms@gnu.org
Subject: Re: What is best in life?
From: conan@example.org
--text follows this line--
To crush your enemies, see them driven before you, and to
hear the lamentation of their women.

邮件缓冲区的顶部是一组标头字段,用于指定有关电子邮件收件人、主题等的信息。上面的缓冲区包含 '','CC','主题', 和 ''。在适当的情况下,某些标头字段会在邮件缓冲区中自动预初始化。

At the top of the mail buffer is a set of header fields, which are used for specifying information about the email’s recipient(s), subject, and so on. The above buffer contains header fields for ‘To’, ‘CC’, ‘Subject’, and ‘From’. Some header fields are automatically pre-initialized in the mail buffer, when appropriate.

一行写着‘--文本遵循这一行--' 将消息的标头字段与正文(或文本)分开。该行之上的所有内容都被视为标头的一部分;它下面的所有东西都被视为主体。分隔符行本身不会出现在实际发送的消息中。

The line that says ‘--text follows this line--’ separates the header fields from the body (or text) of the message. Everything above that line is treated as part of the headers; everything below it is treated as the body. The delimiter line itself does not appear in the message actually sent.

您可以使用普通编辑命令插入和编辑标题字段。有关特定于编辑标头字段的命令,请参阅邮件标头编辑。某些标头,例如 '日期' 和 '消息ID',通常从邮件缓冲区中省略,并在发送消息时自动创建。

You can insert and edit header fields using ordinary editing commands. See Mail Header Editing, for commands specific to editing header fields. Certain headers, such as ‘Date’ and ‘Message-Id’, are normally omitted from the mail buffer and are created automatically when the message is sent.


33.2 邮件标头字段

33.2 Mail Header Fields

邮件缓冲区中的标头字段以行开头的字段名称开头,以冒号结尾。字段名称中的大小写相同。冒号和可选空格之后是字段的内容。

A header field in the mail buffer starts with a field name at the beginning of a line, terminated by a colon. Upper and lower case are equivalent in field names. After the colon and optional whitespace comes the contents of the field.

您可以为标头字段使用任何您喜欢的名称,但通常人们只使用具有可接受含义的标准字段名称。

You can use any name you like for a header field, but normally people use only standard field names with accepted meanings.

这 '' 标头字段标识发送电子邮件的人(即您)。这应该是一个有效的邮寄地址,因为回复通常会发送到那里。此标头字段的默认内容是根据变量user-full-name(指定您的全名)和user-mail-address(您的电子邮件地址)计算得出的。在某些操作系统上,Emacs 使用环境变量初始化这两个变量(请参阅常规变量)。如果此信息不可用或错误,您应该自行自定义变量(请参阅轻松自定义界面)。

The ‘From’ header field identifies the person sending the email (i.e., you). This should be a valid mailing address, as replies are normally sent there. The default contents of this header field are computed from the variables user-full-name (which specifies your full name) and user-mail-address (your email address). On some operating systems, Emacs initializes these two variables using environment variables (see General Variables). If this information is unavailable or wrong, you should customize the variables yourself (see Easy Customization Interface).

除了 '',这是一个常用字段表:

Apart from ‘From’, here is a table of commonly-used fields:

''
To

邮件发送到的邮寄地址。要列出多个地址,请使用逗号分隔它们。

The mailing address(es) to which the message is addressed. To list more than one address, use commas to separate them.

'主题'
Subject

邮件的主题。

The subject of the message.

'CC'
CC

将消息发送到的其他邮寄地址。这就像'”,但这些读者不应认为该消息是针对他们的。

Additional mailing address(es) to send the message to. This is like ‘To’, except that these readers should not regard the message as directed at them.

'密件抄送'
BCC

要将邮件发送到的其他邮寄地址,该地址不应出现在实际发送的邮件的标题中。 '密件抄送' 代表密件抄送

Additional mailing address(es) to send the message to, which should not appear in the header of the message actually sent. ‘BCC’ stands for blind carbon copies.

'美国联邦通信委员会'
FCC

文件的名称,已发送消息的副本应附加到该文件中。 Emacs 以 mbox 格式写入消息,除非文件是 Babyl 格式(Emacs 23 之前的 Rmail 使用),在这种情况下,Emacs 以 Babyl 格式写入。如果 Rmail 缓冲区正在访问该文件,Emacs 会相应地更新它。要指定多个文件,请使用多个 '美国联邦通信委员会' 字段,每个字段中有一个文件名。

The name of a file, to which a copy of the sent message should be appended. Emacs writes the message in mbox format, unless the file is in Babyl format (used by Rmail before Emacs 23), in which case Emacs writes in Babyl format. If an Rmail buffer is visiting the file, Emacs updates it accordingly. To specify more than one file, use several ‘FCC’ fields, with one file name in each field.

'回复'
Reply-To

应发送回复的地址,而不是 ''。如果出于某种原因,您的 '' 地址无法收到回复。

An address to which replies should be sent, instead of ‘From’. This is used if, for some reason, your ‘From’ address cannot receive replies.

'邮件回复'
Mail-Reply-To

该字段优先于 '回复'。使用它是因为一些邮件列表设置了 '回复' 领域用于他们自己的目的(有点争议的做法)。

This field takes precedence over ‘Reply-To’. It is used because some mailing lists set the ‘Reply-To’ field for their own purposes (a somewhat controversial practice).

'邮件跟进'
Mail-Followup-To

用作后续消息的默认收件人的多个地址之一。当您从订阅的邮件列表回复邮件,并且希望回复转到该列表而不向您发送额外的副本时,通常会使用此功能。

One of more address(es) to use as default recipient(s) for follow-up messages. This is typically used when you reply to a message from a mailing list that you are subscribed to, and want replies to go to the list without sending an extra copy to you.

'回复中'
In-Reply-To

您正在回复的消息的标识符。大多数邮件阅读器使用此信息将相关消息分组在一起。通常,当您在 Emacs 内置的任何邮件程序中回复消息时,会自动填充此标头。

An identifier for the message you are replying to. Most mail readers use this information to group related messages together. Normally, this header is filled in automatically when you reply to a message in any mail program built into Emacs.

'参考'
References

先前相关消息的标识符。喜欢 '回复中',通常会自动为您填写。

Identifiers for previous related messages. Like ‘In-Reply-To’, this is normally filled in automatically for you.

这 '','CC', 和 '密件抄送' 字段可以出现任意多次,并且每个此类标头字段可以包含多个地址,以逗号分隔。这样,您可以指定任意数量的发送消息的位置。这些字段还可以有续行:字段起始行后面以空格开头的一行或多行被视为字段的一部分。这是一个 '' 带有续行的字段:

The ‘To’, ‘CC’, and ‘BCC’ fields can appear any number of times, and each such header field can contain multiple addresses, separated by commas. This way, you can specify any number of places to send the message. These fields can also have continuation lines: one or more lines starting with whitespace, following the starting line of the field, are considered part of the field. Here’s an example of a ‘To’ field with a continuation line:

至:foo@example.net、this@example.net、
  鲍勃@example.com
To: foo@example.net, this@example.net,
  bob@example.com

mail-default-headers您可以通过将变量设置为字符串来指示 Emacs 将某些默认标头插入邮件缓冲区。然后C-x m将此字符串插入到消息标头中。例如,以下是如何添加 '回复' 和 '美国联邦通信委员会' 每条消息的标头:

You can direct Emacs to insert certain default headers into the mail buffer by setting the variable mail-default-headers to a string. Then C-x m inserts this string into the message headers. For example, here is how to add a ‘Reply-To’ and ‘FCC’ header to each message:

(setq 邮件默认标头
      “回复:foo@example.com\nFCC:~/Mail/sent”)
(setq mail-default-headers
      "Reply-To: foo@example.com\nFCC: ~/Mail/sent")

如果默认标头字段不适合特定消息,请在发送消息之前根据需要对其进行编辑。

If the default header fields are not appropriate for a particular message, edit them as necessary before sending the message.


33.3 邮件别名

33.3 Mail Aliases

您可以定义邮件别名,这是代表一个或多个邮寄地址的简短助记名称。默认情况下,邮件别名在文件中定义~/.mailrc。您可以通过设置变量 来指定要使用的不同文件名 mail-personal-alias-file

You can define mail aliases, which are short mnemonic names that stand for one or more mailing addresses. By default, mail aliases are defined in the file ~/.mailrc. You can specify a different file name to use, by setting the variable mail-personal-alias-file.

定义别名~/.mailrc,写这样一行:

To define an alias in ~/.mailrc, write a line like this:

别名nick 完整地址
alias nick fulladdresses

这意味着nick应扩展为fulladdresses,其中fulladdresses可以是单个地址,也可以是用空格分隔的多个地址。例如,要maingnu 代表gnu@gnu.org您自己的本地地址,请输入以下行:

This means that nick should expand into fulladdresses, where fulladdresses can be either a single address, or multiple addresses separated with spaces. For instance, to make maingnu stand for gnu@gnu.org plus a local address of your own, put in this line:

别名 maingnu gnu@gnu.org local-gnu
alias maingnu gnu@gnu.org local-gnu

如果地址包含空格,请用一对双引号引用整个地址,如下所示:

If an address contains a space, quote the whole address with a pair of double quotes, like this:

别名 jsmith“John Q. Smith <none@example.com>”
alias jsmith "John Q. Smith <none@example.com>"

请注意,您无需在地址的各个部分(例如人员的全名)周围添加双引号。如果需要,Emacs 会将它们放入。例如,它将上述地址插入为 '“约翰·Q·史密斯”<none@example.com>'。

Note that you need not include double quotes around individual parts of the address, such as the person’s full name. Emacs puts them in if they are needed. For instance, it inserts the above address as ‘"John Q. Smith" <none@example.com>’.

编辑后~/.mailrc文件,或者如果该文件是在 Emacs 外部修改的,您可以使用.这会提示输入要使用的文件名,默认值为.类似的命令 会提示输入包含邮件别名的文件,然后将该文件中的别名与现有别名合并。 M-x rebuild-mail-abbrevs RETmail-personal-alias-filemerge-mail-abbrevs

After editing the ~/.mailrc file, or if the file was modified outside of Emacs, you can update the mail aliases used by a running Emacs session with M-x rebuild-mail-abbrevs RET. This prompts for the name of the file to use, the default being the value of mail-personal-alias-file. A similar command merge-mail-abbrevs prompts for a file with mail aliases, then merges the aliases in that file with the existing ones.

或者,您可以使用 Emacs 命令来定义邮件别名。该命令define-mail-abbrev提示输入别名和完整地址,并定义别名以扩展为完整地址。每当 Emacs 提供保存所有文件(对于C-x sC-x C-c)时,它都会保存添加的别名,就像处理其他缩写一样(请参阅保存缩写)。

Alternatively, you can use Emacs commands to define mail aliases. The command define-mail-abbrev prompts for the alias and the full address, and defines the alias to expand to the full address. Emacs will save the added aliases whenever it offers to save all files (for C-x s or C-x C-c), like it does with other abbrevs (see Saving Abbrevs).

Emacs 还识别包含命令~/.mailrc。它们看起来像这样:

Emacs also recognizes include commands in ~/.mailrc. They look like this:

文件名
source filename

~/.mailrc文件并非 Emacs 所独有;许多其他邮件阅读程序使用它作为邮件别名,并且它可以包含各种其他命令。但是,Emacs 会忽略除别名定义和 include 命令之外的所有内容。

The ~/.mailrc file is not unique to Emacs; many other mail-reading programs use it for mail aliases, and it can contain various other commands. However, Emacs ignores everything except alias definitions and include commands.

邮件别名会扩展为缩写,也就是说,只要您在别名后键入单词分隔符(请参阅缩写)。这种扩展仅发生在 '','','CC','密件抄送', 和 '回复' 标头字段(加上它们的 '重新发送-' 变体);它不会发生在其他标头字段中,例如 '主题'。

Mail aliases expand as abbrevs—that is to say, as soon as you type a word-separator character after an alias (see Abbrevs). This expansion takes place only within the ‘To’, ‘From’, ‘CC’, ‘BCC’, and ‘Reply-To’ header fields (plus their ‘Resent-’ variants); it does not take place in other header fields, such as ‘Subject’.

您还可以使用命令直接插入别名地址 M-x mail-abbrev-insert-alias。这将读取别名并完成,并在该位置插入其定义。

You can also insert an aliased address directly, using the command M-x mail-abbrev-insert-alias. This reads an alias name, with completion, and inserts its definition at point.

该命令mail-abbrev-complete-alias在邮件别名前面的点上完成。

The command mail-abbrev-complete-alias completes on the mail alias preceding point.


33.4 邮件命令

33.4 Mail Commands

默认主要模式为*邮件*缓冲区称为消息模式。它在很多方面的行为类似于文本模式,但在前缀上提供了几个附加命令C-c,这使得编辑消息更加方便。

The default major mode for the *mail* buffer is called Message mode. It behaves like Text mode in many ways, but provides several additional commands on the C-c prefix, which make editing a message more convenient.

在本节中,我们将描述消息模式下一些最常用的命令。消息模式也有自己的手册,其中更详细地描述了其功能。请参阅消息中的消息

In this section, we will describe some of the most commonly-used commands available in Message mode. Message mode also has its own manual, where its features are described in greater detail. See Message in Message.


33.4.1 邮件发送

33.4.1 Mail Sending

C-c C-c
C-c C-c

发送消息,并埋葬邮件缓冲区(message-send-and-exit)。

Send the message, and bury the mail buffer (message-send-and-exit).

C-c C-s
C-c C-s

发送消息,并保持邮件缓冲区处于选中状态 ( message-send)。

Send the message, and leave the mail buffer selected (message-send).

通常发送消息的命令是C-c C-c ( message-send-and-exit)。这会发送消息,然后隐藏邮件缓冲区,将其置于重新选择的最低优先级。如果您希望它杀死邮件缓冲区,请将变量更改message-kill-buffer-on-exitt

The usual command to send a message is C-c C-c (message-send-and-exit). This sends the message and then buries the mail buffer, putting it at the lowest priority for reselection. If you want it to kill the mail buffer instead, change the variable message-kill-buffer-on-exit to t.

命令C-c C-s( message-send) 发送消息并保持选定的缓冲区。如果您想修改邮件(可能是新的收件人)并再次发送,请使用此命令。

The command C-c C-s (message-send) sends the message and leaves the buffer selected. Use this command if you want to modify the message (perhaps with new recipients) and send it again.

发送消息会运行钩子message-send-hook。它还将邮件缓冲区标记为未修改,除非邮件缓冲区也是文件访问缓冲区(在这种情况下,仅保存文件即可,并且如果您尝试两次发送相同的消息,则不会收到警告)。

Sending a message runs the hook message-send-hook. It also marks the mail buffer as unmodified, except if the mail buffer is also a file-visiting buffer (in that case, only saving the file does that, and you don’t get a warning if you try to send the same message twice).

该变量message-send-mail-function控制消息的传递方式(send-mail-function用于邮件模式)。的值send-mail-function应该是以下函数之一:

The variable message-send-mail-function controls how the message is delivered (send-mail-function is used for Mail mode). The value of send-mail-function should be one of the following functions:

sendmail-query-once
sendmail-query-once

查询传递方法(此列表中的其他条目之一),并将该方法用于此消息;然后将该方法保存到 send-mail-function,以便将来交付时使用。这是默认设置,除非您已经设置了发送邮件的变量smtpmail-send-it(见下文)。

Query for a delivery method (one of the other entries in this list), and use that method for this message; then save the method to send-mail-function, so that it is used for future deliveries. This is the default, unless you have already set the variables for sending mail via smtpmail-send-it (see below).

smtpmail-send-it
smtpmail-send-it

通过外部邮件主机发送邮件,例如 Internet 服务提供商的外发 SMTP 邮件服务器。如果你还没有告诉 Emacs 如何联系 SMTP 服务器,它会提示输入此信息,该信息保存在变量smtpmail-smtp-server和文件中〜/.authinfo。请参阅通过 SMTP 发送邮件中的Emacs SMTP 库

Send mail through an external mail host, such as your Internet service provider’s outgoing SMTP mail server. If you have not told Emacs how to contact the SMTP server, it prompts for this information, which is saved in the smtpmail-smtp-server variable and the file ~/.authinfo. See Emacs SMTP Library in Sending mail via SMTP.

sendmail-send-it
sendmail-send-it

使用系统的默认sendmail程序或同等程序发送邮件。这需要将系统设置为直接通过 SMTP 传送邮件。

Send mail using the system’s default sendmail program, or equivalent. This requires the system to be set up for delivering mail directly via SMTP.

mailclient-send-it
mailclient-send-it

将邮件缓冲区传递到系统指定的邮件客户端。请参阅文件中的注释部分邮件客户端.el了解详情。

Pass the mail buffer on to the system’s designated mail client. See the commentary section in the file mailclient.el for details.

feedmail-send-it
feedmail-send-it

这与 类似sendmail-send-it,但允许您对消息进行排队以便稍后发送。请参阅文件中的注释部分 feedmail.el了解详情。

This is similar to sendmail-send-it, but allows you to queue messages for later sending. See the commentary section in the file feedmail.el for details.

当您发送包含非ASCII字符的消息时,需要使用编码系统对它们进行编码(请参阅编码系统)。通常编码系统是由您选择的语言环境自动指定的(请参阅语言环境)。您可以通过设置变量来显式指定外发邮件的编码系统sendmail-coding-system(请参阅识别编码系统)。如果由此确定的编码系统不能处理特定消息中的字符,Emacs 会要求您选择要使用的编码系统,并显示可能的编码系统列表。请参阅选择输出编码系统

When you send a message containing non-ASCII characters, they need to be encoded with a coding system (see Coding Systems). Usually the coding system is specified automatically by your chosen language environment (see Language Environments). You can explicitly specify the coding system for outgoing mail by setting the variable sendmail-coding-system (see Recognizing Coding Systems). If the coding system thus determined does not handle the characters in a particular message, Emacs asks you to select the coding system to use, showing a list of possible coding systems. See Choosing Coding Systems for Output.


33.4.2 邮件标题编辑

33.4.2 Mail Header Editing

消息模式提供以下特殊命令来移动到特定标头字段并完成标头中的地址。

Message mode provides the following special commands to move to particular header fields and to complete addresses in headers.

C-c C-f C-t
C-c C-f C-t

移至 '' 标头 ( message-goto-to)。

Move to the ‘To’ header (message-goto-to).

C-c C-f C-s
C-c C-f C-s

移至 '主题' 标头 ( message-goto-subject)。

Move to the ‘Subject’ header (message-goto-subject).

C-c C-f C-c
C-c C-f C-c

移至 'CC' 标头 ( message-goto-cc)。

Move to the ‘CC’ header (message-goto-cc).

C-c C-f C-b
C-c C-f C-b

移至 '密件抄送' 标头 ( message-goto-bcc)。

Move to the ‘BCC’ header (message-goto-bcc).

C-c C-f C-r
C-c C-f C-r

移至 '回复' 标头 ( message-goto-reply-to)。

Move to the ‘Reply-To’ header (message-goto-reply-to).

C-c C-f C-f
C-c C-f C-f

移至 '邮件跟进' 标头字段 ( message-goto-followup-to)。

Move to the ‘Mail-Followup-To’ header field (message-goto-followup-to).

C-c C-f C-w
C-c C-f C-w

添加一个新的 '美国联邦通信委员会' 标头字段,带有文件名补全 ( message-goto-fcc)。

Add a new ‘FCC’ header field, with file-name completion (message-goto-fcc).

C-c C-b
C-c C-b

移至消息正文的开头 ( message-goto-body)。

Move to the start of the message body (message-goto-body).

TAB
TAB

填写邮寄地址 ( message-tab)。

Complete a mailing address (message-tab).

将点移动到特定标头字段的命令均基于前缀C-c C-f('CF' 代表“字段”)。如果相关字段不存在,该命令将创建一个字段(例外情况是mail-fcc,它每次都会创建一个新字段)。

The commands to move point to particular header fields are all based on the prefix C-c C-f (‘C-f’ is for “field”). If the field in question does not exist, the command creates one (the exception is mail-fcc, which creates a new field each time).

命令C-c C-b( message-goto-body) 将点移动到标题分隔线之后,即正文的开头。

The command C-c C-b (message-goto-body) moves point to just after the header separator line—that is, to the beginning of the body.

编辑包含地址的标头字段时,例如“到:','抄送:' 和 '密件抄送:TAB',您可以通过键入( )来完成地址message-tab。这会尝试根据多种方法插入与地址相对应的全名,包括 EUDC,这是一个可识别多种目录服务器协议的库(请参阅Emacs 统一目录客户端中的EUDC)。如果失败,它会尝试将地址扩展为邮件别名(请参阅邮件别名)。如果点位于不带地址的标头字段上,或者位于消息正文中,则 只需插入制表符。 TAB

While editing a header field that contains addresses, such as ‘To:’, ‘CC:’ and ‘BCC:’, you can complete an address by typing TAB (message-tab). This attempts to insert the full name corresponding to the address based on a couple of methods, including EUDC, a library that recognizes a number of directory server protocols (see EUDC in The Emacs Unified Directory Client). Failing that, it attempts to expand the address as a mail alias (see Mail Aliases). If point is on a header field that does not take addresses, or if it is in the message body, then TAB just inserts a tab character.


33.4.3 引用邮件

33.4.3 Citing Mail

C-c C-y
C-c C-y

从邮件阅读器中拉出选定的消息,作为引用 ( message-yank-original)。

Yank the selected message from the mail reader, as a citation (message-yank-original).

C-c C-q
C-c C-q

填写从另一条消息引用的每个段落(message-fill-yanked-message)。

Fill each paragraph cited from another message (message-fill-yanked-message).

您可以使用命令C-c C-y( message-yank-original) 引用正在回复的消息。这将该消息的文本插入到邮件缓冲区中。仅当从 Emacs 中运行的邮件阅读器(例如 Rmail)调用邮件缓冲区时,此命令才有效。

You can use the command C-c C-y (message-yank-original) to cite a message that you are replying to. This inserts the text of that message into the mail buffer. This command works only if the mail buffer is invoked from a mail reader running in Emacs, such as Rmail.

默认情况下,Emacs 插入字符串 '>' 在引用文本的每一行前面;该前缀字符串由变量指定 message-yank-prefix。如果message-yank-original 使用前缀参数调用,则不会插入引用前缀。

By default, Emacs inserts the string ‘>’ in front of each line of the cited text; this prefix string is specified by the variable message-yank-prefix. If you call message-yank-original with a prefix argument, the citation prefix is not inserted.

使用 后C-c C-y,您可以键入C-c C-q ( message-fill-yanked-message) 来填写引用消息的段落。的一种用法C-c C-q可以填满所有这些段落,每个段落都是单独的。要填写引用消息的单个段落,请使用M-q。如果填充不能自动处理您使用的引文前缀类型,请尝试显式设置填充前缀。请参阅填充文本

After using C-c C-y, you can type C-c C-q (message-fill-yanked-message) to fill the paragraphs of the cited message. One use of C-c C-q fills all such paragraphs, each one individually. To fill a single paragraph of the quoted message, use M-q. If filling does not automatically handle the type of citation prefix you use, try setting the fill prefix explicitly. See Filling Text.

您可以通过钩子自定义邮件引用 mail-citation-hook。例如,您可以使用 Supercite 包,它提供更灵活的引用(请参阅Supercite中的简介)。

You can customize mail citation through the hook mail-citation-hook. For example, you can use the Supercite package, which provides more flexible citation (see Introduction in Supercite).


33.4.4 邮件杂项

33.4.4 Mail Miscellany

您可以通过在邮件缓冲区中键入( ) 将文件 附加到外发邮件。附加是使用多用途 Internet 邮件扩展 ( MIME ) 标准完成的。 C-c C-amml-attach-file

You can attach a file to an outgoing message by typing C-c C-a (mml-attach-file) in the mail buffer. Attaching is done using the Multipurpose Internet Mail Extensions (MIME) standard.

mml-attach-file命令提示输入文件名、附件的内容类型描述配置。通常会自动检测内容类型;只需键入RET即可接受默认值。描述是收件人将在附件旁边看到的单行文本;您也可以选择将其留空。处置方式是 '排队',这意味着收件人将在邮件正文中看到指向附件的链接,或者 '依恋',这意味着链接将与正文分开。

The mml-attach-file command prompts for the name of the file, and for the attachment’s content type, description, and disposition. The content type is normally detected automatically; just type RET to accept the default. The description is a single line of text that the recipient will see next to the attachment; you may also choose to leave this empty. The disposition is either ‘inline’, which means the recipient will see a link to the attachment within the message body, or ‘attachment’, which means the link will be separate from the body.

mml-attach-file命令是消息模式特有的;在邮件模式mail-add-attachment下使用。它只会提示输入文件名,并自动确定内容类型和配置。如果您想要包含附加文件的一些描述,请在邮件正文中键入该描述。

The mml-attach-file command is specific to Message mode; in Mail mode use mail-add-attachment instead. It will prompt only for the name of the file, and will determine the content type and the disposition automatically. If you want to include some description of the attached file, type that in the message body.

附件的实际内容不会插入到邮件缓冲区中。相反,一些占位符文本被插入到邮件缓冲区中,如下所示:

The actual contents of the attached file are not inserted into the mail buffer. Instead, some placeholder text is inserted into the mail buffer, like this:

<#part type="text/plain" filename="~/foo.txt" disposition=inline>
<#/部分>
<#part type="text/plain" filename="~/foo.txt" disposition=inline>
<#/part>

当您键入C-c C-cC-c C-s发送消息时,附件文件将随之发送。

When you type C-c C-c or C-c C-s to send the message, the attached file will be delivered with it.

撰写消息时,您可以通过键入 来对消息文本进行拼写更正M-x ispell-message。如果您已将传入消息拉入传出草稿中,则此命令会跳过拉出的内容,但它会检查您自己插入的文本(它会查找缩进或mail-yank-prefix将引用的行与您的输入区分开来)。请参阅检查和更正拼写

While composing a message, you can do spelling correction on the message text by typing M-x ispell-message. If you have yanked an incoming message into the outgoing draft, this command skips what was yanked, but it checks the text that you yourself inserted (it looks for indentation or mail-yank-prefix to distinguish the cited lines from your input). See Checking and Correcting Spelling.

打开消息模式(C-x m自动执行)会运行正常的钩子text-mode-hookmessage-mode-hook.初始化新的传出消息会运行正常的钩子 message-setup-hook;如果您想更改邮件缓冲区的外观,可以使用此挂钩。请参阅钩子

Turning on Message mode (which C-x m does automatically) runs the normal hooks text-mode-hook and message-mode-hook. Initializing a new outgoing message runs the normal hook message-setup-hook; you can use this hook if you want to make changes to the appearance of the mail buffer. See Hooks.

这些钩子之间的主要区别在于它们被调用的时间。每当您键入 时C-x mmessage-mode-hook邮件缓冲区一创建就会运行。然后该message-setup 函数插入缓冲区的默认内容。插入这些默认内容后,message-setup-hook运行。

The main difference between these hooks is just when they are invoked. Whenever you type C-x m, message-mode-hook runs as soon as the mail buffer is created. Then the message-setup function inserts the default contents of the buffer. After these default contents are inserted, message-setup-hook runs.

如果您用于C-x m继续现有的撰写,则 message-mode-hook在切换到邮件缓冲区后立即运行。如果缓冲区未修改,或者您决定擦除它并重新开始,message-setup-hook则在插入默认内容后运行。

If you use C-x m to continue an existing composition, message-mode-hook runs immediately after switching to the mail buffer. If the buffer is unmodified, or if you decide to erase it and start again, message-setup-hook runs after the default contents are inserted.


33.5 邮件签名

33.5 Mail Signature

您可以在每封邮件的末尾添加一段标准文本(您的邮件签名)。该签名可能包含您的电话号码或您的实际位置等信息。该变量message-signature决定 Emacs 如何处理邮件签名。

You can add a standard piece of text—your mail signature—to the end of every message. This signature may contain information such as your telephone number or your physical location. The variable message-signature determines how Emacs handles the mail signature.

message-signature的默认值为t;这意味着在文件中查找您的邮件签名~/.签名。如果该文件存在,其内容会自动插入到邮件缓冲区的末尾。您可以通过变量更改签名文件message-signature-file

The default value of message-signature is t; this means to look for your mail signature in the file ~/.signature. If this file exists, its contents are automatically inserted into the end of the mail buffer. You can change the signature file via the variable message-signature-file.

如果更改message-signature为字符串,则直接指定签名的文本。

If you change message-signature to a string, that specifies the text of the signature directly.

如果您更改message-signaturenil,Emacs 将不会自动插入您的邮件签名。您可以通过在邮件缓冲区中键入C-c C-w( )来插入邮件签名。 message-insert-signatureEmacs 会在签名文件中查找您的签名。

If you change message-signature to nil, Emacs will not insert your mail signature automatically. You can insert your mail signature by typing C-c C-w (message-insert-signature) in the mail buffer. Emacs will look for your signature in the signature file.

如果您使用邮件模式而不是消息模式来撰写邮件,则确定签名发送方式的相应变量为mail-signaturemail-signature-file

If you use Mail mode rather than Message mode for composing your mail, the corresponding variables that determine how your signature is sent are mail-signature and mail-signature-file instead.

按照惯例,邮件签名应由一行标记,其内容为 '--'。如果您的签名缺少此前缀,系统会为您添加它。签名的其余部分不应超过四行。

By convention, a mail signature should be marked by a line whose contents are ‘-- ’. If your signature lacks this prefix, it is added for you. The remainder of your signature should be no more than four lines.


33.6 邮件娱乐

33.6 Mail Amusements

M-x spook将一行随机选择的关键字添加到外发邮件消息中。关键字是从暗示您正在讨论颠覆性事物的单词列表中选择的。

M-x spook adds a line of randomly chosen keywords to an outgoing mail message. The keywords are chosen from a list of words that suggest you are discussing something subversive.

此功能背后的想法是怀疑 NSA 19和其他情报机构窥探所有包含关键字的电子邮件,表明他们可能会发现这些关键字有趣。 (这些机构说他们不这样做,但他们就是这么的。)这个想法是,如果很多人在他们的消息中添加可疑的单词,这些机构将忙于虚假输入,以至于他们将不得不放弃阅读这一切。不管这是否属实,至少让一些人感到好笑。

The idea behind this feature is the suspicion that the NSA19 and other intelligence agencies snoop on all electronic mail messages that contain keywords suggesting they might find them interesting. (The agencies say that they don’t, but that’s what they would say.) The idea is that if lots of people add suspicious words to their messages, the agencies will get so busy with spurious input that they will have to give up reading it all. Whether or not this is true, it at least amuses some people.

您可以使用该fortune程序将幸运饼干消息放入外发邮件中。为此,请 fortune-to-signature添加mail-setup-hook

You can use the fortune program to put a fortune cookie message into outgoing mail. To do this, add fortune-to-signature to mail-setup-hook:

(add-hook 'mail-setup-hook 'fortune-to-signature)
(add-hook 'mail-setup-hook 'fortune-to-signature)

fortune-file在使用它之前 您可能需要设置变量。

You will probably need to set the variable fortune-file before using this.


33.7 邮件撰写方法

33.7 Mail-Composition Methods

在本章中,我们描述了编辑和发送邮件的常用 Emacs 模式——消息模式。这只是多种可用模式之一。在 Emacs 23.2 之前,默认模式是 Mail 模式,它在很多方面与 Message 模式类似,但缺乏 MIME 支持等功能。另一种可用的模式是 MH-E(请参阅Emacs 与 MH 的接口中的MH-E)。

In this chapter we have described the usual Emacs mode for editing and sending mail—Message mode. This is only one of several available modes. Prior to Emacs 23.2, the default mode was Mail mode, which is similar to Message mode in many respects but lacks features such as MIME support. Another available mode is MH-E (see MH-E in The Emacs Interface to MH).

您可以选择任何这些邮件用户代理作为编辑和发送邮件的首选方法。命令C-x mC-x 4 mC-x 5 m使用您指定的代理; Emacs 发送邮件的其他各个部分也是如此,例如错误报告器(请参阅报告错误)。要指定邮件用户代理,请自定义变量mail-user-agent。目前,合法值包括message-user-agent(消息模式) sendmail-user-agent、(邮件模式)gnus-user-agent、 和 mh-e-user-agent。可能还有其他选项;有关详细信息,请参阅邮件用户代理包的手册。您还可以使用 定义另一个邮件用户代理 define-mail-user-agent

You can choose any of these mail user agents as your preferred method for editing and sending mail. The commands C-x m, C-x 4 m and C-x 5 m use whichever agent you have specified; so do various other parts of Emacs that send mail, such as the bug reporter (see Reporting Bugs). To specify a mail user agent, customize the variable mail-user-agent. Currently, legitimate values include message-user-agent (Message mode) sendmail-user-agent (Mail mode), gnus-user-agent, and mh-e-user-agent. Additional options may be available; check in the manual of your mail user agent package for details. You may also define another mail user agent using define-mail-user-agent.

如果您选择不同的邮件撰写方法,则本章中有关邮件缓冲区和消息模式的信息不适用;其他方法在不同的缓冲区中使用不同格式的文本,并且它们的命令也不同。

If you select a different mail-composition method, the information in this chapter about the mail buffer and Message mode does not apply; the other methods use a different format of text in a different buffer, and their commands are different as well.

同样,要指定您阅读邮件的首选方法,请自定义变量read-mail-command。默认值为 rmail(请参阅使用 Rmail 读取邮件)。

Similarly, to specify your preferred method for reading mail, customize the variable read-mail-command. The default is rmail (see Reading Mail with Rmail).


34 使用 Rmail 阅读邮件

34 Reading Mail with Rmail

Rmail 是一个 Emacs 子系统,用于阅读和处理您收到的邮件。 Rmail 将邮件消息存储在称为 Rmail 文件的文件中。读取 Rmail 文件中的消息是在一种特殊的主要模式(Rmail 模式)下完成的,该模式重新定义了大多数字母来运行管理邮件的命令。

Rmail is an Emacs subsystem for reading and disposing of mail that you receive. Rmail stores mail messages in files called Rmail files. Reading the messages in an Rmail file is done in a special major mode, Rmail mode, which redefines most letters to run commands for managing mail.

Emacs 还附带了一个更复杂、更灵活的邮件阅读子系统,称为 Gnus。 Gnus 是一个非常大的包,因此在它自己的手册中进行了描述,请参阅Gnus Newsreader

Emacs also comes with a much more sophisticated and flexible subsystem for reading mail, called Gnus. Gnus is a very large package, and is therefore described in its own manual, see The Gnus Newsreader.


34.1 Rmail的基本概念

34.1 Basic Concepts of Rmail

以最简单的方式使用 Rmail,您将拥有一个 Rmail 文件 ~/RMAIL您的所有邮件都保存在其中。它称为您的 主 Rmail 文件。该命令M-x rmail读取您的主 Rmail 文件,合并收件箱中的新邮件,显示您尚未阅读的第一封邮件,然后让您开始阅读。该变量 rmail-file-name指定主 Rmail 文件的名称。

Using Rmail in the simplest fashion, you have one Rmail file ~/RMAIL in which all of your mail is saved. It is called your primary Rmail file. The command M-x rmail reads your primary Rmail file, merges new mail in from your inboxes, displays the first message you haven’t read yet, and lets you begin reading. The variable rmail-file-name specifies the name of the primary Rmail file.

Rmail 一次仅显示 Rmail 文件中的一封邮件。显示的消息称为当前消息。 Rmail 模式的特殊命令可以执行诸如删除当前邮件、将其复制到另一个文件、发送回复或移动到另一封邮件等操作。您还可以创建多个 Rmail 文件(请参阅文件处理)并使用 Rmail 在它们之间移动消息(请参阅将消息复制到文件)。

Rmail displays only one message in the Rmail file at a time. The message that is shown is called the current message. Rmail mode’s special commands can do such things as delete the current message, copy it into another file, send a reply, or move to another message. You can also create multiple Rmail files (see File Handling) and use Rmail to move messages between them (see Copying Messages Out to Files).

在 Rmail 文件中,消息通常按照接收顺序依次排列;您可以指定其他方式对它们进行排序(请参阅对 Rmail 文件进行排序)。消息由连续的整数(即消息号)来标识。当前消息的数量显示在 Rmail 的模式行中,后面是文件中的消息总数。您可以通过使用 键指定消息编号来移动到消息j(请参阅在消息之间移动)。

Within the Rmail file, messages are normally arranged sequentially in order of receipt; you can specify other ways to sort them (see Sorting the Rmail File). Messages are identified by consecutive integers which are their message numbers. The number of the current message is displayed in Rmail’s mode line, followed by the total number of messages in the file. You can move to a message by specifying its message number with the j key (see Moving Among Messages).

遵循 Emacs 的常用约定,仅当您保存文件时,Rmail 文件中的更改才会永久生效。您可以使用s( )保存它 rmail-expunge-and-save,这也会首先从文件中删除已删除的消息(请参阅删除消息)。要保存文件而不删除,请使用C-x C-s.合并收件箱文件中的新邮件后,Rmail 会自动保存 Rmail 文件(请参阅Rmail 文件和收件箱)。

Following the usual conventions of Emacs, changes in an Rmail file become permanent only when you save the file. You can save it with s (rmail-expunge-and-save), which also expunges deleted messages from the file first (see Deleting Messages). To save the file without expunging, use C-x C-s. Rmail automatically saves the Rmail file after merging new mail from an inbox file (see Rmail Files and Inboxes).

q您可以使用( )退出 Rmail rmail-quit;这将删除并保存 Rmail 文件,然后隐藏 Rmail 缓冲区及其摘要缓冲区(如果存在)(请参阅摘要)。但没有必要正式退出。如果您从 Rmail 切换到在其他缓冲区中进行编辑,并且再也没有切换回来,那么您就已经退出了。只需确保最终保存 Rmail 文件(就像您更改的任何其他文件一样)。 C-x s是执行此操作的合适方法(请参阅保存文件的命令)。 Rmail 命令brmail-bury、 隐藏 Rmail 缓冲区及其摘要,而不删除和保存 Rmail 文件。

You can exit Rmail with q (rmail-quit); this expunges and saves the Rmail file, then buries the Rmail buffer as well as its summary buffer, if present (see Summaries). But there is no need to exit formally. If you switch from Rmail to editing in other buffers, and never switch back, you have exited. Just make sure to save the Rmail file eventually (like any other file you have changed). C-x s is a suitable way to do this (see Commands for Saving Files). The Rmail command b, rmail-bury, buries the Rmail buffer and its summary without expunging and saving the Rmail file.


34.2 在消息内滚动

34.2 Scrolling Within a Message

当 Rmail 显示的消息无法在屏幕上显示时,您必须滚动浏览该消息才能阅读其余内容。您可以使用常用的滚动命令来完成此操作:C-vM-vM-< (请参阅滚动),但在 Rmail 中滚动非常频繁,因此应该更容易。

When Rmail displays a message that does not fit on the screen, you must scroll through it to read the rest. You could do this with the usual scrolling commands: C-v, M-v and M-< (see Scrolling), but in Rmail scrolling is so frequent that it deserves to be easier.

SPC
SPC

向前滚动 ( scroll-up-command)。

Scroll forward (scroll-up-command).

DEL
DEL
S-SPC
S-SPC

向后滚动 ( scroll-down-command)。

Scroll backward (scroll-down-command).

.
.

滚动到消息开头 ( rmail-beginning-of-message)。

Scroll to start of message (rmail-beginning-of-message).

/
/

滚动到消息末尾 ( rmail-end-of-message)。

Scroll to end of message (rmail-end-of-message).

由于阅读邮件时最常见的操作是整屏滚动浏览邮件,因此 Rmail 使SPCDEL (或)分别与( ) 和( ) 执行相同的操作。S-SPCC-vscroll-up-commandM-vscroll-down-command

Since the most common thing to do while reading a message is to scroll through it by screenfuls, Rmail makes SPC and DEL (or S-SPC) do the same as C-v (scroll-up-command) and M-v (scroll-down-command) respectively.

命令.( rmail-beginning-of-message) 滚动回所选消息的开头。这与M-<:一方面,它没有设置标记;另一方面,它也没有设置标记。另一方面,如果您更改了当前消息的缓冲区边界(例如,通过编辑,请参阅在消息内编辑),它会重置当前消息的缓冲区边界。类似地,命令/ ( rmail-end-of-message) 向前滚动到所选消息的末尾。

The command . (rmail-beginning-of-message) scrolls back to the beginning of the selected message. This is not quite the same as M-<: for one thing, it does not set the mark; for another, it resets the buffer boundaries of the current message if you have changed them (e.g., by editing, see Editing Within a Message). Similarly, the command / (rmail-end-of-message) scrolls forward to the end of the selected message.


34.3 在消息之间移动

34.3 Moving Among Messages

处理消息最基本的事情就是阅读它。在 Rmail 中执行此操作的方法是使消息成为最新消息。通常的做法是按顺序移动文件,因为这是接收消息的顺序。当您输入 Rmail 时,您将定位到第一封尚未设为当前邮件的邮件(即第一封带有 '看不见' 属性;请参阅Rmail 属性)。向前查看其他新消息;向后移动以重新检查旧消息。

The most basic thing to do with a message is to read it. The way to do this in Rmail is to make the message current. The usual practice is to move sequentially through the file, since this is the order of receipt of messages. When you enter Rmail, you are positioned at the first message that you have not yet made current (that is, the first one that has the ‘unseen’ attribute; see Rmail Attributes). Move forward to see the other new messages; move backward to re-examine old messages.

n
n

移至下一条未删除的邮件,跳过任何插入的已删除邮件 ( rmail-next-undeleted-message)。

Move to the next nondeleted message, skipping any intervening deleted messages (rmail-next-undeleted-message).

p
p

移至上一条未删除的消息 ( rmail-previous-undeleted-message)。

Move to the previous nondeleted message (rmail-previous-undeleted-message).

M-n
M-n

移至下一条消息,包括已删除的消息 ( rmail-next-message)。

Move to the next message, including deleted messages (rmail-next-message).

M-p
M-p

移至上一条消息,包括已删除的消息 ( rmail-previous-message)。

Move to the previous message, including deleted messages (rmail-previous-message).

C-c C-n
C-c C-n

移至与当前邮件主题相同的下一封邮件 ( rmail-next-same-subject)。

Move to the next message with the same subject as the current one (rmail-next-same-subject).

C-c C-p
C-c C-p

移至与当前邮件主题相同的上一条邮件 ( rmail-previous-same-subject)。

Move to the previous message with the same subject as the current one (rmail-previous-same-subject).

j
j

移至第一条消息。使用参数n,移动到消息编号n ( rmail-show-message)。

Move to the first message. With argument n, move to message number n (rmail-show-message).

>
>

移至最后一条消息 ( rmail-last-message)。

Move to the last message (rmail-last-message).

<
<

移至第一条消息 ( rmail-first-message)。

Move to the first message (rmail-first-message).

M-s regexp RET
M-s regexp RET

移至下一条包含正则表达式 ( rmail-search) 匹配项的消息。

Move to the next message containing a match for regexp (rmail-search).

- M-s regexp RET
- M-s regexp RET

移至包含regexp匹配项的上一条消息。 (这是M-s带有否定论证的。)

Move to the previous message containing a match for regexp. (This is M-s with a negative argument.)

np是 Rmail 中消息之间移动的常用方式。它们按顺序浏览邮件,但跳过已删除的邮件,这通常是您想要做的。它们的命令定义被命名为rmail-next-undeleted-messagermail-previous-undeleted-message。如果您不想跳过已删除的邮件(例如,如果您想移至某封邮件以取消删除它),请使用变体M-nM-p (rmail-next-messagermail-previous-message)。这些命令中的任何一个的数字参数都用作重复计数。

n and p are the usual way of moving among messages in Rmail. They move through the messages sequentially, but skip over deleted messages, which is usually what you want to do. Their command definitions are named rmail-next-undeleted-message and rmail-previous-undeleted-message. If you do not want to skip deleted messages—for example, if you want to move to a message to undelete it—use the variants M-n and M-p (rmail-next-message and rmail-previous-message). A numeric argument to any of these commands serves as a repeat count.

在 Rmail 中,您可以通过仅键入数字来指定数字参数。您无需C-u先输入。您还可以通过仅键入 来指定负参数-

In Rmail, you can specify a numeric argument by typing just the digits. You don’t need to type C-u first. You can also specify a negative argument by typing just -.

M-s( )命令rmail-search是 Rmail 的搜索版本。通常的增量搜索命令C-s在 Rmail 中有效,但它仅在当前邮件内搜索。的目的 M-s是搜索另一条消息。它以非增量方式读取正则表达式(请参阅正则表达式的语法),然后从以下消息的开头开始搜索匹配项。然后它选择该消息。如果regexp为空,M-s则重复使用上次使用的 regexp。

The M-s (rmail-search) command is Rmail’s version of search. The usual incremental search command C-s works in Rmail, but it searches only within the current message. The purpose of M-s is to search for another message. It reads a regular expression (see Syntax of Regular Expressions) nonincrementally, then searches starting at the beginning of the following message for a match. It then selects that message. If regexp is empty, M-s reuses the regexp used the previous time.

要在文件中向后搜索另一条消息,请给出M-s否定参数。在 Rmail 中,您可以使用 来执行此操作- M-s。这将从上一条消息的末尾开始搜索。

To search backward in the file for another message, give M-s a negative argument. In Rmail you can do this with - M-s. This begins searching from the end of the previous message.

还可以根据标签搜索消息。请参阅标签

It is also possible to search for a message based on labels. See Labels.

C-c C-n( )命令rmail-next-same-subject移动到与当前邮件主题相同的下一条邮件。前缀参数用作重复计数。如果参数为负,则该命令向后移动,其作用类似于C-c C-p ( rmail-previous-same-subject)。比较主题时,这些命令会忽略通常添加到回复主题的前缀。这些命令对于读取与同一主题(又称线程)相关的所有消息非常有用。

The C-c C-n (rmail-next-same-subject) command moves to the next message with the same subject as the current one. A prefix argument serves as a repeat count. With a negative argument, this command moves backward, acting like C-c C-p (rmail-previous-same-subject). When comparing subjects, these commands ignore the prefixes typically added to the subjects of replies. These commands are useful for reading all of the messages pertaining to the same subject, a.k.a. thread.

要移动到由绝对消息编号指定的消息,请使用j ( rmail-show-message) 并将消息编号作为参数。不带参数,j选择第一条消息。 < ( rmail-first-message) 还选择第一条消息。 > ( rmail-last-message) 选择最后一条消息。

To move to a message specified by absolute message number, use j (rmail-show-message) with the message number as argument. With no argument, j selects the first message. < (rmail-first-message) also selects the first message. > (rmail-last-message) selects the last message.


34.4 删除消息

34.4 Deleting Messages

当您不再需要保留消息时,可以将其删除。这会将其标记为可忽略,并且某些 Rmail 命令会假装它不再存在;但它仍然在 Rmail 文件中占有一席之地,并且仍然具有其邮件编号。

When you no longer need to keep a message, you can delete it. This flags it as ignorable, and some Rmail commands pretend it is no longer present; but it still has its place in the Rmail file, and still has its message number.

清除Rmail 文件实际上会删除已删除的邮件。剩余的消息被连续地重新编号。

Expunging the Rmail file actually removes the deleted messages. The remaining messages are renumbered consecutively.

d
d

删除当前消息,并移至下一条未删除的消息 ( rmail-delete-forward)。

Delete the current message, and move to the next nondeleted message (rmail-delete-forward).

C-d
C-d

删除当前消息,并移至上一条未删除的消息 ( rmail-delete-backward)。

Delete the current message, and move to the previous nondeleted message (rmail-delete-backward).

u
u

取消删除当前消息,或返回到上一条已删除的消息并取消删除 ( rmail-undelete-previous-message)。

Undelete the current message, or move back to the previous deleted message and undelete it (rmail-undelete-previous-message).

x
x

删除 Rmail 文件 ( rmail-expunge)。

Expunge the Rmail file (rmail-expunge).

有两个 Rmail 命令用于删除邮件。两者都删除当前消息并选择另一条消息。 d ( rmail-delete-forward) 移动到下一条消息,跳过已删除的消息,而C-d( rmail-delete-backward) 移动到上一条未删除的消息。如果在指定方向上没有可移动到的未删除邮件,则刚刚删除的邮件将保持当前状态。数字前缀参数用作重复计数,以允许在单个命令中删除多条消息。否定参数颠倒了d和的含义C-d

There are two Rmail commands for deleting messages. Both delete the current message and select another. d (rmail-delete-forward) moves to the following message, skipping messages already deleted, while C-d (rmail-delete-backward) moves to the previous nondeleted message. If there is no nondeleted message to move to in the specified direction, the message that was just deleted remains current. A numeric prefix argument serves as a repeat count, to allow deletion of several messages in a single command. A negative argument reverses the meaning of d and C-d.

每当 Rmail 删除一条消息时,它都会运行 hook rmail-delete-message-hook。当调用钩子函数时,消息已被标记为删除,但它仍然是 Rmail 缓冲区中的当前消息。

Whenever Rmail deletes a message, it runs the hook rmail-delete-message-hook. When the hook functions are invoked, the message has been marked deleted, but it is still the current message in the Rmail buffer.

要使所有已删除的邮件最终从 Rmail 文件中消失,请键入x( rmail-expunge)。在执行此操作之前,您仍然可以 取消删除已删除的邮件。在大多数情况下,取消删除命令u ( rmail-undelete-previous-message) 旨在取消命令的效果。d如果当前消息被删除,它会取消删除当前消息。否则,它将向后移动到以前的消息,直到找到已删除的消息,并取消删除该消息。数字前缀参数用作重复计数,以允许在单个命令中取消删除多条消息。

To make all the deleted messages finally vanish from the Rmail file, type x (rmail-expunge). Until you do this, you can still undelete the deleted messages. The undeletion command, u (rmail-undelete-previous-message), is designed to cancel the effect of a d command in most cases. It undeletes the current message if the current message is deleted. Otherwise it moves backward to previous messages until a deleted message is found, and undeletes that message. A numeric prefix argument serves as a repeat count, to allow undeletion of several messages in a single command.

您通常可以使用 a 撤消da,u因为它u 会移回并取消删除已删除的邮件d。但是,当d跳过被删除的消息之后的一些已删除的消息时,这不起作用;然后该u命令会取消删除最后一条被跳过的消息。没有干净的方法可以避免这个问题。但是,通过重复该u命令,您最终可以返回到要取消删除的邮件。您还可以使用该命令选择特定的已删除邮件M-p,然后键入u以取消删除。

You can usually undo a d with a u because the u moves back to and undeletes the message that the d deleted. But this does not work when the d skips a few already-deleted messages that follow the message being deleted; then the u command undeletes the last of the messages that were skipped. There is no clean way to avoid this problem. However, by repeating the u command, you can eventually get back to the message that you intend to undelete. You can also select a particular deleted message with the M-p command, then type u to undelete it.

已删除的消息包含 '已删除' 属性,以及结果 '已删除删除当前消息时,模式行中会出现 '。事实上,删除或取消删除一条消息无非就是添加或删除这个属性。请参阅Rmail 属性

A deleted message has the ‘deleted’ attribute, and as a result ‘deleted’ appears in the mode line when the current message is deleted. In fact, deleting or undeleting a message is nothing more than adding or removing this attribute. See Rmail Attributes.


34.5 Rmail 文件和收件箱

34.5 Rmail Files and Inboxes

当您在本地接收邮件时,操作系统会将您收到的邮件放入我们称为“收件箱”的文件中。当您启动 Rmail 时,它会运行一个 C 程序,movemail将新邮件从收件箱复制到主 Rmail 文件中,该文件还包含从以前的 Rmail 会话保存的其他邮件。您实际上是在这个文件中使用 Rmail 阅读邮件的。此操作称为获取新邮件。您可以随时在 Rmail 中键入 来获取新邮件g

When you receive mail locally, the operating system places incoming mail for you in a file that we call your inbox. When you start up Rmail, it runs a C program called movemail to copy the new messages from your inbox into your primary Rmail file, which also contains other messages saved from previous Rmail sessions. It is in this file that you actually read the mail with Rmail. This operation is called getting new mail. You can get new mail at any time in Rmail by typing g.

该变量rmail-primary-inbox-list包含主 Rmail 文件收件箱中的文件列表。如果您没有显式设置此变量,Rmail 将使用MAIL环境变量,或者作为最后的手段,使用基于 rmail-spool-directory.默认收件箱文件取决于您的操作系统;通常是/var/mail/用户名, /var/spool/mail/用户名, 或者 /usr/spool/mail/用户名

The variable rmail-primary-inbox-list contains a list of the files that are inboxes for your primary Rmail file. If you don’t set this variable explicitly, Rmail uses the MAIL environment variable, or, as a last resort, a default inbox based on rmail-spool-directory. The default inbox file depends on your operating system; often it is /var/mail/username, /var/spool/mail/username, or /usr/spool/mail/username.

您可以使用以下命令为当前会话的任何 Rmail 文件指定收件箱文件set-rmail-inbox-list;请参阅多个 Rmail 文件

You can specify the inbox file(s) for any Rmail file for the current session with the command set-rmail-inbox-list; see Multiple Rmail Files.

拥有单独的 Rmail 文件和收件箱有两个原因。

There are two reasons for having separate Rmail files and inboxes.

  1. 收件箱文件格式因操作系统和所使用的其他邮件软件而异。 Rmail 中只有一部分需要了解替代方案,并且它只需要了解如何将所有替代方案转换为 Rmail 自己的格式。
  2. The inbox file format varies between operating systems and according to the other mail software in use. Only one part of Rmail needs to know about the alternatives, and it need only understand how to convert all of them to Rmail’s own format.
  3. 访问收件箱文件而不会有丢失邮件的危险是非常麻烦的,因为需要与邮件传递联锁。此外,不同的操作系统使用不同的互锁技术。将邮件从收件箱一次性移出到单独的 Rmail 文件中的策略避免了在 Rmail 的所有其余部分中进行互锁的需要,因为只有 Rmail 对 Rmail 文件进行操作。
  4. It is very cumbersome to access an inbox file without danger of losing mail, because it is necessary to interlock with mail delivery. Moreover, different operating systems use different interlocking techniques. The strategy of moving mail out of the inbox once and for all into a separate Rmail file avoids the need for interlocking in all the rest of Rmail, since only Rmail operates on the Rmail file.

Rmail 使用标准 '信箱' 格式,由 Unix 和 GNU 系统为收件箱文件引入,作为 Rmail 文件的内部格式。 (事实上​​,mbox 格式有一些略有不同。差异并不是很重要,但您可以设置变量 rmail-mbox-format来告诉 Rmail 您的系统使用哪种形式。有关更多详细信息,请参阅该变量的文档。)

Rmail uses the standard ‘mbox’ format, introduced by Unix and GNU systems for inbox files, as its internal format of Rmail files. (In fact, there are a few slightly different mbox formats. The differences are not very important, but you can set the variable rmail-mbox-format to tell Rmail which form your system uses. See that variable’s documentation for more details.)

当收到新邮件时,Rmail首先将新邮件从收件箱文件复制到Rmail文件中;然后保存Rmail文件;然后它会清除收件箱文件。这样,系统崩溃可能会导致收件箱和 Rmail 文件之间出现重复邮件,但不会丢失邮件。如果rmail-preserve-inbox为非nil,则Rmail收到新邮件时不会清除收件箱文件。例如,您可能希望在旅行时用于通过 POP 检查邮件的便携式计算机上进行此项设置,以便您的邮件将保留在服务器上,并且稍后可以将其保存在主桌面工作站上。

When getting new mail, Rmail first copies the new mail from the inbox file to the Rmail file; then it saves the Rmail file; then it clears out the inbox file. This way, a system crash may cause duplication of mail between the inbox and the Rmail file, but cannot lose mail. If rmail-preserve-inbox is non-nil, then Rmail does not clear out the inbox file when it gets new mail. You may wish to set this, for example, on a portable computer you use to check your mail via POP while traveling, so that your mail will remain on the server and you can save it later on your main desktop workstation.

在某些情况下,Rmail 会间接从收件箱文件复制新邮件。首先,它运行movemail程序将邮件从收件箱移动到一个名为的中间文件 .newmail-收件箱名称,与 Rmail 文件位于同一目录中。然后 Rmail 合并该文件中的新邮件,保存 Rmail 文件,然后删除中间文件。如果在错误的时间发生崩溃,该文件将继续存在,并且 Rmail 下次从该收件箱收到新邮件时将再次使用它。

In some cases, Rmail copies the new mail from the inbox file indirectly. First it runs the movemail program to move the mail from the inbox to an intermediate file called .newmail-inboxname, in the same directory as the Rmail file. Then Rmail merges the new mail from that file, saves the Rmail file, and only then deletes the intermediate file. If there is a crash at the wrong time, this file continues to exist, and Rmail will use it again the next time it gets new mail from that inbox.

如果 Rmail 无法转换数据 .newmail-收件箱名称转换为 mbox 格式,它将文件重命名为 回复邮件。nn是一个整数,选择该整数以使名称唯一)以便 Rmail 不会再次遇到数据问题。您应该查看该文件,找到任何令 Rmail 感到困惑的消息(可能包含控制下划线字符、八进制代码 037),然后将其删除。然后您可以使用1 g从更正的文件中获取新邮件。

If Rmail is unable to convert the data in .newmail-inboxname into mbox format, it renames the file to RMAILOSE.n (n is an integer chosen to make the name unique) so that Rmail will not have trouble with the data again. You should look at the file, find whatever message confuses Rmail (probably one that includes the control-underscore character, octal code 037), and delete it. Then you can use 1 g to get new mail from the corrected file.


34.6 多个Rmail文件

34.6 Multiple Rmail Files

默认情况下,Rmail 在您的主 Rmail 文件上运行,该文件名为 ~/RMAIL并从系统收件箱文件接收传入的邮件。但您也可以拥有其他 Rmail 文件并使用 Rmail 对其进行编辑。这些文件可以通过它们自己的收件箱接收邮件,或者您可以使用显式 Rmail 命令将邮件移入其中(请参阅将邮件复制到文件中)。

Rmail operates by default on your primary Rmail file, which is named ~/RMAIL and receives your incoming mail from your system inbox file. But you can also have other Rmail files and edit them with Rmail. These files can receive mail through their own inboxes, or you can move messages into them with explicit Rmail commands (see Copying Messages Out to Files).

i file RET
i file RET

将文件读入 Emacs 并在其上运行 Rmail ( rmail-input)。

Read file into Emacs and run Rmail on it (rmail-input).

g
g

合并当前 Rmail 文件收件箱中的新邮件 ( rmail-get-new-mail)。

Merge new mail from current Rmail file’s inboxes (rmail-get-new-mail).

C-u g file RET
C-u g file RET

合并收件箱文件file中的新邮件。

Merge new mail from inbox file file.

要在主 Rmail 文件以外的文件上运行 Rmail,您可以在 Rmail 中使用i( rmail-input) 命令。这会以 Rmail 模式访问该文件。即使不在 Rmail 中,您也可以使用M-x rmail-input,但键入 更容易C-u M-x rmail,它可以完成相同的操作。

To run Rmail on a file other than your primary Rmail file, you can use the i (rmail-input) command in Rmail. This visits the file in Rmail mode. You can use M-x rmail-input even when not in Rmail, but it is easier to type C-u M-x rmail, which does the same thing.

您读取的文件i通常应该是有效的 mbox 文件。如果不是,Rmail 会尝试将其文本转换为 mbox 格式,并访问缓冲区中转换后的文本。如果保存缓冲区,则会转换文件。

The file you read with i should normally be a valid mbox file. If it is not, Rmail tries to convert its text to mbox format, and visits the converted text in the buffer. If you save the buffer, that converts the file.

如果指定的文件名不存在,则i初始化一个新缓冲区以创建新的 Rmail 文件。

If you specify a file name that doesn’t exist, i initializes a new buffer for creating a new Rmail file.

您还可以从菜单中选择 Rmail 文件。在“分类”菜单中,选择“输入 Rmail 文件”项;然后选择您想要的 Rmail 文件。变量rmail-secondary-file-directoryrmail-secondary-file-regexp指定在菜单中提供哪些文件:第一个变量表示在哪个目录中找到它们;第二个表示要提供该目录中的哪些文件(所有与正则表达式匹配的文件)。如果没有文件匹配,则无法选择此菜单项。这些变量也适用于选择输出文件(请参阅将消息复制到文件)。

You can also select an Rmail file from a menu. In the Classify menu, choose the Input Rmail File item; then choose the Rmail file you want. The variables rmail-secondary-file-directory and rmail-secondary-file-regexp specify which files to offer in the menu: the first variable says which directory to find them in; the second says which files in that directory to offer (all those that match the regular expression). If no files match, you cannot select this menu item. These variables also apply to choosing a file for output (see Copying Messages Out to Files).

要使用的收件箱文件由变量 指定 rmail-inbox-list,该变量在 Rmail 模式下是本地缓冲区。作为一个特殊的例外,如果您没有为主 Rmail 文件指定收件箱文件,它将使用MAIL环境变量或您的标准系统收件箱。

The inbox files to use are specified by the variable rmail-inbox-list, which is buffer-local in Rmail mode. As a special exception, if you have specified no inbox files for your primary Rmail file, it uses the MAIL environment variable, or your standard system inbox.

命令g( rmail-get-new-mail) 将邮件从收件箱合并到当前 Rmail 文件中。如果 Rmail 文件没有收件箱,g则不执行任何操作。该命令M-x rmail还将新邮件合并到您的主 Rmail 文件中。

The g command (rmail-get-new-mail) merges mail into the current Rmail file from its inboxes. If the Rmail file has no inboxes, g does nothing. The command M-x rmail also merges new mail into your primary Rmail file.

要合并来自非常用收件箱的文件的邮件,请为该 g键指定一个数字参数,如 中所示C-u g。然后它读取文件名并合并该文件中的邮件。g使用 with 参数时,不会以任何方式删除或更改收件箱文件。因此,这是将一个消息文件合并到另一个消息文件中的通用方法。

To merge mail from a file that is not the usual inbox, give the g key a numeric argument, as in C-u g. Then it reads a file name and merges mail from that file. The inbox file is not deleted or changed in any way when g with an argument is used. This is, therefore, a general way of merging one file of messages into another.


34.7 将消息复制到文件中

34.7 Copying Messages Out to Files

这些命令将消息从 Rmail 文件复制到另一个文件中。

These commands copy messages from an Rmail file into another file.

o file RET
o file RET

将当前消息的完整副本附加到文件 file ( ) rmail-output

Append a full copy of the current message to the file file (rmail-output).

C-o file RET
C-o file RET

将显示的当前消息的副本附加到文件 file ( ) rmail-output-as-seen

Append a copy of the current message, as displayed, to the file file (rmail-output-as-seen).

w file RET
w file RET

仅将消息正文输出到文件file,并采用消息中的默认文件名'主题' 标头。

Output just the message body to the file file, taking the default file name from the message ‘Subject’ header.

命令o并将C-o当前消息复制到指定文件中,并将其添加到末尾。正前缀参数用作重复计数:许多连续消息将被复制到指定文件,从当前消息开始并忽略已删除的消息。

The commands o and C-o copy the current message into a specified file, adding it at the end. A positive prefix argument serves as a repeat count: that many consecutive messages will be copied to the specified file, starting with the current one and ignoring deleted messages.

这两个命令的主要区别在于复制的数量:o复制完整的邮件标头,即使它们并非全部可见,而 C-o精确复制当前显示的标头,不再复制。请参阅消息显示。此外,o如果文件是 Babyl 格式,则将消息转换为 Babyl 格式(Emacs 版本 22 及之前的 Rmail 使用);C-o根本无法输出到 Babyl 文件。

The two commands differ mainly in how much to copy: o copies the full message headers, even if they are not all visible, while C-o copies exactly the headers currently displayed and no more. See Display of Messages. In addition, o converts the message to Babyl format (used by Rmail in Emacs version 22 and before) if the file is in Babyl format; C-o cannot output to Babyl files at all.

如果当前在 Emacs 缓冲区中访问输出文件,则输出命令会将消息附加到该缓冲区。最终由您将缓冲区保存在其文件中。

If the output file is currently visited in an Emacs buffer, the output commands append the message to that buffer. It is up to you to save the buffer eventually in its file.

有时您可能会收到一条消息,其正文包含文件的内容。您可以使用w命令 ( )将正文保存到文件(不包括消息头)rmail-output-body-to-file。这些消息通常在“主题' 字段,因此该w命令使用 '主题' 字段作为输出文件名的默认值(替换一些无法在文件名中使用的字符后)。但是,文件名是使用迷你缓冲区读取的,因此您可以根据需要指定不同的名称。

Sometimes you may receive a message whose body holds the contents of a file. You can save the body to a file (excluding the message header) with the w command (rmail-output-body-to-file). Often these messages contain the intended file name in the ‘Subject’ field, so the w command uses the ‘Subject’ field as the default for the output file name (after replacing some characters that cannot be portably used in file names). However, the file name is read using the minibuffer, so you can specify a different name if you wish.

您还可以将消息输出到通过菜单选择的 Rmail 文件。在 Classify 菜单中,选择 Output Rmail File 菜单项;然后选择您想要的 Rmail 文件。这会将当前消息输出到该文件,就像o命令一样。变量 rmail-secondary-file-directoryrmail-secondary-file-regexp指定在菜单中提供哪些文件:第一个变量表示在哪个目录中找到它们;第二个表示要提供该目录中的哪些文件(所有与正则表达式匹配的文件)。如果没有文件匹配,则无法选择此菜单项。

You can also output a message to an Rmail file chosen with a menu. In the Classify menu, choose the Output Rmail File menu item; then choose the Rmail file you want. This outputs the current message to that file, like the o command. The variables rmail-secondary-file-directory and rmail-secondary-file-regexp specify which files to offer in the menu: the first variable says which directory to find them in; the second says which files in that directory to offer (all those that match the regular expression). If no files match, you cannot select this menu item.

o使用或复制消息会为C-o消息的原始副本提供 '提交' 属性,因此 '提交当此类消息当前存在时,模式行中会出现 '。

Copying a message with o or C-o gives the original copy of the message the ‘filed’ attribute, so that ‘filed’ appears in the mode line when such a message is current.

如果您想只保留每封邮件的一个副本,请将变量设置rmail-delete-after-outputt;然后 oC-ow命令在复制后删除原始消息。 (如果您愿意,您可以在之后取消删除它,请参阅 删除消息。)

If you like to keep just a single copy of every mail message, set the variable rmail-delete-after-output to t; then the o, C-o and w commands delete the original message after copying it. (You can undelete it afterward if you wish, see Deleting Messages.)

默认情况下,o将保留其输出的消息的已删除状态,就像原始消息一样;因此,在输出之前删除的消息将在输出文件中显示为已删除。将变量设置rmail-output-reset-deleted-flag为非值nil会抵消以下要求:消息的副本将重置其已删除状态,因此该消息将在输出文件中显示为未删除。此外,当该变量为非时nil,指定正参数 时,o在查找要输出的连续消息时不会忽略已删除的消息。

By default, o will leave the deleted status of a message it outputs as it was on the original message; thus, a message deleted before it was output will appear as deleted in the output file. Setting the variable rmail-output-reset-deleted-flag to a non-nil value countermands that: the copy of the message will have its deleted status reset, so the message will appear as undeleted in the output file. In addition, when this variable is non-nil, specifying a positive argument to o will not ignore deleted messages when looking for consecutive messages to output.

该变量rmail-output-file-alist允许您根据当前消息的内容指定输出文件的智能默认值。该值应该是一个列表,其元素具有以下形式:

The variable rmail-output-file-alist lets you specify intelligent defaults for the output file, based on the contents of the current message. The value should be a list whose elements have this form:

正则表达式名称表达式
(regexp . name-exp)

如果当前消息中存在regexp匹配项,则输出的默认文件名是name-exp。如果多个元素与消息匹配,则第一个匹配元素决定默认文件名。子表达式name-exp可以是给出要使用的文件名的字符串常量,或者更一般地,它可以是产生字符串形式的文件名的任何 Lisp 表达式。 rmail-output-file-alist 适用于oC-o

If there’s a match for regexp in the current message, then the default file name for output is name-exp. If multiple elements match the message, the first matching element decides the default file name. The subexpression name-exp may be a string constant giving the file name to use, or more generally it may be any Lisp expression that yields a file name as a string. rmail-output-file-alist applies to both o and C-o.

rmail-file-nameRmail 可以根据变量 的值自动将消息从主 Rmail 文件(指定的文件)保存到其他文件rmail-automatic-folder-directives。该变量是一个元素列表 ('指令') 表示哪些消息保存在哪里。每个指令都是一个由输出文件组成的列表,后跟一对或多对标头名称和正则表达式。如果消息的标头与指定的正则表达式匹配,则该消息将保存到给定文件中。如果指令有多个标头条目,则所有标头条目都必须匹配。 Rmail 在显示来自文件的消息时检查指令rmail-file-name,并应用第一个匹配的指令(如果有)。如果输出文件为 nil,则消息将被删除,而不是保存。例如,您可以使用此功能将来自特定地址或具有特定主题的邮件保存到专用文件中。

Rmail can automatically save messages from your primary Rmail file (the one that rmail-file-name specifies) to other files, based on the value of the variable rmail-automatic-folder-directives. This variable is a list of elements (‘directives’) that say which messages to save where. Each directive is a list consisting of an output file, followed by one or more pairs of a header name and a regular expression. If a message has a header matching the specified regular expression, that message is saved to the given file. If the directive has more than one header entry, all must match. Rmail checks directives when it shows a message from the file rmail-file-name, and applies the first that matches (if any). If the output file is nil, the message is deleted, not saved. For example, you can use this feature to save messages from a particular address, or with a particular subject, to a dedicated file.


34.8 标签

34.8 Labels

每条消息都可以分配有各种标签作为分类手段。每个标签都有一个名称;不同的名字是不同的标签。任何给定的标签在特定消息上要么存在,要么不存在。一些标签名称具有标准含义,并在适当的时候由 Rmail 自动赋予邮件;这些特殊标签称为属性。 (请参阅Rmail 属性。)所有其他标签仅由用户分配。

Each message can have various labels assigned to it as a means of classification. Each label has a name; different names are different labels. Any given label is either present or absent on a particular message. A few label names have standard meanings and are given to messages automatically by Rmail when appropriate; these special labels are called attributes. (See Rmail Attributes.) All other labels are assigned only by users.

a label RET
a label RET

将标签label分配给当前消息 ( rmail-add-label)。

Assign the label label to the current message (rmail-add-label).

k label RET
k label RET

从当前消息中删除标签 label (rmail-kill-label )。

Remove the label label from the current message (rmail-kill-label).

C-M-n labels RET
C-M-n labels RET

移至具有标签 ( ) 之一的下一条 消息rmail-next-labeled-message

Move to the next message that has one of the labels labels (rmail-next-labeled-message).

C-M-p labels RET
C-M-p labels RET

移至具有标签 ( ) 之一的上一条 消息rmail-previous-labeled-message

Move to the previous message that has one of the labels labels (rmail-previous-labeled-message).

l labels RET
l labels RET
C-M-l labels RET
C-M-l labels RET

对包含任何标签 ( )的所有消息进行摘要rmail-summary-by-labels

Make a summary of all messages containing any of the labels labels (rmail-summary-by-labels).

a( rmail-add-label) 和k ( )命令rmail-kill-label允许您分配或删除当前消息上的任何标签。如果标签参数为空,则表示分配或删除最近分配或删除的标签。

The a (rmail-add-label) and k (rmail-kill-label) commands allow you to assign or remove any label on the current message. If the label argument is empty, it means to assign or remove the label most recently assigned or removed.

一旦您给了邮件标签并根据需要对其进行分类,就可以通过三种方式使用这些标签:移动、摘要和排序。

Once you have given messages labels to classify them as you wish, there are three ways to use the labels: in moving, in summaries, and in sorting.

C-M-n labels RET ( rmail-next-labeled-message) 移动到具有某个标签labels的下一条消息。参数labels指定一个或多个标签名称,以逗号分隔。 C-M-p ( rmail-previous-labeled-message) 类似,但向后移动到之前的消息。任一命令的数字参数用作重复计数。

C-M-n labels RET (rmail-next-labeled-message) moves to the next message that has one of the labels labels. The argument labels specifies one or more label names, separated by commas. C-M-p (rmail-previous-labeled-message) is similar, but moves backwards to previous messages. A numeric argument to either command serves as a repeat count.

命令 ( ) 显示仅包含至少具有一组指定标签的消息的摘要。参数labels是一个或多个标签名称,以逗号分隔。有关摘要的信息, 请参阅摘要。C-M-l labels RETrmail-summary-by-labels

The command C-M-l labels RET (rmail-summary-by-labels) displays a summary containing only the messages that have at least one of a specified set of labels. The argument labels is one or more label names, separated by commas. See Summaries, for information on summaries.

如果,或 的 labels参数为空,则意味着使用为任何这些命令指定的最后一组标签。 C-M-nC-M-pC-M-l

If the labels argument to C-M-n, C-M-p or C-M-l is empty, it means to use the last set of labels specified for any of these commands.

有关使用标签对邮件进行排序的信息, 请参阅对 Rmail 文件进行排序。

See Sorting the Rmail File, for information on sorting messages with labels.


34.9 Rmail属性

34.9 Rmail Attributes

一些标签,例如 '已删除' 和 '提交' 具有内置含义,Rmail 在适当的时间自动将它们分配给邮件;这些标签称为属性。以下是 Rmail 属性列表:

Some labels such as ‘deleted’ and ‘filed’ have built-in meanings, and Rmail assigns them to messages automatically at appropriate times; these labels are called attributes. Here is a list of Rmail attributes:

'看不见'
unseen

意味着该消息从未是最新的。当消息来自收件箱文件时分配给消息,并在消息成为当前消息时删除。当您启动 Rmail 时,它首先显示具有此属性的第一条消息。

Means the message has never been current. Assigned to messages when they come from an inbox file, and removed when a message is made current. When you start Rmail, it initially shows the first message that has this attribute.

'已删除'
deleted

表示该消息已被删除。由删除命令分配并由取消删除命令删除(请参阅删除消息)。

Means the message is deleted. Assigned by deletion commands and removed by undeletion commands (see Deleting Messages).

'提交'
filed

意味着消息已被复制到其他文件中。由 oC-ofile 输出命令分配(请参阅将消息复制到文件)。

Means the message has been copied to some other file. Assigned by the o and C-o file output commands (see Copying Messages Out to Files).

'回答了'
answered

意味着您已经邮寄了对该消息的答复。由r 命令( rmail-reply)指定。请参阅发送回复

Means you have mailed an answer to the message. Assigned by the r command (rmail-reply). See Sending Replies.

'转发的'
forwarded

表示您已转发该消息。由f命令( rmail-forward)指定。请参阅发送回复

Means you have forwarded the message. Assigned by the f command (rmail-forward). See Sending Replies.

'已编辑'
edited

表示您已在 Rmail 中编辑了邮件文本。请参阅在消息内编辑

Means you have edited the text of the message within Rmail. See Editing Within a Message.

'怨恨'
resent

表示您已重新发送该消息。由命令分配M-x rmail-resend。请参阅发送回复

Means you have resent the message. Assigned by the command M-x rmail-resend. See Sending Replies.

'重试'
retried

表示您已重试发送失败的消息。由命令分配M-x rmail-retry-failure。请参阅发送回复

Means you have retried a failed outgoing message. Assigned by the command M-x rmail-retry-failure. See Sending Replies.

所有其他标签仅由用户分配或删除,并且没有标准含义。

All other labels are assigned or removed only by users, and have no standard meaning.


34.10 发送回复

34.10 Sending Replies

Rmail 有几个用于发送外发邮件的命令。有关使用消息模式的信息,包括与 Rmail 配合使用的某些功能,请参阅发送邮件。本节记录的是 Rmail 的特殊命令,用于输入用于撰写外发消息的邮件缓冲区。请注意,用于发送邮件的常用键C-x mC-x 4 m、 和C-x 5 m— 在 Rmail 模式下也能正常工作。

Rmail has several commands to send outgoing mail. See Sending Mail, for information on using Message mode, including certain features meant to work with Rmail. What this section documents are the special commands of Rmail for entering the mail buffer used to compose the outgoing message. Note that the usual keys for sending mail—C-x m, C-x 4 m, and C-x 5 m—also work normally in Rmail mode.

m
m

发送一个消息 (rmail-mail)。

Send a message (rmail-mail).

c
c

继续编辑已开始的外发消息 ( rmail-continue)。

Continue editing the already started outgoing message (rmail-continue).

r
r

发送对当前 Rmail 消息的回复 ( rmail-reply)。

Send a reply to the current Rmail message (rmail-reply).

f
f

将当前消息转发给其他用户 ( rmail-forward)。

Forward the current message to other users (rmail-forward).

C-u f
C-u f

将当前消息重新发送给其他用户 ( rmail-resend)。

Resend the current message to other users (rmail-resend).

M-m
M-m

尝试第二次发送退回邮件 ( rmail-retry-failure)。

Try sending a bounced message a second time (rmail-retry-failure).

在 Rmail 中发送消息的最常见原因是回复您正在阅读的消息。为此,请键入r ( rmail-reply)。这会在另一个窗口中显示邮件撰写缓冲区,非常类似于C-x 4 m,但会预先初始化 '主题','','CC','回复中' 和 '参考' 基于您要回复的消息的标头字段。这 '' 字段以发送您收到的消息的人的地址开始,并且 'CC' 字段以该消息的所有其他收件人开始。

The most common reason to send a message while in Rmail is to reply to the message you are reading. To do this, type r (rmail-reply). This displays a mail composition buffer in another window, much like C-x 4 m, but preinitializes the ‘Subject’, ‘To’, ‘CC’, ‘In-Reply-To’ and ‘References’ header fields based on the message you are replying to. The ‘To’ field starts out as the address of the person who sent the message you received, and the ‘CC’ field starts out with all the other recipients of that message.

您可以使用变量 排除某些收件人自动包含在回复中mail-dont-reply-to-names。它的值应该是一个正则表达式;任何匹配的收件人均被排除在 'CC' 场地。他们也被排除在“' 字段,除非这会使该字段留空。如果此变量为nil,那么您第一次撰写回复时,它会被初始化为与您自己的地址匹配的默认值。

You can exclude certain recipients from being included automatically in replies, using the variable mail-dont-reply-to-names. Its value should be a regular expression; any recipients that match are excluded from the ‘CC’ field. They are also excluded from the ‘To’ field, unless this would leave the field empty. If this variable is nil, then the first time you compose a reply it is initialized to a default value that matches your own address.

要仅回复原始邮件的发件人,请输入带有数字参数的回复命令:C-u r1 r。这省略了 'CC' 完全用于特定回复的字段。

To reply only to the sender of the original message, enter the reply command with a numeric argument: C-u r or 1 r. This omits the ‘CC’ field completely for a particular reply.

邮件撰写缓冲区初始化后,编辑和发送邮件将照常进行(请参阅发送邮件)。如果预先提供的标题字段不是您想要的,您可以对其进行编辑。您还可以使用诸如 之类的命令C-c C-y,该命令会拉入您正在回复的邮件(请参阅邮件命令)。您还可以切换到 Rmail 缓冲区,在那里选择不同的消息,切换回来,然后拉出新的当前消息。

Once the mail composition buffer has been initialized, editing and sending the mail goes as usual (see Sending Mail). You can edit the presupplied header fields if they are not what you want. You can also use commands such as C-c C-y, which yanks in the message that you are replying to (see Mail Commands). You can also switch to the Rmail buffer, select a different message there, switch back, and yank the new current message.

有时消息无法到达目的地。邮件程序通常会将失败的消息发送回给您,并附在失败消息中。 Rmail 命令M-m( rmail-retry-failure) 准备第二次发送相同的消息:它设置一个邮件撰写缓冲区,其中包含与以前相同的文本和标头字段。如果您C-c C-c立即键入,您将再次发送与第一次完全相同的消息。或者,您可以编辑文本或标题,然后发送。变量 的 rmail-retry-ignored-headers格式与 rmail-ignored-headers(请参阅消息的显示)相同,控制重试时从失败的消息中删除哪些标头。

Sometimes a message does not reach its destination. Mailers usually send the failed message back to you, enclosed in a failure message. The Rmail command M-m (rmail-retry-failure) prepares to send the same message a second time: it sets up a mail composition buffer with the same text and header fields as before. If you type C-c C-c right away, you send the message again exactly the same as the first time. Alternatively, you can edit the text or headers and then send it. The variable rmail-retry-ignored-headers, in the same format as rmail-ignored-headers (see Display of Messages), controls which headers are stripped from the failed message when retrying it.

在 Rmail 中发送邮件的另一个常见原因是将当前邮件 转发f给其他用户。 ( rmail-forward) 通过使用当前邮件作为文本以及表单的主题来预初始化邮件撰写缓冲区,从而轻松实现此目的,其中fromsubject是原始邮件的发件人和主题。您所要做的就是填写收件人并发送。当您转发邮件时,收件人会收到一封来自您的邮件,其中包含原始邮件的内容。 [from: subject]

Another frequent reason to send mail in Rmail is to forward the current message to other users. f (rmail-forward) makes this easy by preinitializing the mail composition buffer with the current message as the text, and a subject of the form [from: subject], where from and subject are the sender and subject of the original message. All you have to do is fill in the recipients and send. When you forward a message, recipients get a message which is from you, and which has the original message in its contents.

Rmail 提供两种转发消息的格式。默认使用 MIME 格式(请参阅消息显示)。这包括作为单独部分的原始消息。如果您愿意,可以通过将变量设置为rmail-enable-mime-composing来 使用更简单的格式nil。在这种情况下,Rmail 仅包含包含在两个分隔符行之间的原始消息。它还通过插入 ' 来修改以破折号开头的每一行- '在该行的开头。当您收到这种格式的转发消息时,如果它包含普通文本之外的内容(例如程序源代码),您可能会发现撤消该转换很有用。您可以通过选择转发的消息并键入 来完成此操作M-x unforward-rmail-message。此命令提取原始转发消息,删除插入的 '- '字符串,并将其作为一条单独的消息插入到 Rmail 文件中,紧跟在当前消息之后。

Rmail offers two formats for forwarded messages. The default is to use the MIME format (see Display of Messages). This includes the original message as a separate part. You can use a simpler format if you prefer, by setting the variable rmail-enable-mime-composing to nil. In this case, Rmail just includes the original message enclosed between two delimiter lines. It also modifies every line that starts with a dash, by inserting ‘-  at the start of the line. When you receive a forwarded message in this format, if it contains something besides ordinary text—for example, program source code—you might find it useful to undo that transformation. You can do this by selecting the forwarded message and typing M-x unforward-rmail-message. This command extracts the original forwarded message, deleting the inserted ‘-  strings, and inserts it into the Rmail file as a separate message immediately following the current one.

重发是类似于转发的另一种选择;不同之处在于,重新发送会发送一条来自原始发件人的消息,就像它到达您时一样 - 带有一些添加的标头字段('重新发送自' 和 '重新发送至') 来表明它是通过你来的。要在 Rmail 中重新发送消息,请使用C-u f。 (f运行 ,如果您提供数字参数, rmail-forward则会调用。)rmail-resend

Resending is an alternative similar to forwarding; the difference is that resending sends a message that is from the original sender, just as it reached you—with a few added header fields (‘Resent-From’ and ‘Resent-To’) to indicate that it came via you. To resend a message in Rmail, use C-u f. (f runs rmail-forward, which invokes rmail-resend if you provide a numeric argument.)

使用m( rmail-mail) 命令开始编辑非回复的外发消息。它将标头字段留空。它与 的唯一区别C-x 4 m是它使 Rmail 缓冲区可访问C-c C-y,正如r所做的那样。

Use the m (rmail-mail) command to start editing an outgoing message that is not a reply. It leaves the header fields empty. Its only difference from C-x 4 m is that it makes the Rmail buffer accessible for C-c C-y, just as r does.

c( )命令rmail-continue恢复编辑邮件撰写缓冲区,完成编辑已撰写的外发邮件,或更改已发送的邮件。

The c (rmail-continue) command resumes editing the mail composition buffer, to finish editing an outgoing message you were already composing, or to alter a message you have sent.

如果您将该变量设置rmail-mail-new-frame为非值nil,则开始发送消息的所有 Rmail 命令都会创建一个新框架来对其进行编辑。当您发送消息时,该框架将被删除。

If you set the variable rmail-mail-new-frame to a non-nil value, then all the Rmail commands to start sending a message create a new frame to edit it in. This frame is deleted when you send the message.

所有发送消息的 Rmail 命令都使用您选择的邮件撰写方法(请参阅邮件撰写方法)。

All the Rmail commands to send a message use the mail-composition method that you have chosen (see Mail-Composition Methods).


34.11 总结

34.11 Summaries

摘要是一个缓冲区,每条消息包含一行,为您提供 Rmail 文件中邮件的概述。每行显示邮件编号和日期、发件人、行数、标签和主题。当您移动到摘要行时,在摘要缓冲区中移动点会选择消息。几乎所有 Rmail 命令在摘要缓冲区中也有效;当在那里使用时,它们适用于摘要的当前行描述的消息。

A summary is a buffer containing one line per message to give you an overview of the mail in an Rmail file. Each line shows the message number and date, the sender, the line count, the labels, and the subject. Moving point in the summary buffer selects messages as you move to their summary lines. Almost all Rmail commands are valid in the summary buffer also; when used there, they apply to the message described by the current line of the summary.

摘要缓冲区仅适用于单个 Rmail 文件;如果您正在编辑多个 Rmail 文件,每个文件都可以有自己的摘要缓冲区。摘要缓冲区名称是通过附加 '-概括' 到 Rmail 缓冲区的名称。通常一次仅显示一个摘要缓冲区。

A summary buffer applies to a single Rmail file only; if you are editing multiple Rmail files, each one can have its own summary buffer. The summary buffer name is made by appending ‘-summary’ to the Rmail buffer’s name. Normally only one summary buffer is displayed at a time.


34.11.1 进行总结

34.11.1 Making Summaries

以下是为当前 Rmail 缓冲区创建摘要的命令。一旦 Rmail 缓冲区有了摘要,Rmail 缓冲区中的更改(例如删除或清除邮件以及获取新邮件)会自动更新摘要。

Here are the commands to create a summary for the current Rmail buffer. Once the Rmail buffer has a summary, changes in the Rmail buffer (such as deleting or expunging messages, and getting new mail) automatically update the summary.

h
h
C-M-h
C-M-h

总结所有消息 ( rmail-summary)。

Summarize all messages (rmail-summary).

l labels RET
l labels RET
C-M-l labels RET
C-M-l labels RET

汇总具有一个或多个指定标签 ( rmail-summary-by-labels) 的消息。

Summarize messages that have one or more of the specified labels (rmail-summary-by-labels).

C-M-r rcpts RET
C-M-r rcpts RET

汇总与指定收件人 ( rmail-summary-by-recipients) 匹配的邮件。

Summarize messages that match the specified recipients (rmail-summary-by-recipients).

C-M-t topic RET
C-M-t topic RET

汇总在其主题 ( ) 中与指定正则表达式主题匹配的消息 rmail-summary-by-topic

Summarize messages that have a match for the specified regexp topic in their subjects (rmail-summary-by-topic).

C-M-s regexp RET
C-M-s regexp RET

汇总标头与指定正则表达式 regexp ( rmail-summary-by-regexp) 匹配的消息。

Summarize messages whose headers match the specified regular expression regexp (rmail-summary-by-regexp).

C-M-f senders RET
C-M-f senders RET

汇总与指定发件人匹配的邮件。 ( rmail-summary-by-senders)。

Summarize messages that match the specified senders. (rmail-summary-by-senders).

hor C-M-h( )命令rmail-summary用缓冲区中所有消息的摘要填充当前 Rmail 缓冲区的摘要缓冲区。然后它在另一个窗口中显示并选择摘要缓冲区。

The h or C-M-h (rmail-summary) command fills the summary buffer for the current Rmail buffer with a summary of all the messages in the buffer. It then displays and selects the summary buffer in another window.

C-M-l labels RET( ) 进行部分摘要,仅提及具有一个或多个标签labelsrmail-summary-by-labels的消息。 标签应包含以逗号分隔的标签名称。

C-M-l labels RET (rmail-summary-by-labels) makes a partial summary mentioning only the messages that have one or more of the labels labels. labels should contain label names separated by commas.

C-M-r rcpts RET( ) 进行部分摘要,仅提及具有一个或多个与正则表达式rcptsrmail-summary-by-recipients匹配的收件人的邮件。这与 ' 相匹配','', 和 'CC' 标头(提供前缀参数以排除 'CC' 标题)。

C-M-r rcpts RET (rmail-summary-by-recipients) makes a partial summary mentioning only the messages that have one or more recipients matching the regular expression rcpts. This is matched against the ‘To’, ‘From’, and ‘CC’ headers (supply a prefix argument to exclude the ‘CC’ header).

C-M-t topic RET( ) 进行部分摘要,仅提及主题与正则表达式主题rmail-summary-by-topic匹配的消息。使用前缀参数,匹配的是整个消息,而不仅仅是主题。

C-M-t topic RET (rmail-summary-by-topic) makes a partial summary mentioning only the messages whose subjects have a match for the regular expression topic. With a prefix argument, the match is against the whole message, not just the subject.

C-M-s regexp RET( rmail-summary-by-regexp) 进行部分摘要,仅提及标题(包括日期和主题行)与正则表达式regexp匹配的邮件。

C-M-s regexp RET (rmail-summary-by-regexp) makes a partial summary that mentions only the messages whose headers (including the date and the subject lines) match the regular expression regexp.

C-M-f senders RET( rmail-summary-by-senders) 进行部分摘要,仅提及其 '' 字段与正则表达式发件人匹配。

C-M-f senders RET (rmail-summary-by-senders) makes a partial summary that mentions only the messages whose ‘From’ fields match the regular expression senders.

请注意,任何 Rmail 缓冲区都只有一个摘要缓冲区;进行任何类型的总结都会丢弃任何先前的总结。

Note that there is only one summary buffer for any Rmail buffer; making any kind of summary discards any previous summary.

该变量rmail-summary-window-size表示摘要窗口使用多少行。该变量 rmail-summary-line-count-flag控制消息的摘要行是否应包括消息的行计数。将此选项设置为nil可能会加快摘要的生成速度。

The variable rmail-summary-window-size says how many lines to use for the summary window. The variable rmail-summary-line-count-flag controls whether the summary line for a message should include the line count of the message. Setting this option to nil might speed up the generation of summaries.


34.11.2 编辑摘要

34.11.2 Editing in Summaries

您可以使用 Rmail 摘要缓冲区执行几乎在 Rmail 缓冲区本身中可以执行的任何操作。事实上,一旦有了摘要缓冲区,就无需切换回 Rmail 缓冲区。

You can use the Rmail summary buffer to do almost anything you can do in the Rmail buffer itself. In fact, once you have a summary buffer, there’s no need to switch back to the Rmail buffer.

您可以从摘要缓冲区中选择并显示 Rmail 缓冲区中的各种消息,只需将摘要缓冲区中的点移动到不同的行即可。使用什么 Emacs 命令来移动点并不重要;无论命令末尾出现哪个行点,都会在 Rmail 缓冲区中选择该消息。

You can select and display various messages in the Rmail buffer, from the summary buffer, just by moving point in the summary buffer to different lines. It doesn’t matter what Emacs command you use to move point; whichever line point is on at the end of the command, that message is selected in the Rmail buffer.

几乎所有 Rmail 命令都在摘要缓冲区和 Rmail 缓冲区中工作。因此,d在摘要缓冲区中删除当前消息、u取消删除和x清除。 (但是,在摘要缓冲区中,如果相关方向上不再有未删除的消息,则删除命令将转到第一条或最后一条消息,而不是停留在当前消息上。) o并将 C-o当前消息输出到文件;r开始回复;您可以使用SPC和滚动当前消息,同时保留在摘要缓冲区中DEL。然而,在摘要缓冲区中,用SPC或滚动经过消息的末尾或开头 DEL,分别会转到下一条或上一条未删除的消息。自定义 rmail-summary-scroll-between-messages选项以nil禁用滚动到下一条/上一条消息。

Almost all Rmail commands work in the summary buffer as well as in the Rmail buffer. Thus, d in the summary buffer deletes the current message, u undeletes, and x expunges. (However, in the summary buffer, if there are no more undeleted messages in the relevant direction, the delete commands go to the first or last message, rather than staying on the current message.) o and C-o output the current message to a FILE; r starts a reply to it; etc. You can scroll the current message while remaining in the summary buffer using SPC and DEL. However, in the summary buffer scrolling past the end or the beginning of a message with SPC or DEL goes, respectively, to the next or previous undeleted message. Customize the rmail-summary-scroll-between-messages option to nil to disable scrolling to next/previous messages.

M-u( rmail-summary-undelete-many) 取消删除摘要中所有已删除的消息。前缀参数意味着取消删除许多以前删除的消息。

M-u (rmail-summary-undelete-many) undeletes all deleted messages in the summary. A prefix argument means to undelete that many of the previous deleted messages.

在消息之间移动的 Rmail 命令也可以在摘要缓冲区中工作,但有一点不同:它们在摘要中包含的消息集中移动。它们还确保 Rmail 缓冲区出现在​​屏幕上(与光标移动命令不同,光标移动命令更新 Rmail 缓冲区的内容,但不会在窗口中显示它,除非它已经出现)。以下是这些命令的列表:

The Rmail commands to move between messages also work in the summary buffer, but with a twist: they move through the set of messages included in the summary. They also ensure the Rmail buffer appears on the screen (unlike cursor motion commands, which update the contents of the Rmail buffer but don’t display it in a window unless it already appears). Here is a list of these commands:

n
n

移至下一行,跳过显示“已删除”的行,然后选择其消息 ( rmail-summary-next-msg)。

Move to next line, skipping lines saying “deleted”, and select its message (rmail-summary-next-msg).

p
p

移至上一行,跳过显示“已删除”的行,然后选择其消息 ( rmail-summary-previous-msg)。

Move to previous line, skipping lines saying “deleted”, and select its message (rmail-summary-previous-msg).

M-n
M-n

移至下一行并选择其消息 ( rmail-summary-next-all)。

Move to next line and select its message (rmail-summary-next-all).

M-p
M-p

移至上一行并选择其消息 ( rmail-summary-previous-all)。

Move to previous line and select its message (rmail-summary-previous-all).

>
>

移至最后一行,然后选择其消息 ( rmail-summary-last-message)。

Move to the last line, and select its message (rmail-summary-last-message).

<
<

移至第一行,然后选择其消息 ( rmail-summary-first-message)。

Move to the first line, and select its message (rmail-summary-first-message).

j
j
RET
RET

选择当前行上的消息(确保 Rmail 缓冲区出现在​​屏幕上;rmail-summary-goto-msg)。使用参数 n,选择消息编号n并移动到摘要缓冲区中的该行;如果消息未在摘要缓冲区中列出,则这会发出错误信号。

Select the message on the current line (ensuring that the Rmail buffer appears on the screen; rmail-summary-goto-msg). With argument n, select message number n and move to its line in the summary buffer; this signals an error if the message is not listed in the summary buffer.

M-s pattern RET
M-s pattern RET

在消息中搜索以当前消息开头的模式;选择找到的消息,并将摘要缓冲区中的点移动到该消息的行 ( rmail-summary-search)。前缀参数充当重复计数;负参数意味着向后搜索(相当于rmail-summary-search-backward.)

Search through messages for pattern starting with the current message; select the message found, and move point in the summary buffer to that message’s line (rmail-summary-search). A prefix argument acts as a repeat count; a negative argument means search backward (equivalent to rmail-summary-search-backward.)

C-M-n labels RET
C-M-n labels RET

移至至少具有一个指定标签 ( rmail-summary-next-labeled-message) 的下一条消息。 labels是逗号分隔的标签列表。前缀参数充当重复计数。

Move to the next message with at least one of the specified labels (rmail-summary-next-labeled-message). labels is a comma-separated list of labels. A prefix argument acts as a repeat count.

C-M-p labels RET
C-M-p labels RET

移至至少具有一个指定标签 ( rmail-summary-previous-labeled-message) 的上一条消息。

Move to the previous message with at least one of the specified labels (rmail-summary-previous-labeled-message).

C-c C-n RET
C-c C-n RET

移至与当前消息主题相同的下一条消息 ( rmail-summary-next-same-subject)。前缀参数充当重复计数。

Move to the next message with the same subject as the current message (rmail-summary-next-same-subject). A prefix argument acts as a repeat count.

C-c C-p RET
C-c C-p RET

移至与当前消息主题相同的上一条消息 ( rmail-summary-previous-same-subject)。

Move to the previous message with the same subject as the current message (rmail-summary-previous-same-subject).

当您在 Rmail 缓冲区中执行删除、取消删除和获取新邮件,甚至选择不同的邮件时,都会更新摘要缓冲区。如果变量rmail-redisplay-summary为非nil,这些操作还会将摘要缓冲区带回到屏幕上。

Deletion, undeletion, and getting new mail, and even selection of a different message all update the summary buffer when you do them in the Rmail buffer. If the variable rmail-redisplay-summary is non-nil, these actions also bring the summary buffer back onto the screen.

使用完摘要后,请键入Q ( rmail-summary-wipe) 以删除摘要缓冲区的窗口。您还可以在摘要中退出 Rmail:( q )rmail-summary-quit删除摘要窗口,然后通过保存 Rmail 文件并切换到另一个缓冲区来退出 Rmail。或者,b( rmail-summary-bury) 简单地隐藏 Rmail 摘要和缓冲区。

When you are finished using the summary, type Q (rmail-summary-wipe) to delete the summary buffer’s window. You can also exit Rmail while in the summary: q (rmail-summary-quit) deletes the summary window, then exits from Rmail by saving the Rmail file and switching to another buffer. Alternatively, b (rmail-summary-bury) simply buries the Rmail summary and buffer.


34.12 对 Rmail 文件进行排序

34.12 Sorting the Rmail File

C-c C-s C-d
C-c C-s C-d
M-x rmail-sort-by-date
M-x rmail-sort-by-date

按日期对当前 Rmail 缓冲区中的邮件进行排序。

Sort messages of current Rmail buffer by date.

C-c C-s C-s
C-c C-s C-s
M-x rmail-sort-by-subject
M-x rmail-sort-by-subject

按主题对当前 Rmail 缓冲区中的邮件进行排序。

Sort messages of current Rmail buffer by subject.

C-c C-s C-a
C-c C-s C-a
M-x rmail-sort-by-author
M-x rmail-sort-by-author

按作者姓名对当前 Rmail 缓冲区中的消息进行排序。

Sort messages of current Rmail buffer by author’s name.

C-c C-s C-r
C-c C-s C-r
M-x rmail-sort-by-recipient
M-x rmail-sort-by-recipient

按收件人姓名对当前 Rmail 缓冲区中的邮件进行排序。

Sort messages of current Rmail buffer by recipient’s name.

C-c C-s C-c
C-c C-s C-c
M-x rmail-sort-by-correspondent
M-x rmail-sort-by-correspondent

按对方的姓名对当前 Rmail 缓冲区中的邮件进行排序。

Sort messages of current Rmail buffer by the name of the other correspondent.

C-c C-s C-l
C-c C-s C-l
M-x rmail-sort-by-lines
M-x rmail-sort-by-lines

按行数对当前 Rmail 缓冲区中的邮件进行排序。

Sort messages of current Rmail buffer by number of lines.

C-c C-s C-k RET labels RET
C-c C-s C-k RET labels RET
M-x rmail-sort-by-labels RET labels RET
M-x rmail-sort-by-labels RET labels RET

按标签对当前 Rmail 缓冲区中的邮件进行排序。参数 标签应该是以逗号分隔的标签列表。这些标签的顺序指定了消息的顺序;带有第一个标签的消息排在第一位,带有第二个标签的消息排在第二位,依此类推。没有这些标签的消息排在最后。

Sort messages of current Rmail buffer by labels. The argument labels should be a comma-separated list of labels. The order of these labels specifies the order of messages; messages with the first label come first, messages with the second label come second, and so on. Messages that have none of these labels come last.

Rmail 排序命令执行稳定排序:如果没有理由选择两封邮件中的任何一封,则它们的顺序保持不变。您可以使用它来按多个标准进行排序。例如,如果您使用rmail-sort-by-dateand then rmail-sort-by-author,来自同一作者的消息将按日期顺序显示。

The Rmail sort commands perform a stable sort: if there is no reason to prefer either one of two messages, their order remains unchanged. You can use this to sort by more than one criterion. For example, if you use rmail-sort-by-date and then rmail-sort-by-author, messages from the same author appear in order by date.

使用前缀参数,所有这些命令都会颠倒比较顺序。这意味着它们按照从最新到最旧、从最大到最小或相反的字母顺序对消息进行排序。

With a prefix argument, all these commands reverse the order of comparison. This means they sort messages from newest to oldest, from biggest to smallest, or in reverse alphabetical order.

摘要缓冲区中的相同键运行类似的功能;例如,C-c C-s C-l运行rmail-summary-sort-by-lines.这些命令始终对整个 Rmail 缓冲区进行排序,即使摘要仅显示消息的子集。

The same keys in the summary buffer run similar functions; for example, C-c C-s C-l runs rmail-summary-sort-by-lines. These commands always sort the whole Rmail buffer, even if the summary is only showing a subset of messages.

请注意,您无法撤消排序,因此您可能希望在排序之前保存 Rmail 缓冲区。

Note that you cannot undo a sort, so you may wish to save the Rmail buffer before sorting it.


34.13 消息的显示

34.13 Display of Messages

本节介绍 Rmail 如何显示邮件标头、 MIME部分和附件、URL 以及加密消息。

This section describes how Rmail displays mail headers, MIME sections and attachments, URLs, and encrypted messages.

t
t

切换完整标题的显示 ( rmail-toggle-header)。

Toggle display of complete header (rmail-toggle-header).

在第一次显示每条消息之前,Rmail 会重新格式化其标头,隐藏无用的标头字段以减少混乱。t( )命令 rmail-toggle-header对此进行切换,在显示重新格式化的标头字段和显示完整的原始标头之间切换。使用正前缀参数,该命令显示重新格式化的标头;使用零或负前缀参数,它显示完整的标头。如有必要,再次选择该消息也会重新格式化它。

Before displaying each message for the first time, Rmail reformats its header, hiding uninteresting header fields to reduce clutter. The t (rmail-toggle-header) command toggles this, switching between showing the reformatted header fields and showing the complete, original header. With a positive prefix argument, the command shows the reformatted header; with a zero or negative prefix argument, it shows the full header. Selecting the message again also reformats it if necessary.

该变量rmail-ignored-headers保存一个正则表达式,指定要隐藏的标头字段;任何匹配的标题行都将被隐藏。该变量rmail-nonignored-headers会覆盖这一点:任何与该正则表达式匹配的标头字段都会显示,即使它rmail-ignored-headers也匹配。该变量 rmail-displayed-headers是这两个变量的替代;如果非nil,这应该是一个正则表达式,指定要显示哪些标题(默认为nil)。

The variable rmail-ignored-headers holds a regular expression specifying the header fields to hide; any matching header line will be hidden. The variable rmail-nonignored-headers overrides this: any header field matching that regular expression is shown even if it matches rmail-ignored-headers too. The variable rmail-displayed-headers is an alternative to these two variables; if non-nil, this should be a regular expression specifying which headers to display (the default is nil).

Rmail 突出显示某些特别有趣的标头字段 — 默认情况下,“' 和 '主题' 字段。此突出显示使用rmail-highlight脸部。该变量 rmail-highlighted-headers包含一个正则表达式,指定要突出显示的标头字段;如果它与标头字段的开头匹配,则整个字段都会突出显示。要禁用此功能,请设置rmail-highlighted-headersnil

Rmail highlights certain header fields that are especially interesting—by default, the ‘From’ and ‘Subject’ fields. This highlighting uses the rmail-highlight face. The variable rmail-highlighted-headers holds a regular expression specifying the header fields to highlight; if it matches the beginning of a header field, that whole field is highlighted. To disable this feature, set rmail-highlighted-headers to nil.

如果邮件采用MIME(多用途 Internet 邮件扩展)格式并包含多个部分(MIME 实体),Rmail 将使用标语显示每个部分。标语总结了该部分的索引、大小和内容类型。根据内容类型,它还可能包含一个或多个按钮;这些执行操作,例如将零件保存到文件中。

If a message is in MIME (Multipurpose Internet Mail Extensions) format and contains multiple parts (MIME entities), Rmail displays each part with a tagline. The tagline summarizes the part’s index, size, and content type. Depending on the content type, it may also contain one or more buttons; these perform actions such as saving the part into a file.

RET
RET

隐藏或显示点 ( ) 处的MIMErmail-mime-toggle-hidden部分。

Hide or show the MIME part at point (rmail-mime-toggle-hidden).

TAB
TAB

将点移至下一个MIME标语按钮。 ( rmail-mime-next-item)。

Move point to the next MIME tagline button. (rmail-mime-next-item).

S-TAB
S-TAB

将点移至上一个MIME部分 ( rmail-mime-previous-item)。

Move point to the previous MIME part (rmail-mime-previous-item).

v
v

在MIME显示和原始消息之间切换( rmail-mime)。

Toggle between MIME display and raw message (rmail-mime).

每个纯文本MIME部分最初都在其标语之后立即显示,作为 Rmail 缓冲区的一部分(除非消息有HTML部分,见下文),而其他类型的MIME 部分仅由其标语及其实际内容表示隐。在任何一种情况下,您都可以 通过在该部分的任意位置或在其标语中的任意位置键入内容(用于其他操作的按钮除外,如果有的话)来在其显示和隐藏状态之间 切换MIMERET部分。键入RET(或单击鼠标)以激活标语按钮,并TAB在标语按钮之间循环点。

Each plain-text MIME part is initially displayed immediately after its tagline, as part of the Rmail buffer (unless the message has an HTML part, see below), while MIME parts of other types are represented only by their taglines, with their actual contents hidden. In either case, you can toggle a MIME part between its displayed and hidden states by typing RET anywhere in the part—or anywhere in its tagline (except for buttons for other actions, if there are any). Type RET (or click with the mouse) to activate a tagline button, and TAB to cycle point between tagline buttons.

v( )命令在上述rmail-mime默认 MIME显示和显示未解码MIME数据的原始显示之间切换。使用前缀参数,此命令仅切换该点实体的显示。

The v (rmail-mime) command toggles between the default MIME display described above, and a raw display showing the undecoded MIME data. With a prefix argument, this command toggles the display of only an entity at point.

如果消息具有HTML MIME部分,并且 Emacs 可以呈现HTML 20,则 Rmail 会优先显示它而不是纯文本部分 。为了防止这种情况发生,并显示纯文本部分,请将变量自定义rmail-mime-prefer-html为一个nil值。

If the message has an HTML MIME part, Rmail displays it in preference to the plain-text part, if Emacs can render HTML20. To prevent that, and have the plain-text part displayed instead, customize the variable rmail-mime-prefer-html to a nil value.

要防止 Rmail 处理 MIME 解码的消息,请将变量更改rmail-enable-mimenil。在这种情况下,v( rmail-mime) 命令会创建一个临时缓冲区来显示当前的MIME消息。

To prevent Rmail from handling MIME decoded messages, change the variable rmail-enable-mime to nil. When this is the case, the v (rmail-mime) command instead creates a temporary buffer to display the current MIME message.

如果当前消息是加密消息,请使用命令 C-c C-d( rmail-epa-decrypt) 使用 EasyPG 库对其进行解密(请参阅EasyPG 助手用户手册中的EasyPG)。

If the current message is an encrypted one, use the command C-c C-d (rmail-epa-decrypt) to decrypt it, using the EasyPG library (see EasyPG in EasyPG Assistant User’s Manual).

您可以使用转到地址模式突出显示并激活 Rmail 缓冲区中的 URL:

You can highlight and activate URLs in the Rmail buffer using Goto Address mode:

(add-hook 'rmail-show-message-hook '转到地址模式)
(add-hook 'rmail-show-message-hook 'goto-address-mode)

mouse-2 然后,您可以通过使用(或快速)单击这些 URLmouse-1或移动到其中一个并键入 来浏览这些 URL 。请参阅激活 URLC-c RET

Then you can browse these URLs by clicking on them with mouse-2 (or mouse-1 quickly) or by moving to one and typing C-c RET. See Activating URLs.


34.14 Rmail和编码系统

34.14 Rmail and Coding Systems

Rmail 自动解码包含非ASCII 字符的消息,就像 Emacs 对您访问的文件和子进程输出所做的那样。 Rmail 使用标准 '字符集=字符集' 消息中的标头(如果有),以确定发送者如何对消息进行编码。它将字符集映射到相应的 Emacs 编码系统(请参阅编码系统),并使用该编码系统来解码消息文本。如果邮件标头没有 '字符集' 规范,或者如果无法识别字符集,Rmail 将使用通常的 Emacs 启发式和默认值选择编码系统(请参阅识别编码系统)。

Rmail automatically decodes messages which contain non-ASCII characters, just as Emacs does with files you visit and with subprocess output. Rmail uses the standard ‘charset=charset’ header in the message, if any, to determine how the message was encoded by the sender. It maps charset into the corresponding Emacs coding system (see Coding Systems), and uses that coding system to decode message text. If the message header doesn’t have the ‘charset’ specification, or if charset is not recognized, Rmail chooses the coding system with the usual Emacs heuristics and defaults (see Recognizing Coding Systems).

有时,消息会被错误解码,这可能是因为 Emacs 在缺少 ' 的情况下猜测了错误的编码系统字符集' 规范,或者因为规范不准确。例如,配置错误的邮件程序可能会发送带有“字符集=iso-8859-1' 当消息实际编码为koi8-r.当您看到消息文本出现乱码,或者某些字符显示为十六进制代码或空框时,可能已经发生了这种情况。

Occasionally, a message is decoded incorrectly, either because Emacs guessed the wrong coding system in the absence of the ‘charset’ specification, or because the specification was inaccurate. For example, a misconfigured mailer could send a message with a ‘charset=iso-8859-1’ header when the message is actually encoded in koi8-r. When you see the message text garbled, or some of its characters displayed as hex codes or empty boxes, this may have happened.

如果您能找出或猜测哪一个是正确的,则可以通过使用正确的编码系统再次解码消息来纠正问题。为此,请调用该M-x rmail-redecode-body命令。它读取编码系统的名称,然后使用您指定的编码系统重新解码消息。如果指定了正确的编码系统,结果应该是可读的。

You can correct the problem by decoding the message again using the right coding system, if you can figure out or guess which one is right. To do this, invoke the M-x rmail-redecode-body command. It reads the name of a coding system, and then redecodes the message using the coding system you specified. If you specified the right coding system, the result should be readable.

当您在 Rmail 中收到新邮件时,每封邮件都会根据其写入的编码系统自动进行翻译,就好像它是一个单独的文件一样。这将使用您指定的编码系统的优先级列表。如果 MIME 消息指定了字符集,Rmail 就会遵守该规范。为了读取和保存 Rmail 文件本身,Emacs 使用变量 指定的编码系统 rmail-file-coding-system。默认值为nil,这意味着 Rmail 文件不被翻译(它们以 Emacs 内部字符代码读取和写入)。

When you get new mail in Rmail, each message is translated automatically from the coding system it is written in, as if it were a separate file. This uses the priority list of coding systems that you have specified. If a MIME message specifies a character set, Rmail obeys that specification. For reading and saving Rmail files themselves, Emacs uses the coding system specified by the variable rmail-file-coding-system. The default value is nil, which means that Rmail files are not translated (they are read and written in the Emacs internal character code).


34.15 在消息内编辑

34.15 Editing Within a Message

大多数常用的 Emacs 键绑定在 Rmail 模式下可用,但Rmail 出于其他目的重新定义了一些键绑定,例如C-M-n和。C-M-h然而,Rmail 缓冲区通常是只读的,并且大多数信件被重新定义为 Rmail 命令。如果要编辑邮件文本,则必须使用 Rmail 命令 e

Most of the usual Emacs key bindings are available in Rmail mode, though a few, such as C-M-n and C-M-h, are redefined by Rmail for other purposes. However, the Rmail buffer is normally read only, and most of the letters are redefined as Rmail commands. If you want to edit the text of a message, you must use the Rmail command e.

e
e

将当前消息编辑为普通文本。

Edit the current message as ordinary text.

命令e( rmail-edit-current-message) 从 Rmail 模式切换到 Rmail 编辑模式,这是另一种主要模式,与文本模式几乎相同。模式线指示了这种变化。

The e command (rmail-edit-current-message) switches from Rmail mode into Rmail Edit mode, another major mode which is nearly the same as Text mode. The mode line indicates this change.

在 Rmail 编辑模式下,信件照常插入,并且 Rmail 命令不可用。您可以编辑消息正文和标题字段。完成消息编辑后,请键入C-c C-c ( rmail-cease-edit) 以切换回 Rmail 模式。或者,您可以返回 Rmail 模式,但通过键入C-c C-]( rmail-abort-edit) 取消已完成的任何编辑。

In Rmail Edit mode, letters insert themselves as usual and the Rmail commands are not available. You can edit the message body and header fields. When you are finished editing the message, type C-c C-c (rmail-cease-edit) to switch back to Rmail mode. Alternatively, you can return to Rmail mode but cancel any editing that you have done, by typing C-c C-] (rmail-abort-edit).

进入 Rmail 编辑模式运行钩子text-mode-hook;然后它运行钩子rmail-edit-mode-hook(参见Hooks)。返回普通 Rmail 模式添加属性 '已编辑' 到消息中,如果您对其进行了任何更改(请参阅Rmail 属性)。

Entering Rmail Edit mode runs the hook text-mode-hook; then it runs the hook rmail-edit-mode-hook (see Hooks). Returning to ordinary Rmail mode adds the attribute ‘edited’ to the message, if you have made any changes in it (see Rmail Attributes).


34.16 摘要消息

34.16 Digest Messages

摘要消息是包含并携带多个其他消息的消息。摘要用于某些邮件列表;在一段时间内(例如一天)到达列表的所有消息都会放入一个摘要中,然后发送给订阅者。由于网络邮件传输中每条消息的开销,即使总大小相同,传输单个摘要所用的计算机时间也比传输单个消息要少。

A digest message is a message which exists to contain and carry several other messages. Digests are used on some mailing lists; all the messages that arrive for the list during a period of time such as one day are put inside a single digest which is then sent to the subscribers. Transmitting the single digest uses less computer time than transmitting the individual messages even though the total size is the same, because of the per-message overhead in network mail transmission.

当您收到摘要消息时,阅读它的最方便的方法就是取消摘要:将其恢复为许多单独的消息。然后您可以根据需要阅读和删除各个消息。为此,请选择摘要消息并键入命令M-x undigestify-rmail-message。这会将子消息提取为单独的 Rmail 消息,并将它们插入到摘要之后。摘要消息本身被标记为已删除。

When you receive a digest message, the most convenient way to read it is to undigestify it: to turn it back into many individual messages. Then you can read and delete the individual messages as it suits you. To do this, select the digest message and type the command M-x undigestify-rmail-message. This extracts the submessages as separate Rmail messages, and inserts them following the digest. The digest message itself is flagged as deleted.


34.17 读取Rot13消息

34.17 Reading Rot13 Messages

可能会冒犯或惹恼某些读者的邮件列表消息有时会用一个名为rot13的简单代码进行编码,如此命名是因为它将字母表旋转 13 个字母。该代码不是为了保密,因为它不提供任何信息;相反,它使那些希望避免看到消息真实文本的人能够使用。例如,电影评论可能会使用 rot13 来隐藏重要的情节点。

Mailing list messages that might offend or annoy some readers are sometimes encoded in a simple code called rot13—so named because it rotates the alphabet by 13 letters. This code is not for secrecy, as it provides none; rather, it enables those who wish to avoid seeing the real text of the message. For example, a review of a film might use rot13 to hide important plot points.

要查看使用 rot13 代码的缓冲区,请使用命令M-x rot13-other-window。这会在另一个窗口中显示当前缓冲区,该窗口在显示文本时应用代码。

To view a buffer that uses the rot13 code, use the command M-x rot13-other-window. This displays the current buffer in another window which applies the code when displaying the text.

如果您只对某个区域感兴趣,则该命令M-x rot13-region可能更合适。这将就地加密/解密活动区域。如果缓冲区是只读的,它将尝试在回显区域中显示纯文本。如果文本对于回显区域来说太长,该命令将弹出一个临时缓冲区,其中包含加密/解密的文本。

If you are only interested in a region, the command M-x rot13-region might be preferable. This will encrypt/decrypt the active region in-place. If the buffer is read-only, it will attempt to display the plain text in the echo area. If the text is too long for the echo area, the command will pop up a temporary buffer with the encrypted/decrypted text.


34.18movemail节目

34.18 movemail program

Rmail 使用该movemail程序将邮件从收件箱移动到 Rmail 文件(请参阅Rmail 文件和收件箱)。第一次加载时,Rmail 会尝试定位该movemail程序并确定其版本。该程序有两个版本movemail:GNU Mailutils 版本(请参阅GNU mailutils中的movemail),以及除非配置了 Emacs,否则构建和安装的 Emacs 特定版本--with-mailutils有效。这两个movemail版本支持相同的命令行语法和相同的基本选项子集。然而,Mailutils 版本提供了额外的功能并且更安全。

Rmail uses the movemail program to move mail from your inbox to your Rmail file (see Rmail Files and Inboxes). When loaded for the first time, Rmail attempts to locate the movemail program and determine its version. There are two versions of the movemail program: the GNU Mailutils version (see movemail in GNU mailutils), and an Emacs-specific version that is built and installed unless Emacs was configured --with-mailutils in effect. The two movemail versions support the same command line syntax and the same basic subset of options. However, the Mailutils version offers additional features and is more secure.

Emacs 版本movemail可以从常用的 Unix 邮箱格式检索邮件。 警告:虽然它也可以使用 POP3 协议,但不建议这样做,因为它不支持通过加密 TLS 通道的 POP3。

The Emacs version of movemail can retrieve mail from the usual Unix mailbox formats. Warning: Although it can also use the POP3 protocol, this is not recommended because it does not support POP3 via encrypted TLS channels.

Mailutils版本能够处理多种邮箱格式,例如普通Unix邮箱maildirMH 邮箱等。它能够使用POP3或IMAP4协议访问远程邮箱,并可以使用TLS加密通道从中检索邮件。它还接受URL 形式的邮箱参数。邮箱URL的详细说明可以参见邮箱URL格式中的URL。简而言之, URL是:

The Mailutils version is able to handle a wide set of mailbox formats, such as plain Unix mailboxes, maildir and MH mailboxes, etc. It is able to access remote mailboxes using the POP3 or IMAP4 protocol, and can retrieve mail from them using a TLS encrypted channel. It also accepts mailbox arguments in URL form. The detailed description of mailbox URLs can be found in URL in Mailbox URL Formats. In short, a URL is:

proto ://[用户[:密码]@]主机或文件名[:端口]
proto://[user[:password]@]host-or-file-name[:port]

其中方括号表示可选元素。

where square brackets denote optional elements.

原型
proto

指定要使用的邮箱协议格式。其余URL元素的确切语义取决于proto的实际值(见下文)。

Specifies the mailbox protocol, or format to use. The exact semantics of the rest of URL elements depends on the actual value of proto (see below).

用户
user

访问远程邮箱的用户名。

User name to access the remote mailbox.

密码
password

访问远程邮箱的用户密码。

User password to access the remote mailbox.

主机名或文件名
host-or-file-name

远程邮箱的远程服务器的主机名或本地邮箱的文件名。

Hostname of the remote server for remote mailboxes or file name of a local mailbox.

港口
port

可选端口号(如果不是该协议的默认端口号)。

Optional port number, if not the default for that protocol.

原型可以是以下之一:

proto can be one of:

mbox
mbox

常见的 Unix 邮箱格式。在这种情况下,不使用userpassport ,并且host-or-file-name表示邮箱文件的文件名,例如mbox:///var/spool/mail/smith.

Usual Unix mailbox format. In this case, user, pass and port are not used, and host-or-file-name denotes the file name of the mailbox file, e.g., mbox:///var/spool/mail/smith.

mh
mh

MH格式的本地邮箱。 不使用 userpassport 。 host-or-file-name表示MH文件夹的名称,例如mh:///Mail/inbox.

A local mailbox in the MH format. user, pass and port are not used. host-or-file-name denotes the name of MH folder, e.g., mh:///Mail/inbox.

maildir
maildir

maildir格式的本地邮箱。 不使用userpassport , host-or-file-name 表示邮箱的名称maildir,例如 maildir:///mail/inbox

A local mailbox in the maildir format. user, pass and port are not used, and host-or-file-name denotes the name of maildir mailbox, e.g., maildir:///mail/inbox.

file
file

邮箱格式的任何本地文件。它的实际格式由自动检测movemail

Any local file in mailbox format. Its actual format is detected automatically by movemail.

pop
pop
pops
pops

通过 POP3 协议访问的远程邮箱。 user 指定要使用的远程用户名,pass可以用来指定用户密码,host-or-file-name是要连接的远程邮件服务器的名称或IP地址,port是端口号;例如,pop://smith:guessme@remote.server.net:995。如果服务器支持,movemail则尝试使用加密连接 - 使用 '持久性有机污染物' 形式要求一个。

A remote mailbox to be accessed via POP3 protocol. user specifies the remote user name to use, pass may be used to specify the user password, host-or-file-name is the name or IP address of the remote mail server to connect to, and port is the port number; e.g., pop://smith:guessme@remote.server.net:995. If the server supports it, movemail tries to use an encrypted connection—use the ‘pops’ form to require one.

imap
imap
imaps
imaps

通过 IMAP4 协议访问的远程邮箱。 user 指定要使用的远程用户名,pass可以用来指定用户密码,host-or-file-name是要连接的远程邮件服务器的名称或IP地址,port是端口号;例如,imap://smith:guessme@remote.server.net:993。如果服务器支持,movemail则尝试使用加密连接 - 使用 '图像处理程序' 形式要求一个。

A remote mailbox to be accessed via IMAP4 protocol. user specifies the remote user name to use, pass may be used to specify the user password, host-or-file-name is the name or IP address of the remote mail server to connect to, and port is the port number; e.g., imap://smith:guessme@remote.server.net:993. If the server supports it, movemail tries to use an encrypted connection—use the ‘imaps’ form to require one.

或者,您可以指定要使用的邮箱的文件名。这相当于指定 '文件' 协议:

Alternatively, you can specify the file name of the mailbox to use. This is equivalent to specifying the ‘file’ protocol:

/var/spool/mail/用户== 文件:///var/spool/mail/用户
/var/spool/mail/user ≡ file:///var/spool/mail/user

该变量控制要使用rmail-movemail-program的版本 。movemail如果这是一个字符串,则它指定可执行文件的绝对文件名movemail。如果是 ,Rmail 将在 中列出的目录中nil搜索,然后在 (请参阅从 Emacs 运行 Shell 命令)中搜索,然后在 中搜索。 movemailrmail-movemail-search-pathexec-pathexec-directory

The variable rmail-movemail-program controls which version of movemail to use. If that is a string, it specifies the absolute file name of the movemail executable. If it is nil, Rmail searches for movemail in the directories listed in rmail-movemail-search-path, then in exec-path (see Running Shell Commands from Emacs), then in exec-directory.


34.19 从远程邮箱检索邮件

34.19 Retrieving Mail from Remote Mailboxes

某些站点使用称为 POP3 的方法来访问用户的收件箱数据,而不是将数据存储在收件箱文件中。 Mailutils movemail默认支持带有 TLS 加密的 POP3。 警告:虽然Emacs movemail支持 POP3,但不建议将其用于此目的,因为它不支持加密连接,而 Mailutils 版本则支持。这两个版本movemail仅适用于 POP3,不适用于旧版本的 POP。

Some sites use a method called POP3 for accessing users’ inbox data instead of storing the data in inbox files. The Mailutils movemail by default supports POP3 with TLS encryption. Warning: Although the Emacs movemail supports POP3, its use for this is not recommended since it does not support encrypted connections—the Mailutils version does. Both versions of movemail work only with POP3, not with older versions of POP.

您可以使用 POP3 URL指定 POP3 收件箱(请参阅movemail程序)。 POP3 URL 的形式为 'pop://用户名@主机名:端口',其中 主机名端口是远程邮件服务器的主机名(或 IP 地址)和端口号,用户名是该服务器上的用户名。此外,您可以在邮箱URL中指定密码:'pop://用户名:密码@主机名:端口'。在这种情况下,密码优先于由 rmail-remote-password(见下文)设置的密码。如果您有多个具有不同密码的远程邮箱,这尤其有用。如果使用 Mailutils movemail,您可能希望使用 '持久性有机污染物'代替'流行音乐'。

You can specify a POP3 inbox by using a POP3 URL (see movemail program). A POP3 URL is of the form ‘pop://username@hostname:port’, where hostname and port are the host name (or IP address) and port number of the remote mail server and username is the user name on that server. Additionally, you may specify the password in the mailbox URL: ‘pop://username:password@hostname:port’. In this case, password takes preference over the one set by rmail-remote-password (see below). This is especially useful if you have several remote mailboxes with different passwords. If using Mailutils movemail, you may wish to use ‘pops’ in place of ‘pop’.

为了向后兼容,Rmail 还支持指定远程 POP3 邮箱的替代方法。以格式 ' 指定收件箱名称po:用户名:主机名:端口' 相当于 'pop://用户名@主机名:端口'。如果省略 :hostname部分,MAILHOST环境变量将指定要在其上查找 POP3 服务器的计算机。

For backward compatibility, Rmail also supports an alternative way of specifying remote POP3 mailboxes. Specifying an inbox name in the form ‘po:username:hostname:port’ is equivalent to ‘pop://username@hostname:port’. If you omit the :hostname part, the MAILHOST environment variable specifies the machine on which to look for the POP3 server.

另一种访问远程邮箱的方法是 IMAP。仅 Mailutils 支持此方法movemail。要在收件箱列表中指定 IMAP 邮箱,请使用以下邮箱URL:'imap://用户名[:密码]@主机名:端口'。如上所述,密码部分 是可选的。您可能希望使用 '图像处理程序'代替'图像映射'。

Another method for accessing remote mailboxes is IMAP. This method is supported only by the Mailutils movemail. To specify an IMAP mailbox in the inbox list, use the following mailbox URL: ‘imap://username[:password]@hostname:port’. The password part is optional, as described above. You may wish to use ‘imaps’ in place of ‘imap’.

访问远程邮箱可能需要密码。 Rmail 使用以下算法来检索它:

Accessing a remote mailbox may require a password. Rmail uses the following algorithm to retrieve it:

  1. 如果邮箱 URL 中存在 密码(参见上文),则会使用该密码。
  2. If a password is present in the mailbox URL (see above), it is used.
  3. 如果变量rmail-remote-password-requirednil,Rmail 假定不需要密码。
  4. If the variable rmail-remote-password-required is nil, Rmail assumes no password is required.
  5. 如果变量rmail-remote-password为非nil,则使用其值。
  6. If the variable rmail-remote-password is non-nil, its value is used.
  7. 否则,Rmail 将要求您输入要使用的密码。
  8. Otherwise, Rmail will ask you for the password to use.

在某些邮件服务器上,用户名包含域信息,这可能意味着它们包含“@' 特点。收件箱说明符字符串使用 '@' 表示邮件服务器名称的开始。这会给 movemail 带来混乱。如果您的用户名包含 '@'并且您正在使用 Mailutils,movemail那么您可以解决此问题:将@用户名替换为其URL 编码'%40'。

On some mail servers the usernames include domain information, which can mean they contain the ‘@’ character. The inbox specifier string uses ‘@’ to signal the start of the mailserver name. This creates confusion for movemail. If your username contains ‘@’ and you’re using Mailutils movemail then you can fix this: Replace @ in the user name with its URL encoding ‘%40’.

如果您需要将其他命令行标志传递给movemail,请将变量设置为rmail-movemail-flags您希望使用的标志列表。不要使用此变量来传递 '-p' 标记以保留您的收件箱内容;代替使用rmail-preserve-inbox

If you need to pass additional command-line flags to movemail, set the variable rmail-movemail-flags a list of the flags you wish to use. Do not use this variable to pass the ‘-p’ flag to preserve your inbox contents; use rmail-preserve-inbox instead.

movemail您站点上安装的程序可能支持 Kerberos 身份验证。如果支持,则在 未设置rmail-remote-passwordrmail-remote-password-required 的情况下,每当您尝试检索 POP3 邮件时,默认情况下都会使用它。

The movemail program installed at your site may support Kerberos authentication. If it is supported, it is used by default whenever you attempt to retrieve POP3 mail when rmail-remote-password and rmail-remote-password-required are unset.

某些 POP3 服务器以相反的顺序存储邮件。如果您的服务器执行此操作,并且您希望按照收到的顺序阅读邮件,则可以movemail通过添加 '-r' 标记为 rmail-movemail-flags.

Some POP3 servers store messages in reverse order. If your server does this, and you would rather read your mail in the order in which it was received, you can tell movemail to reverse the order of downloaded messages by adding the ‘-r’ flag to rmail-movemail-flags.

Mailutilsmovemail支持 TLS 加密。如果您想使用它,请添加 '--tls' 标记为rmail-movemail-flags.

Mailutils movemail supports TLS encryption. If you wish to use it, add the ‘--tls’ flag to rmail-movemail-flags.


34.20 从本地邮箱中检索各种格式的邮件

34.20 Retrieving Mail from Local Mailboxes in Various Formats

如果您收到的邮件以 Unix 邮箱以外的格式存储在本地计算机上,您将需要 Mailutilsmovemail来检索它。有关版本的详细说明, 请参阅movemail程序movemail。例如,要从收件箱访问 maildir格式位于/var/spool/mail/in,您将在 Rmail 收件箱列表中包含以下内容:

If your incoming mail is stored on a local machine in a format other than Unix mailbox, you will need the Mailutils movemail to retrieve it. See movemail program, for the detailed description of movemail versions. For example, to access mail from an inbox in maildir format located in /var/spool/mail/in, you would include the following in the Rmail inbox list:

maildir:///var/spool/mail/in
maildir:///var/spool/mail/in

35 Gnus 的电子邮件和 Usenet 新闻

35 Email and Usenet News with Gnus

Gnus 是一个 Emacs 软件包,主要设计用于阅读和发布 Usenet 新闻。它还可用于读取和响应来自许多其他来源(电子邮件、远程目录、摘要等)的消息。这里我们介绍一下Gnus并描述几个基本特性。有关完整详细信息,请参阅Gnus 手册中的Gnus

Gnus is an Emacs package primarily designed for reading and posting Usenet news. It can also be used to read and respond to messages from a number of other sources—email, remote directories, digests, and so on. Here we introduce Gnus and describe several basic features. For full details, see Gnus in The Gnus Manual.


35.1 Gnus 缓冲区

35.1 Gnus Buffers

Gnus 使用多个缓冲区来显示信息和接收命令。三个最常用的 Gnus 缓冲区是 组缓冲区摘要缓冲区文章缓冲区

Gnus uses several buffers to display information and to receive commands. The three most commonly-used Gnus buffers are the group buffer, the summary buffer and the article buffer.

缓冲区包含文章源列表(例如,新闻组和电子邮件收件箱),它们统称为 。这是 Gnus 启动时显示的第一个缓冲区。它通常仅显示您订阅的且包含未读文章的组。从此缓冲区中,您可以选择要读取的组。

The group buffer contains a list of article sources (e.g., newsgroups and email inboxes), which are collectively referred to as groups. This is the first buffer Gnus displays when it starts up. It normally displays only the groups to which you subscribe and that contain unread articles. From this buffer, you can select a group to read.

摘要缓冲区列出了单个组中的文章,每行显示一篇文章。默认情况下,它显示每篇文章的作者、主题和行号,但这是可定制的;请参阅Gnus 手册中的摘要缓冲区格式。摘要缓冲区在您在组缓冲区中选择一个组时创建,并在您退出该组时终止。

The summary buffer lists the articles in a single group, showing one article per line. By default, it displays each article’s author, subject, and line number, but this is customizable; See Summary Buffer Format in The Gnus Manual. The summary buffer is created when you select a group in the group buffer, and is killed when you exit the group.

从摘要缓冲区中,您可以选择要查看的文章。文章显示在文章缓冲区中。在正常的 Gnus 使用中,您可以查看此缓冲区,但不选择它 — 所有有用的 Gnus 命令都可以从摘要缓冲区中调用。但如果您愿意,您可以选择文章缓冲区,并从中执行 Gnus 命令。

From the summary buffer, you can choose an article to view. The article is displayed in the article buffer. In normal Gnus usage, you view this buffer but do not select it—all useful Gnus commands can be invoked from the summary buffer. But you can select the article buffer, and execute Gnus commands from it, if you wish.


35.2 Gnus 启动时

35.2 When Gnus Starts Up

如果您的系统已设置为阅读 Usenet 新闻,那么开始使用 Gnus 就很容易 — 只需键入M-x gnus

If your system has been set up for reading Usenet news, getting started with Gnus is easy—just type M-x gnus.

启动时,Gnus 读取您的新闻初始化文件:一个名为.newsrc在您的主目录中,其中列出了您的 Usenet 新闻组和订阅(此文件并非 Gnus 独有;许多其他新闻阅读器程序都使用它)。然后,它尝试联系系统的默认新闻服务器,该服务器通常由NNTPSERVER环境变量指定。

On starting up, Gnus reads your news initialization file: a file named .newsrc in your home directory which lists your Usenet newsgroups and subscriptions (this file is not unique to Gnus; it is used by many other newsreader programs). It then tries to contact the system’s default news server, which is typically specified by the NNTPSERVER environment variable.

如果您的系统没有默认的新闻服务器,或者您希望使用 Gnus 阅读电子邮件,那么在调用之前M-x gnus您需要告诉 Gnus 从哪里获取新闻和/或邮件。为此,请自定义变量gnus-select-method和/或 gnus-secondary-select-methods.请参阅《Gnus 手册》中的“查找新闻”

If your system does not have a default news server, or if you wish to use Gnus for reading email, then before invoking M-x gnus you need to tell Gnus where to get news and/or mail. To do this, customize the variables gnus-select-method and/or gnus-secondary-select-methods. See Finding the News in The Gnus Manual.

一旦 Gnus 启动,它就会显示组缓冲区。默认情况下,组缓冲区仅显示少量订阅的组。具有其他状态(未订阅已死亡僵尸)的组将被隐藏。第一次启动 Gnus 时,任何您未订阅的组都会被设为终止组;随后出现在新闻服务器上的任何组都会成为僵尸组。

Once Gnus has started up, it displays the group buffer. By default, the group buffer shows only a small number of subscribed groups. Groups with other statuses—unsubscribed, killed, or zombie—are hidden. The first time you start Gnus, any group to which you are not subscribed is made into a killed group; any group that subsequently appears on the news server becomes a zombie group.

要继续,您必须在组缓冲区中选择一个组以打开该组的摘要缓冲区;然后,选择摘要缓冲区中的一篇文章以在单独的窗口中查看其文章缓冲区。以下部分说明如何使用组缓冲区和摘要缓冲区来执行此操作。

To proceed, you must select a group in the group buffer to open the summary buffer for that group; then, select an article in the summary buffer to view its article buffer in a separate window. The following sections explain how to use the group and summary buffers to do this.

要退出 Gnus,请输入q组缓冲区。这会自动将您的群组状态记录在文件中.newsrc.newsrc.field,以便它们在后续的 Gnus 会话中生效。

To quit Gnus, type q in the group buffer. This automatically records your group statuses in the files .newsrc and .newsrc.eld, so that they take effect in subsequent Gnus sessions.


35.3 使用 Gnus 组缓冲区

35.3 Using the Gnus Group Buffer

Gnus 组缓冲区中提供以下命令:

The following commands are available in the Gnus group buffer:

SPC
SPC

切换到当前行 ( ) 上的组的摘要缓冲区gnus-group-read-group

Switch to the summary buffer for the group on the current line (gnus-group-read-group).

l
l
A s
A s

在组缓冲区中,仅列出您订阅的且包含未读文章的组(gnus-group-list-groups;这是默认列表)。

In the group buffer, list only the groups to which you subscribe and which contain unread articles (gnus-group-list-groups; this is the default listing).

L
L
A u
A u

列出所有已订阅和未订阅的组,但不包括已终止或僵尸组 ( gnus-group-list-all-groups)。

List all subscribed and unsubscribed groups, but not killed or zombie groups (gnus-group-list-all-groups).

A k
A k

列出被杀死的群体 ( gnus-group-list-killed)。

List killed groups (gnus-group-list-killed).

A z
A z

列出僵尸组 ( gnus-group-list-zombies)。

List zombie groups (gnus-group-list-zombies).

u
u

gnus-group-toggle-subscription-at-point切换当前行群组 ( ) 的订阅状态。对已死亡或僵尸组调用此命令会将其变成取消订阅的组。

Toggle the subscription status of the group (gnus-group-toggle-subscription-at-point) on the current line. Invoking this on a killed or zombie group turns it into an unsubscribed group.

C-k
C-k

杀死当前行 ( ) 上的组gnus-group-kill-group。被杀死的群体没有记录在.newsrc文件,并且它们不会显示在lL列表中。

Kill the group on the current line (gnus-group-kill-group). Killed groups are not recorded in the .newsrc file, and they are not shown in the l or L listings.

DEL
DEL

将点移至包含未读文章的上一组 ( gnus-group-prev-unread-group)。

Move point to the previous group containing unread articles (gnus-group-prev-unread-group).

n
n

将点移动到下一个未读组 ( gnus-group-next-unread-group)。

Move point to the next unread group (gnus-group-next-unread-group).

p
p

将点移至上一个未读组 ( gnus-group-prev-unread-group)。

Move point to the previous unread group (gnus-group-prev-unread-group).

q
q

更新您的 Gnus 设置,然后退出 Gnus ( gnus-group-exit)。

Update your Gnus settings, and quit Gnus (gnus-group-exit).


35.4 使用Gnus摘要缓冲区

35.4 Using the Gnus Summary Buffer

Gnus 摘要缓冲区中提供以下命令:

The following commands are available in the Gnus summary buffer:

SPC
SPC

如果没有选择文章,则选择当前行的文章并显示其文章缓冲区。否则,尝试在其窗口中滚动选定的文章缓冲区;到达缓冲区末尾时,选择下一篇未读文章 ( gnus-summary-next-page)。

因此,您可以通过重复键入 来阅读所有文章 SPC

If there is no article selected, select the article on the current line and display its article buffer. Otherwise, try scrolling the selected article buffer in its window; on reaching the end of the buffer, select the next unread article (gnus-summary-next-page).

Thus, you can read through all articles by repeatedly typing SPC.

DEL
DEL

向后滚动文章文本 ( gnus-summary-prev-page)。

Scroll the text of the article backwards (gnus-summary-prev-page).

n
n

选择下一篇未读文章 ( gnus-summary-next-unread-article)。

Select the next unread article (gnus-summary-next-unread-article).

p
p

选择上一篇未读文章 ( gnus-summary-prev-unread-article)。

Select the previous unread article (gnus-summary-prev-unread-article).

s
s

对选定的文章缓冲区 ( gnus-summary-isearch-article) 执行增量搜索,就像切换到缓冲区并键入一样C-s(请参阅增量搜索)。

Do an incremental search on the selected article buffer (gnus-summary-isearch-article), as if you switched to the buffer and typed C-s (see Incremental Search).

M-s M-s regexp RET
M-s M-s regexp RET

向前搜索包含正则表达式 ( gnus-summary-search-article-forward) 匹配的文章。

Search forward for articles containing a match for regexp (gnus-summary-search-article-forward).

M-r regexp RET
M-r regexp RET

向后搜索包含正则表达式 ( gnus-summary-search-article-backward) 匹配的文章。

Search back for articles containing a match for regexp (gnus-summary-search-article-backward).

q
q

退出摘要缓冲区并返回到组缓冲区 ( gnus-summary-exit)。

Exit the summary buffer and return to the group buffer (gnus-summary-exit).


36 主机安全

36 Host Security

Emacs 在 GNU/Linux 等操作系统内运行,并依赖操作系统来检查安全约束,例如对文件的访问。 Emacs 的默认设置是为典型用途而设计的;它们可能需要在安全性比平时更受关注或更少关注的环境中进行一些调整。例如,文件局部变量可能存在风险,您可以将变量设置 enable-local-variables:safe或 (甚至更保守)为nil;相反,如果您的文件都是可信的,并且对这些变量的默认检查令人恼火,那么您可以设置enable-local-variables:all.请参阅文件变量的安全性

Emacs runs inside an operating system such as GNU/Linux, and relies on the operating system to check security constraints such as accesses to files. The default settings for Emacs are designed for typical use; they may require some tailoring in environments where security is more of a concern, or less of a concern, than usual. For example, file-local variables can be risky, and you can set the variable enable-local-variables to :safe or (even more conservatively) to nil; conversely, if your files can all be trusted and the default checking for these variables is irritating, you can set enable-local-variables to :all. See Safety of File Variables.

有关在大型应用程序中使用 Emacs 时的安全注意事项的更多信息, 参阅Emacs Lisp 参考手册中的安全注意事项。

See Security Considerations in The Emacs Lisp Reference Manual, for more information about security considerations when using Emacs as part of a larger application.


37 网络安全

37 Network Security

每当 Emacs 建立任何网络连接时,它都会将已建立的连接传递给网络安全管理器 ( NSM )。 NSM负责在您的控制下实施网络安全。目前,这是通过使用传输层安全 ( TLS ) 功能来实现的。

Whenever Emacs establishes any network connection, it passes the established connection to the Network Security Manager (NSM). NSM is responsible for enforcing the network security under your control. Currently, this works by using the Transport Layer Security (TLS) features.

该变量确定NSMnetwork-security-level强制执行的安全级别。如果其值为,则不执行安全检查。不建议这样做,这基本上意味着您的网络连接不可信。但是,该设置在有限的情况下很有用,例如测试网络问题时。 low

The network-security-level variable determines the security level that NSM enforces. If its value is low, no security checks are performed. This is not recommended, and will basically mean that your network connections can’t be trusted. However, the setting can be useful in limited circumstances, as when testing network issues.

如果此变量是medium(这是默认值),则将执行许多检查。如果NSM确定网络连接可能不可信,它会让您意识到这一点,并询问您如何处理网络连接。

If this variable is medium (which is the default), a number of checks will be performed. If as result NSM determines that the network connection might not be trustworthy, it will make you aware of that, and will ask you what to do about the network connection.

您可以决定为未经验证的连接注册永久安全异常、临时异常或完全拒绝连接。

You can decide to register a permanent security exception for an unverified connection, a temporary exception, or refuse the connection entirely.

除了基本的证书正确性检查之外, 还可以使用多种TLS算法检查。一些以前被认为是安全的加密技术已证明自己很脆弱,因此 Emacs(默认情况下)会警告您其中一些问题。

In addition to the basic certificate correctness checks, several TLS algorithm checks are available. Some encryption technologies that were previously thought to be secure have shown themselves to be fragile, so Emacs (by default) warns you about some of these problems.

协议网络检查是通过 network-security-protocol-checks变量控制的。

The protocol network checks is controlled via the network-security-protocol-checks variable.

它是一个列表,其中每个关联的第一个元素是检查的名称,第二个元素是应使用检查的安全级别。

It’s an alist where the first element of each association is the name of the check, and the second element is the security level where the check should be used.

像这样的元素(rc4 medium)将导致函数 nsm-protocol-check--rc4被调用,如下所示: (nsm-protocol-check--rc4 host port status settings)nil如果连接应继续,则该函数应返回 non- ,nil否则返回。

An element like (rc4 medium) will result in the function nsm-protocol-check--rc4 being called like thus: (nsm-protocol-check--rc4 host port status settings). The function should return non-nil if the connection should proceed and nil otherwise.

下面是在默认级别上完成的检查的列表medium

Below is a list of the checks done on the default medium level.

无法验证TLS证书
unable to verify a TLS certificate

如果连接是TLSSSLSTARTTLS连接,NSM将检查用于建立我们要连接的服务器身份的证书是否可以验证。

虽然无效的证书通常会引起关注(中间人可能会劫持您的网络连接并窃取您的密码),但无论如何仍可能有充分的理由继续连接。例如,服务器可能正在使用自签名证书,或者证书可能已过期。由您决定是否可以继续连接。

If the connection is a TLS, SSL or STARTTLS connection, NSM will check whether the certificate used to establish the identity of the server we’re connecting to can be verified.

While an invalid certificate is often the cause for concern (there could be a Man-in-the-Middle hijacking your network connection and stealing your password), there may be valid reasons for going ahead with the connection anyway. For instance, the server may be using a self-signed certificate, or the certificate may have expired. It’s up to you to determine whether it’s acceptable to continue with the connection.

自签名证书已更改
a self-signed certificate has changed

如果您之前接受了自签名证书,但现在它已更改,这可能意味着服务器刚刚更改了证书,但也可能意味着网络连接已被劫持。

If you’ve previously accepted a self-signed certificate, but it has now changed, that could mean that the server has just changed the certificate, but it might also mean that the network connection has been hijacked.

以前加密的连接现在未加密
previously encrypted connection now unencrypted

如果连接未加密,但在之前的会话中已加密,这可能意味着您和服务器之间存在代理,该代理会删除STARTTLS公告,从而使连接保持未加密状态。这通常是非常可疑的。

If the connection is unencrypted, but it was encrypted in previous sessions, this might mean that there is a proxy between you and the server that strips away STARTTLS announcements, leaving the connection unencrypted. This is usually very suspicious.

发送密码时与未加密的服务通信
talking to an unencrypted service when sending a password

连接到IMAPPOP3服务器时,通常应对这些服务器进行加密,因为通过这些连接发送密码是很常见的。同样,如果您通过SMTP发送 需要密码的电子邮件,您通常希望对该连接进行加密。如果连接未加密, NSM会警告您。

When connecting to an IMAP or POP3 server, these should usually be encrypted, because it’s common to send passwords over these connections. Similarly, if you’re sending email via SMTP that requires a password, you usually want that connection to be encrypted. If the connection isn’t encrypted, NSM will warn you.

Diffie-Hellman 低素数位
Diffie-Hellman low prime bits

在进行公钥交换时,素数位的数量应该足够高,以确保通道不会被第三方窃听。如果这个数字太低,Emacs 会警告你。 (这是办理 diffie-hellman-prime-bits登机手续 network-security-protocol-checks)。

When doing the public key exchange, the number of prime bits should be high enough to ensure that the channel can’t be eavesdropped on by third parties. If this number is too low, Emacs will warn you. (This is the diffie-hellman-prime-bits check in network-security-protocol-checks).

RC4流密码
RC4 stream cipher

RC4流密码被认为质量较低,可能会被第三方窃听。 (这是办理rc4 入住手续network-security-protocol-checks)。

The RC4 stream cipher is believed to be of low quality and may allow eavesdropping by third parties. (This is the rc4 check in network-security-protocol-checks).

主机证书或中间证书中的SHA1
SHA1 in the host certificate or in intermediate certificates

据信,如果中间证书使用 SHA1哈希算法,则第三方可以冒充该颁发实例颁发证书。因此,这些连接很容易受到中间人攻击。 (这些是signature-sha1intermediate-sha1 签入network-security-protocol-checks)。

It is believed that if an intermediate certificate uses the SHA1 hashing algorithm, then third parties can issue certificates pretending to be that issuing instance. These connections are therefore vulnerable to man-in-the-middle attacks. (These are the signature-sha1 and intermediate-sha1 checks in network-security-protocol-checks).

SSL1SSL2SSL3
SSL1, SSL2 and SSL3

人们认为早于TLS1.0 的协议容易受到各种攻击,如果您所做的事情需要更高的安全性,您可能希望避免使用这些协议。 (这是办理 ssl登机手续network-security-protocol-checks)。

The protocols older than TLS1.0 are believed to be vulnerable to a variety of attacks, and you may want to avoid using these if what you’re doing requires higher security. (This is the ssl check in network-security-protocol-checks).

如果network-security-levelhigh,除了上述检查之外,还将进行以下检查:

If network-security-level is high, the following checks will be made, in addition to the above:

3DES密码
3DES cipher

3DES流密码最多提供 112 位的有效安全性,这被认为是低端的。 (这是办理3des登机手续 network-security-protocol-checks)。

The 3DES stream cipher provides at most 112 bits of effective security, which is considered to be towards the low end. (This is the 3des check in network-security-protocol-checks).

经过验证的证书会更改公钥
a validated certificate changes the public key

服务器偶尔会更改密钥,这通常无需担心。但是,如果您担心您的网络连接被有权访问为第三方服务颁发新证书的灵活证书颁发机构的机构劫持,您可能需要跟踪这些更改。

Servers change their keys occasionally, and that is normally nothing to be concerned about. However, if you are worried that your network connections are being hijacked by agencies who have access to pliable Certificate Authorities which issue new certificates for third-party services, you may want to keep track of these changes.

最后,如果network-security-level是,当NSM第一次看到任何新证书paranoid时,您也会收到通知。这将允许您检查 Emacs 建立的所有连接的所有证书。

Finally, if network-security-level is paranoid, you will also be notified the first time NSM sees any new certificate. This will allow you to inspect all the certificates from all the connections that Emacs makes.

以下附加变量可用于控制 NSM操作的细节:

The following additional variables can be used to control details of NSM operation:

nsm-settings-file
nsm-settings-file

这是NSM存储有关连接的详细信息的文件。它默认为〜/.emacs.d/network-security.data

This is the file where NSM stores details about connections. It defaults to ~/.emacs.d/network-security.data.

nsm-save-host-names
nsm-save-host-names

默认情况下,不会保存非STARTTLS 连接的主机名。相反,主机/端口哈希用于识别连接。这意味着人们无法随意读取设置文件来查看用户连接到了哪些服务器。如果此变量为tNSM还将在 nsm-settings-file.

By default, host names will not be saved for non-STARTTLS connections. Instead a host/port hash is used to identify connections. This means that one can’t casually read the settings file to see what servers the user has connected to. If this variable is t, NSM will also save host names in the nsm-settings-file.


38 文档查看

38 Document Viewing

DocView 模式是查看 DVI、PostScript (PS)、PDF、OpenDocument、Microsoft Office、EPUB、CBZ、FB2、XPS 和 OXPS 文档的主要模式。它提供了切片、缩放和搜索文档内部等功能。它的工作原理是使用gs(GhostScript) 或 pdfdraw/ (MuPDF) 命令和其他外部工具将文档转换为一组图像mutool draw,然后显示这些转换后的图像。

DocView mode is a major mode for viewing DVI, PostScript (PS), PDF, OpenDocument, Microsoft Office, EPUB, CBZ, FB2, XPS and OXPS documents. It provides features such as slicing, zooming, and searching inside documents. It works by converting the document to a set of images using the gs (GhostScript) or pdfdraw/mutool draw (MuPDF) commands and other external tools, and then displays those converted images.

当您访问可以使用 DocView 模式显示的文档文件时,Emacs 会自动使用该模式21。例外的是,当您访问 PostScript 文件时,Emacs 会切换到 PS 模式,这是一种将 PostScript 文件编辑为文本的主要模式;但是,它还启用了 DocView 次要模式,因此您可以键入 C-c C-c内容以使用 DocView 查看文档。在 DocView 模式或 DocView 次要模式下,重复C-c C-c ( doc-view-toggle-display) 可在 DocView 和底层文件内容之间切换。

When you visit a document file that can be displayed with DocView mode, Emacs automatically uses that mode 21. As an exception, when you visit a PostScript file, Emacs switches to PS mode, a major mode for editing PostScript files as text; however, it also enables DocView minor mode, so you can type C-c C-c to view the document with DocView. In either DocView mode or DocView minor mode, repeating C-c C-c (doc-view-toggle-display) toggles between DocView and the underlying file contents.

当您访问通常由 DocView 模式处理的文件但不满足某些要求时(例如,您在终端框架中操作或 Emacs 不支持 PNG),系统会询问您是否要以纯文本形式查看文档内容。如果确认,缓冲区将置于文本模式,并激活 DocView 次要模式。因此,通过键入C-c C-c即可切换到后备模式。使用另一个, C-c C-c您将返回到 DocView 模式。也可以通过键入C-c C-t ( )在 DocView 模式中显示纯文本内容doc-view-open-text

When you visit a file which would normally be handled by DocView mode but some requirement is not met (e.g., you operate in a terminal frame or Emacs has no PNG support), you are queried if you want to view the document’s contents as plain text. If you confirm, the buffer is put in text mode and DocView minor mode is activated. Thus, by typing C-c C-c you switch to the fallback mode. With another C-c C-c you return to DocView mode. The plain text contents can also be displayed from within DocView mode by typing C-c C-t (doc-view-open-text).

您可以使用命令显式启用 DocView 模式M-x doc-view-mode。您可以使用 切换 DocView 次要模式M-x doc-view-minor-mode

You can explicitly enable DocView mode with the command M-x doc-view-mode. You can toggle DocView minor mode with M-x doc-view-minor-mode.

当 DocView 模式启动时,它会显示欢迎屏幕并开始逐页格式化文件。格式化后,它会显示第一页。

When DocView mode starts, it displays a welcome screen and begins formatting the file, page by page. It displays the first page once that has been formatted.

要终止 DocView 缓冲区,请键入k ( doc-view-kill-proc-and-buffer)。要隐藏它,请键入q ( quit-window)。

To kill the DocView buffer, type k (doc-view-kill-proc-and-buffer). To bury it, type q (quit-window).


38.1 文档视图导航

38.1 DocView Navigation

在 DocView 模式下,您可以使用常用的 Emacs 移动键滚动当前页面:C-pC-nC-bC-f和箭头键。

In DocView mode, you can scroll the current page using the usual Emacs movement keys: C-p, C-n, C-b, C-f, and the arrow keys.

默认情况下,直线运动键C-pC-n分别在当前页面的开头和结尾处停止滚动。但是,如果将该变量更改doc-view-continuous为非值nil,则C-p如果已位于当前页的开头,则显示上一页;C-n 如果位于当前页的末尾,则显示下一页。

By default, the line-motion keys C-p and C-n stop scrolling at the beginning and end of the current page, respectively. However, if you change the variable doc-view-continuous to a non-nil value, then C-p displays the previous page if you are already at the beginning of the current page, and C-n displays the next page if you are at the end of the current page.

您还可以通过键入nPageDown或( )显示下一页。要显示上一页,请键入 、或( ) 。 nextC-x ]doc-view-next-pagepPageUppriorC-x [doc-view-previous-page

You can also display the next page by typing n, PageDown, next or C-x ] (doc-view-next-page). To display the previous page, type p, PageUp, prior or C-x [ (doc-view-previous-page).

SPC( doc-view-scroll-up-or-next-page) 是浏览文档的便捷方式。它在当前页面内滚动或前进到下一页。 DEL以类似的方式向后移动 ( doc-view-scroll-down-or-previous-page)。

SPC (doc-view-scroll-up-or-next-page) is a convenient way to advance through the document. It scrolls within the current page or advances to the next. DEL moves backwards in a similar way (doc-view-scroll-down-or-previous-page).

要转到第一页,请键入M-< ( doc-view-first-page);要转到最后一个,请键入M-> ( doc-view-last-page)。要按页码跳转到页面,请键入 M-g M-gM-g g( doc-view-goto-page)。

To go to the first page, type M-< (doc-view-first-page); to go to the last one, type M-> (doc-view-last-page). To jump to a page by its number, type M-g M-g or M-g g (doc-view-goto-page).

+ 您可以使用( doc-view-enlarge) 和-( )放大或缩小文档doc-view-shrink。默认情况下,这些命令只是重新缩放已渲染的图像。如果您希望图像以新尺寸重新渲染,请设置 doc-view-scale-internallynil。要指定 DocView 的默认大小,请自定义变量 doc-view-resolution

You can enlarge or shrink the document with + (doc-view-enlarge) and - (doc-view-shrink). By default, these commands just rescale the already-rendered image. If you instead want the image to be re-rendered at the new size, set doc-view-scale-internally to nil. To specify the default size for DocView, customize the variable doc-view-resolution.

当该mutool程序可用时,DocView 将使用它来生成大纲菜单的条目,使其可以通过该 imenu工具进行访问(请参阅Imenu)。即使mutool在您的系统上可以找到此功能,也要禁用此功能,请将变量自定义doc-view-imenu-enablednil值。您可以imenu使用变量doc-view-imenu-format和 进一步自定义项目的格式和显示方式doc-view-flatten

When the mutool program is available, DocView will use it to generate entries for an outline menu, making it accessible via the imenu facility (see Imenu). To disable this functionality even when mutool can be found on your system, customize the variable doc-view-imenu-enabled to the nil value. You can further customize how imenu items are formatted and displayed using the variables doc-view-imenu-format and doc-view-flatten.


38.2 文档视图搜索

38.2 DocView Searching

在 DocView 模式下,您可以在文件文本中搜索正则表达式(请参阅正则表达式的语法)。搜索界面的灵感来自isearch(参见增量搜索)。

In DocView mode, you can search the file’s text for a regular expression (see Syntax of Regular Expressions). The interface for searching is inspired by isearch (see Incremental Search).

要开始搜索,请键入C-s( doc-view-search) 或 C-r( doc-view-search-backward)。这使用迷你缓冲区读取正则表达式,然后回显在文档中找到的匹配项的数量。您可以通过键入C-s和在比赛中前进和后退C-r。 DocView模式无法显示页面图像内的匹配;相反,它会显示一个工具提示(在鼠标位置),列出当前页面中的所有匹配行。要强制显示此工具提示,请键入C-t ( doc-view-show-tooltip)。

To begin a search, type C-s (doc-view-search) or C-r (doc-view-search-backward). This reads a regular expression using a minibuffer, then echoes the number of matches found within the document. You can move forward and back among the matches by typing C-s and C-r. DocView mode has no way to show the match inside the page image; instead, it displays a tooltip (at the mouse position) listing all matching lines in the current page. To force display of this tooltip, type C-t (doc-view-show-tooltip).

要开始新的搜索,请使用带有前缀参数的搜索命令;即,C-u C-s用于向前搜索或C-u C-r 向后搜索。

To start a new search, use the search command with a prefix argument; i.e., C-u C-s for a forward search or C-u C-r for a backward search.


38.3 DocView切片

38.3 DocView Slicing

文档通常具有较宽的打印边距。在阅读屏幕上的文档时,它们很烦人,因为它们会占用屏幕空间并导致滚动不方便。

Documents often have wide margins for printing. They are annoying when reading the document on the screen, because they use up screen space and can cause inconvenient scrolling.

使用 DocView,您可以通过选择要显示的页面切片来隐藏这些边距。切片是页面区域内的一个矩形;一旦您在 DocView 中指定了一个切片,它就会应用于您查看的任何页面。

With DocView you can hide these margins by selecting a slice of pages to display. A slice is a rectangle within the page area; once you specify a slice in DocView, it applies to whichever page you look at.

要以数字方式指定切片,请键入c s ( doc-view-set-slice);然后输入左上角像素位置以及切片的宽度和高度。

To specify the slice numerically, type c s (doc-view-set-slice); then enter the top left pixel position and the slice’s width and height.

指定切片的更方便的图形方式是使用c m( doc-view-set-slice-using-mouse),您可以使用鼠标选择切片。只需在要切片的区域的左上角按住鼠标左键,然后将鼠标指针移动到右下角并释放按钮即可。

A more convenient graphical way to specify the slice is with c m (doc-view-set-slice-using-mouse), where you use the mouse to select the slice. Simply press and hold the left mouse button at the upper-left corner of the region you want to have in the slice, then move the mouse pointer to the lower-right corner and release the button.

最方便的方法是使用通过键入c b( doc-view-set-slice-from-bounding-box) 从文档中自动确定的 BoundingBox 信息来设置最佳切片。

The most convenient way is to set the optimal slice by using BoundingBox information automatically determined from the document by typing c b (doc-view-set-slice-from-bounding-box).

要取消选定的切片,请键入c r ( doc-view-reset-slice)。然后 DocView 显示整个页面,包括其整个边距。

To cancel the selected slice, type c r (doc-view-reset-slice). Then DocView shows the entire page including its entire margins.


38.4 文档视图转换

38.4 DocView Conversion

为了提高效率,DocView 缓存gs.缓存图像的目录名称由变量 给出 doc-view-cache-directory。您可以通过键入 来清除缓存目录M-x doc-view-clear-cache

For efficiency, DocView caches the images produced by gs. The name of the directory where it caches images is given by the variable doc-view-cache-directory. You can clear the cache directory by typing M-x doc-view-clear-cache.

要强制重新转换当前查看的文档,请键入rg( revert-buffer)。要终止与当前缓冲区关联的转换器进程,请键入K ( doc-view-kill-proc)。命令k ( doc-view-kill-proc-and-buffer) 终止转换器进程和 DocView 缓冲区。

To force reconversion of the currently viewed document, type r or g (revert-buffer). To kill the converter process associated with the current buffer, type K (doc-view-kill-proc). The command k (doc-view-kill-proc-and-buffer) kills the converter process and the DocView buffer.


39 从 Emacs 运行 Shell 命令

39 Running Shell Commands from Emacs

Emacs 具有用于将单个命令行传递到 shell 子进程、用于通过 Emacs 缓冲区的输入和输出交互运行 shell 以及用于在终端仿真器窗口中运行 shell 的命令。

Emacs has commands for passing single command lines to shell subprocesses, and for running a shell interactively with input and output to an Emacs buffer, and for running a shell in a terminal emulator window.

M-! cmd RET
M-! cmd RET

运行 shell 命令cmd并显示输出 ( shell-command)。

Run the shell command cmd and display the output (shell-command).

M-| cmd RET
M-| cmd RET

以区域内容作为输入运行 shell 命令cmd ;可以选择用输出 ( shell-command-on-region) 替换该区域。

Run the shell command cmd with region contents as input; optionally replace the region with the output (shell-command-on-region).

M-& cmd RET
M-& cmd RET

异步运行 shell 命令cmd,并显示输出 ( async-shell-command)。

Run the shell command cmd asynchronously, and display the output (async-shell-command).

M-x shell
M-x shell

通过 Emacs 缓冲区运行具有输入和输出的子 shell。然后您可以交互式地发出命令。

Run a subshell with input and output through an Emacs buffer. You can then give commands interactively.

M-x term
M-x term

通过 Emacs 缓冲区运行具有输入和输出的子 shell。然后您可以交互式地发出命令。可以使用完整的终端仿真。

Run a subshell with input and output through an Emacs buffer. You can then give commands interactively. Full terminal emulation is available.

每当您为可执行程序指定相对文件名时(无论是在上述命令之一的cmdexec-path参数中,还是在其他上下文中),Emacs 都会在变量指定的目录中搜索该程序。该变量的值必须是目录列表;默认值是PATH在 Emacs 启动时从环境变量初始化的(请参阅常规变量)。

Whenever you specify a relative file name for an executable program (either in the cmd argument to one of the above commands, or in other contexts), Emacs searches for the program in the directories specified by the variable exec-path. The value of this variable must be a list of directories; the default value is initialized from the environment variable PATH when Emacs is started (see General Variables).

M-x eshell调用完全在 Emacs 中实现的 shell。它记录在其自己的手册中。请参阅Eshell中的Eshell :Emacs Shell

M-x eshell invokes a shell implemented entirely in Emacs. It is documented in its own manual. See Eshell in Eshell: The Emacs Shell.


39.1 单Shell命令

39.1 Single Shell Commands

M-!( shell-command) 使用迷你缓冲区读取一行文本,并将其作为 shell 命令在专门为该命令创建的子 shell 中执行。命令的标准输入来自空设备。如果 shell 命令产生任何输出,则输出将出现在 echo 区域(如果很短)或 '“*Shell 命令输出*”' ( shell-command-buffer-name) 缓冲区(如果输出很长)。变量resize-mini-windowsmax-mini-window-height(请参阅在迷你缓冲区中编辑)控制 Emacs 何时应考虑输出对于回显区域来说太长。请注意,shell-command-dont-erase-buffer如下所述的自定义可能会影响回显区域中显示的内容。

M-! (shell-command) reads a line of text using the minibuffer and executes it as a shell command, in a subshell made just for that command. Standard input for the command comes from the null device. If the shell command produces any output, the output appears either in the echo area (if it is short), or in the ‘"*Shell Command Output*"’ (shell-command-buffer-name) buffer (if the output is long). The variables resize-mini-windows and max-mini-window-height (see Editing in the Minibuffer) control when Emacs should consider the output to be too long for the echo area. Note that customizing shell-command-dont-erase-buffer, described below, can affect what is displayed in the echo area.

例如,解压缩名为的文件的一种方法foo.gz就是打字。该 shell 命令通常会创建文件M-! gunzip foo.gz RET并且不产生终端输出。

For instance, one way to decompress a file named foo.gz is to type M-! gunzip foo.gz RET. That shell command normally creates the file foo and produces no terminal output.

的数字参数(shell-command例如,M-1 M-!)导致它将终端输出插入到当前缓冲区而不是单独的缓冲区中。默认情况下,它在输出之前放置点,并在输出之后设置标记(但非默认值 shell-command-dont-erase-buffer可以更改它,请参见下文)。例如,将插入文件的未压缩形式M-1 M-! gunzip < foo.gz RETfoo.gz到当前缓冲区。

A numeric argument to shell-command, e.g., M-1 M-!, causes it to insert terminal output into the current buffer instead of a separate buffer. By default, it puts point before the output, and sets the mark after the output (but a non-default value of shell-command-dont-erase-buffer can change that, see below). For instance, M-1 M-! gunzip < foo.gz RET would insert the uncompressed form of the file foo.gz into the current buffer.

前提是指定的 shell 命令不以 ' 结尾&',它是同步运行的,你必须等待它退出才能继续使用Emacs。要停止等待,请输入C-g退出;这会发送一个信号来终止 shell 命令(这与通常在 shell 中生成的SIGINT信号相同)。C-c然后,Emacs 会等待,直到命令实际终止。如果 shell 命令没有停止(因为它忽略了SIGINT信号),请C-g再次输入;这会向命令发送一个SIGKILL信号,该信号不可能被忽略。

Provided the specified shell command does not end with ‘&’, it runs synchronously, and you must wait for it to exit before continuing to use Emacs. To stop waiting, type C-g to quit; this sends a SIGINT signal to terminate the shell command (this is the same signal that C-c normally generates in the shell). Emacs then waits until the command actually terminates. If the shell command doesn’t stop (because it ignores the SIGINT signal), type C-g again; this sends the command a SIGKILL signal, which is impossible to ignore.

以 ' 结尾的 shell 命令&' 是 异步执行的,您可以在 Emacs 运行时继续使用它。您还可以键入M-&( async-shell-command) 来异步执行 shell 命令;这就像M-! 用尾随的 '进行调用一样&',除非你不需要 '&'。默认情况下,异步 shell 命令的输出进入““*异步 Shell 命令*”' 缓冲 (shell-command-buffer-name-async)。 Emacs 在输出进入时将其插入到该缓冲区中,无论该缓冲区在窗口中是否可见。

A shell command that ends in ‘&’ is executed asynchronously, and you can continue to use Emacs as it runs. You can also type M-& (async-shell-command) to execute a shell command asynchronously; this is exactly like calling M-! with a trailing ‘&’, except that you do not need the ‘&’. The output from asynchronous shell commands, by default, goes into the ‘"*Async Shell Command*"’ buffer (shell-command-buffer-name-async). Emacs inserts the output into this buffer as it comes in, whether or not the buffer is visible in a window.

如果您想同时运行多个异步 shell 命令,它们最终可能会竞争输出缓冲区。该选项async-shell-command-buffer指定对此采取的措施;例如,是否重命名预先存在的输出缓冲区,或者为新命令使用不同的缓冲区。有关更多可能性,请参阅变量的文档。

If you want to run more than one asynchronous shell command at the same time, they could end up competing for the output buffer. The option async-shell-command-buffer specifies what to do about this; e.g., whether to rename the pre-existing output buffer, or to use a different buffer for the new command. Consult the variable’s documentation for more possibilities.

如果您希望异步 shell 命令的输出缓冲区仅在命令生成输出时显示,请设置 async-shell-command-display-buffernil

If you want the output buffer for asynchronous shell commands to be displayed only when the command generates output, set async-shell-command-display-buffer to nil.

该选项async-shell-command-width定义可用于异步 shell 命令输出的显示列数。正整数告诉 shell 使用该列数进行命令输出。默认值nil意味着使用与 shell 提供的列数相同的列数。

The option async-shell-command-width defines the number of display columns available for output of asynchronous shell commands. A positive integer tells the shell to use that number of columns for command output. The default value is nil that means to use the same number of columns as provided by the shell.

要使上述命令在提示中显示当前目录,请将变量自定义shell-command-prompt-show-cwd 为非值nil

To make the above commands show the current directory in their prompts, customize the variable shell-command-prompt-show-cwd to a non-nil value.

M-|( shell-command-on-region) 与 类似M-!,但将区域内容作为标准输入传递给 shell 命令,而不是不输入。使用数字参数,它会删除旧区域并将其替换为 shell 命令的输出。

M-| (shell-command-on-region) is like M-!, but passes the contents of the region as the standard input to the shell command, instead of no input. With a numeric argument, it deletes the old region and replaces it with the output from the shell command.

例如,您可以使用M-|gpg程序来查看缓冲区中有哪些键。如果缓冲区包含 GnuPG 键,请键入以将整个缓冲区内容提供给。这会将键列表输出到名称为 的值的缓冲区。 C-x h M-| gpg RETgpgshell-command-buffer-name

For example, you can use M-| with the gpg program to see what keys are in the buffer. If the buffer contains a GnuPG key, type C-x h M-| gpg RET to feed the entire buffer contents to gpg. This will output the list of keys to the buffer whose name is the value of shell-command-buffer-name.

上述命令使用变量 指定的 shell shell-file-name。其默认值由SHELLEmacs启动时的环境变量决定 。如果文件名是相对的,Emacs 会搜索列出的目录 exec-path(请参阅从 Emacs 运行 Shell 命令)。

The above commands use the shell specified by the variable shell-file-name. Its default value is determined by the SHELL environment variable when Emacs is started. If the file name is relative, Emacs searches the directories listed in exec-path (see Running Shell Commands from Emacs).

如果默认目录是远程(请参阅远程文件),则默认值为/bin/sh。这可以通过声明shell-file-name连接本地来更改 (请参阅每连接本地变量)。

If the default directory is remote (see Remote Files), the default value is /bin/sh. This can be changed by declaring shell-file-name connection-local (see Per-Connection Local Variables).

M-!要指定或 的编码系统,请立即M-|使用该命令 。请参阅进程间通信的编码系统C-x RET c

To specify a coding system for M-! or M-|, use the command C-x RET c immediately beforehand. See Coding Systems for Interprocess Communication.

默认情况下,错误输出与输出缓冲区中的常规输出混合。但是,如果将变量的值更改 shell-command-default-error-buffer为字符串,错误输出将插入到该名称的缓冲区中。

By default, error output is intermixed with the regular output in the output buffer. But if you change the value of the variable shell-command-default-error-buffer to a string, error output is inserted into a buffer of that name.

默认情况下,输出缓冲区在 shell 命令之间被擦除,除非输出进入当前缓冲区。如果将该选项的值更改shell-command-dont-erase-buffererase,则输出缓冲区始终会被擦除。其他非nil值可防止擦除输出缓冲区,并且(如果输出缓冲区不是当前缓冲区)还可以控制在插入 shell 命令的输出后将指向的位置:

By default, the output buffer is erased between shell commands, except when the output goes to the current buffer. If you change the value of the option shell-command-dont-erase-buffer to erase, then the output buffer is always erased. Other non-nil values prevent erasing of the output buffer, and—if the output buffer is not the current buffer—also control where to put point after inserting the output of the shell command:

beg-last-out
beg-last-out

将点放在最后一个 shell 命令输出的开头。

Puts point at the beginning of the last shell-command output.

end-last-out
end-last-out

将点放在最后一个 shell 命令输出的末尾,即输出缓冲区的末尾。

Puts point at the end of the last shell-command output, i.e. at the end of the output buffer.

save-point
save-point

将点的位置恢复为插入 shell 命令输出之前的位置。

Restores the position of point as it was before inserting the shell-command output.

请注意,如果此选项为非 - nil,则回显区域中显示的输出可能不仅仅来自最后一个命令,因为回显区域仅显示输出缓冲区的一部分。

Note that if this option is non-nil, the output shown in the echo area could be from more than just the last command, since the echo area just displays a portion of the output buffer.

如果输出缓冲区不是当前缓冲区,则 shell 命令输出将附加到该缓冲区的末尾。

In case the output buffer is not the current buffer, shell command output is appended at the end of this buffer.


39.2 交互式子shell

39.2 Interactive Subshell

要以交互方式运行子 shell,请键入M-x shell。这将创建(或重用)一个名为的缓冲区*壳*,并运行一个 shell 子进程,输入来自该缓冲区,输出发送到该缓冲区。也就是说,子 shell 的任何终端输出都会进入缓冲区,前进点,子 shell 的任何终端输入都来自缓冲区中的文本。要向子 shell 提供输入,请转到缓冲区末尾并键入输入,以 结尾RET

To run a subshell interactively, type M-x shell. This creates (or reuses) a buffer named *shell*, and runs a shell subprocess with input coming from and output going to that buffer. That is to say, any terminal output from the subshell goes into the buffer, advancing point, and any terminal input for the subshell comes from text in the buffer. To give input to the subshell, go to the end of the buffer and type the input, terminated by RET.

默认情况下,当交互调用子 shell 时, *壳*缓冲区显示在新窗口中,除非当前窗口已经显示*壳*缓冲。此行为可以通过display-buffer-alist(参见工作原理display-buffer)进行自定义。

By default, when the subshell is invoked interactively, the *shell* buffer is displayed in a new window, unless the current window already shows the *shell* buffer. This behavior can be customized via display-buffer-alist (see How display-buffer works).

当子 shell 等待或运行命令时,您可以切换窗口或缓冲区并在 Emacs 中执行其他编辑。只要 Emacs 有时间处理(例如,在等待键盘输入时),Emacs 就会将子 shell 的输出插入到 Shell 缓冲区中。

While the subshell is waiting or running a command, you can switch windows or buffers and perform other editing in Emacs. Emacs inserts the output from the subshell into the Shell buffer whenever it has time to process it (e.g., while waiting for keyboard input).

在 Shell 缓冲区中,提示会通过face显示 comint-highlight-prompt,提交的输入行也会通过face显示comint-highlight-input。这使得区分输入行和 shell 输出变得更加容易。请参阅文本面孔

In the Shell buffer, prompts are displayed with the face comint-highlight-prompt, and submitted input lines are displayed with the face comint-highlight-input. This makes it easier to distinguish input lines from the shell output. See Text Faces.

要创建多个子 shell,请M-x shell使用前缀参数(例如C-u M-x shell)进行调用。然后该命令将读取缓冲区名称,并在该缓冲区中创建(或重用)一个子 shell。您还可以重命名*壳*使用缓冲区M-x rename-uniquely,然后创建一个新的*壳*使用普通缓冲区M-x shell。不同缓冲区中的子shell独立且并行运行。

To make multiple subshells, invoke M-x shell with a prefix argument (e.g., C-u M-x shell). Then the command will read a buffer name, and create (or reuse) a subshell in that buffer. You can also rename the *shell* buffer using M-x rename-uniquely, then create a new *shell* buffer using plain M-x shell. Subshells in different buffers run independently and in parallel.

Emacs 尝试通过查看您输入的命令来跟踪当前目录,查找 '光盘' 命令等。这是一个容易出错的解决方案,因为有很多方法可以更改当前目录,因此 Emacs 还会寻找特殊的 OSC(操作系统命令)转义码,这些转义码旨在以更可靠的方式传达此信息。您应该安排 shell 在每个提示符下打印适当的转义序列,例如使用以下命令:

Emacs attempts to keep track of what the current directory is by looking at the commands you enter, looking for ‘cd’ commands and the like. This is an error-prone solution, since there are many ways to change the current directory, so Emacs also looks for special OSC (Operating System Commands) escape codes that are designed to convey this information in a more reliable fashion. You should arrange for your shell to print the appropriate escape sequence at each prompt, for instance with the following command:

printf "\e]7;file://%s%s\e\\" "$HOSTNAME" "$PWD"
printf "\e]7;file://%s%s\e\\" "$HOSTNAME" "$PWD"

要指定 所使用的 shell 文件名M-x shell,请自定义变量explicit-shell-file-name。如果这是nil (默认),Emacs 将使用该环境变量ESHELL(如果存在)。否则,它通常使用变量 shell-file-name(参见Single Shell Commands);但如果默认目录是远程(请参阅远程文件),它会提示您输入 shell 文件名。请参阅文件名迷你缓冲区,了解如何有效键入远程文件名的提示。

To specify the shell file name used by M-x shell, customize the variable explicit-shell-file-name. If this is nil (the default), Emacs uses the environment variable ESHELL if it exists. Otherwise, it usually uses the variable shell-file-name (see Single Shell Commands); but if the default directory is remote (see Remote Files), it prompts you for the shell file name. See Minibuffers for File Names, for hints how to type remote file names effectively.

Emacs 向新 shell 发送文件内容 ~/.emacs_ shellname作为输入(如果存在),其中 shellname是加载 shell 的文件的名称。例如,如果您使用 bash,则发送给它的文件是 〜/ .emacs_bash。如果找不到该文件,Emacs 会尝试使用 ~/.emacs.d/init_ shellname .sh

Emacs sends the new shell the contents of the file ~/.emacs_shellname as input, if it exists, where shellname is the name of the file that the shell was loaded from. For example, if you use bash, the file sent to it is ~/.emacs_bash. If this file is not found, Emacs tries with ~/.emacs.d/init_shellname.sh.

要指定 shell 的编码系统,可以在 之前使用命令 。您还可以通过在 shell 缓冲区中键入来更改正在运行的子 shell 的编码系统 。请参阅进程间通信的编码系统C-x RET cM-x shellC-x RET p

To specify a coding system for the shell, you can use the command C-x RET c immediately before M-x shell. You can also change the coding system for a running subshell by typing C-x RET p in the shell buffer. See Coding Systems for Interprocess Communication.

INSIDE_EMACSEmacs 将子 shell 中的环境变量设置为 '版本,comint',其中version是 Emacs 版本(例如,'28.1')。程序可以检查此变量以确定它们是否在 Emacs 子 shell 内运行。

Emacs sets the environment variable INSIDE_EMACS in the subshell to ‘version,comint’, where version is the Emacs version (e.g., ‘28.1’). Programs can check this variable to determine whether they are running inside an Emacs subshell.


39.3 外壳模式

39.3 Shell Mode

Shell 缓冲区的主要模式是 Shell 模式。它的许多特殊命令都绑定到前缀C-c,并且类似于普通 shell 中常见的编辑和作业控制字符,只是您必须先键入C-c。以下是 Shell 模式命令的列表:

The major mode for Shell buffers is Shell mode. Many of its special commands are bound to the C-c prefix, and resemble the usual editing and job control characters present in ordinary shells, except that you must type C-c first. Here is a list of Shell mode commands:

RET
RET

将当前行作为输入发送到子 shell ( comint-send-input)。行开头的任何 shell 提示符都会被省略(请参阅Shell 提示符)。如果点位于缓冲区的末尾,则这就像在普通交互式 shell 中提交命令行一样。但是,您也可以调用RETshell 缓冲区中的其他位置来提交当前行作为输入。

Send the current line as input to the subshell (comint-send-input). Any shell prompt at the beginning of the line is omitted (see Shell Prompts). If point is at the end of buffer, this is like submitting the command line in an ordinary interactive shell. However, you can also invoke RET elsewhere in the shell buffer to submit the current line as input.

TAB
TAB

在 shell 缓冲区中的点之前完成命令名或文件名 ( completion-at-point)。这使用通常的 Emacs 完成规则(请参阅完成),完成替代项是文件名、环境变量名称、shell 命令历史记录和历史引用(请参阅Shell 历史引用)。有关控制完成的选项,请参阅Shell 模式选项

Complete the command name or file name before point in the shell buffer (completion-at-point). This uses the usual Emacs completion rules (see Completion), with the completion alternatives being file names, environment variable names, the shell command history, and history references (see Shell History References). For options controlling the completion, see Shell Mode Options.

M-?
M-?

临时显示点 ( ) 之前文件名的可能补全列表comint-dynamic-list-filename-completions

Display temporarily a list of the possible completions of the file name before point (comint-dynamic-list-filename-completions).

C-d
C-d

删除一个字符或发送EOF ( comint-delchar-or-maybe-eof)。在 shell 缓冲区的末尾键入,这会将EOF发送到子 shell。在缓冲区中的任何其他位置键入,这都会像往常一样删除一个字符。

Either delete a character or send EOF (comint-delchar-or-maybe-eof). Typed at the end of the shell buffer, this sends EOF to the subshell. Typed at any other position in the buffer, this deletes a character as usual.

C-c C-a
C-c C-a

移动到行首,但在提示(如果有comint-bol-or-process-mark)之后。如果您连续重复此命令两次,第二次它会移回进程标记,这是您尚未发送到子 shell 的输入的开头。 (通常这是同一位置 - 该行提示的末尾 - 但在进程标记之后可能位于上一行。) C-c SPC

Move to the beginning of the line, but after the prompt if any (comint-bol-or-process-mark). If you repeat this command twice in a row, the second time it moves back to the process mark, which is the beginning of the input that you have not yet sent to the subshell. (Normally that is the same place—the end of the prompt on this line—but after C-c SPC the process mark may be in a previous line.)

C-c SPC
C-c SPC

累积多行输入,然后将它们一起发送 ( comint-accumulate)。此命令在 point 之前插入换行符,但不会将前面的文本作为输入发送到子 shell — 至少现在还没有。当您键入 时,这两行(换行符之前的一行和之后的一行)将一起发送(以及分隔它们的换行符)RET

Accumulate multiple lines of input, then send them together (comint-accumulate). This command inserts a newline before point, but does not send the preceding text as input to the subshell—at least, not yet. Both lines, the one before this newline and the one after, will be sent together (along with the newline that separates them), when you type RET.

C-c C-u
C-c C-u

终止缓冲区末尾待处理的所有文本,以作为输入发送 ( comint-kill-input)。如果 point 不在缓冲区末尾,则只会删除该文本中 point 之前的部分。

Kill all text pending at end of buffer to be sent as input (comint-kill-input). If point is not at end of buffer, this only kills the part of this text that precedes point.

C-c C-w
C-c C-w

删除 ( ) 点之前的一个单词backward-kill-word

Kill a word before point (backward-kill-word).

C-c C-c
C-c C-c

中断 shell 或其当前子作业(如果有)( comint-interrupt-subjob)。此命令还会终止 shell 缓冲区中待处理且尚未发送的所有 shell 输入。

Interrupt the shell or its current subjob if any (comint-interrupt-subjob). This command also kills any shell input pending in the shell buffer and not yet sent.

C-c C-z
C-c C-z

停止 shell 或其当前子作业(如果有)( comint-stop-subjob)。此命令还会终止 shell 缓冲区中待处理且尚未发送的所有 shell 输入。

Stop the shell or its current subjob if any (comint-stop-subjob). This command also kills any shell input pending in the shell buffer and not yet sent.

C-c C-\
C-c C-\

向 shell 或其当前子作业(如果有comint-quit-subjob)发送退出信号 ( )。此命令还会终止 shell 缓冲区中待处理且尚未发送的所有 shell 输入。

Send quit signal to the shell or its current subjob if any (comint-quit-subjob). This command also kills any shell input pending in the shell buffer and not yet sent.

C-c C-o
C-c C-o

删除 shell 命令的最后一批输出 ( comint-delete-output)。如果 shell 命令输出大量阻碍的输出,这非常有用。使用前缀参数,此命令将删除的文本保存在kill-ring (请参阅The Kill Ring)中,以便您稍后可以在其他地方将其拉出(请参阅Yanking)。

Delete the last batch of output from a shell command (comint-delete-output). This is useful if a shell command spews out lots of output that just gets in the way. With a prefix argument, this command saves the deleted text in the kill-ring (see The Kill Ring), so that you could later yank it (see Yanking) elsewhere.

C-c C-s
C-c C-s

将 shell 命令的最后一批输出写入文件 ( comint-write-output)。使用前缀参数,文件将被附加到。输出末尾的任何提示都不会写入。

Write the last batch of output from a shell command to a file (comint-write-output). With a prefix argument, the file is appended to instead. Any prompt at the end of the output is not written.

C-c C-r
C-c C-r
C-M-l
C-M-l

滚动以在窗口顶部显示最后一批输出的开头;也将光标移动到那里 ( comint-show-output)。

Scroll to display the beginning of the last batch of output at the top of the window; also move the cursor there (comint-show-output).

C-c C-e
C-c C-e

滚动将缓冲区的最后一行放在窗口底部 ( comint-show-maximum-output)。

Scroll to put the last line of the buffer at the bottom of the window (comint-show-maximum-output).

C-c C-f
C-c C-f

向前移动一个 shell 命令,但不要超出当前行 ( shell-forward-command)。该变量shell-command-regexp 指定如何识别命令的结尾。

Move forward across one shell command, but not beyond the current line (shell-forward-command). The variable shell-command-regexp specifies how to recognize the end of a command.

C-c C-b
C-c C-b

向后移动一个 shell 命令,但不要超出当前行 ( shell-backward-command)。

Move backward across one shell command, but not beyond the current line (shell-backward-command).

M-x dirs
M-x dirs

向 shell 询问其工作目录,并更新 Shell 缓冲区的默认目录。请参阅目录跟踪

Ask the shell for its working directory, and update the Shell buffer’s default directory. See Directory Tracking.

M-x comint-send-invisible RET text RET
M-x comint-send-invisible RET text RET

读取文本后,将文本作为输入发送到 shell,而不进行回显。当 shell 命令运行要求输入密码的程序时,这非常有用。

请注意,Emacs 默认情况下不会回显密码。如果您确实希望它们得到回显,请评估(请参阅评估 Emacs Lisp 表达式)以下 Lisp 表达式:

(删除钩子'comint-output-filter-functions
             'comint-watch-password-prompt)

Send text as input to the shell, after reading it without echoing. This is useful when a shell command runs a program that asks for a password.

Please note that Emacs will not echo passwords by default. If you really want them to be echoed, evaluate (see Evaluating Emacs Lisp Expressions) the following Lisp expression:

(remove-hook 'comint-output-filter-functions
             'comint-watch-for-password-prompt)
M-x comint-continue-subjob
M-x comint-continue-subjob

继续外壳过程。如果您意外挂起 shell 进程,这会很有用。22

Continue the shell process. This is useful if you accidentally suspend the shell process.22

M-x comint-strip-ctrl-m
M-x comint-strip-ctrl-m

丢弃当前 shell 输出组中的所有 control-M 字符。使用此命令最方便的方法是当您从子 shell 获取输出时使其自动运行。为此,请计算此 Lisp 表达式:

(添加钩子'comint-output-filter-functions
          'comint-strip-ctrl-m)

Discard all control-M characters from the current group of shell output. The most convenient way to use this command is to make it run automatically when you get output from the subshell. To do that, evaluate this Lisp expression:

(add-hook 'comint-output-filter-functions
          'comint-strip-ctrl-m)
M-x comint-truncate-buffer
M-x comint-truncate-buffer

此命令将 shell 缓冲区截断为由变量 指定的某个最大行数comint-buffer-maximum-size。以下是每次从子 shell 获取输出时自动执行此操作的方法:

(添加钩子'comint-output-filter-functions
          'comint-截断-缓冲区)

This command truncates the shell buffer to a certain maximum number of lines, specified by the variable comint-buffer-maximum-size. Here’s how to do this automatically each time you get output from the subshell:

(add-hook 'comint-output-filter-functions
          'comint-truncate-buffer)

默认情况下,Shell 模式处理常见的ANSI转义码(例如,用于更改文本的颜色)。如果您将以下内容放入 init 文件中, Emacs 还可以选择支持一些扩展转义代码,例如某些OSC (操作系统代码):

By default, Shell mode handles common ANSI escape codes (for instance, for changing the color of text). Emacs also optionally supports some extend escape codes, like some of the OSC (Operating System Codes) if you put the following in your init file:

(添加钩子'comint-output-filter-functions'comint-osc-process-output)
(add-hook 'comint-output-filter-functions 'comint-osc-process-output)

启用此功能后,例如,输出ls --hyperlink将被制作为 Shell 模式缓冲区中的可点击按钮。

With this enabled, the output from, for instance, ls --hyperlink will be made into clickable buttons in the Shell mode buffer.

Shell 模式是 Comint 模式的衍生模式,Comint 模式是一种与交互式子进程通信的通用模式。 Shell模式的大部分功能实际上都来自Comint模式,从上面列出的命令名称可以看出。 Shell 模式的特殊功能包括目录跟踪功能和一些用户命令。

Shell mode is a derivative of Comint mode, a general-purpose mode for communicating with interactive subprocesses. Most of the features of Shell mode actually come from Comint mode, as you can see from the command names listed above. The special features of Shell mode include the directory tracking feature, and a few user commands.

使用 Comint 模式变体的其他 Emacs 功能包括 GUD(请参阅在 Emacs 下运行调试器)和M-x run-lisp(请参阅运行外部 Lisp)。

Other Emacs features that use variants of Comint mode include GUD (see Running Debuggers Under Emacs) and M-x run-lisp (see Running an External Lisp).

您可以M-x comint-run使用未修改的 Comint 模式在子进程中执行您选择的任何程序,而无需 Shell 模式的专门化。要将参数传递给程序,请使用 C-u M-x comint-run.

You can use M-x comint-run to execute any program of your choice in a subprocess using unmodified Comint mode—without the specializations of Shell mode. To pass arguments to the program, use C-u M-x comint-run.


39.4 Shell 提示符

39.4 Shell Prompts

提示是程序输出的文本,表明它已准备好接受新的用户输入。通常,Comint 模式(以及 Shell 模式)会根据子进程的输出自动找出缓冲区的哪一部分是提示符。 (具体来说,它假设任何接收到的不以换行符结尾的输出行都是提示。)

A prompt is text output by a program to show that it is ready to accept new user input. Normally, Comint mode (and thus Shell mode) automatically figures out which part of the buffer is a prompt, based on the output of the subprocess. (Specifically, it assumes that any received output line which doesn’t end with a newline is a prompt.)

Comint 模式将缓冲区分为两种类型的字段:输入字段(键入用户输入的位置)和输出字段(其他位置)。提示是输出字段的一部分。大多数 Emacs 运动命令不会跨越字段边界,除非它们在多行上移动。例如,当 point 位于 shell 命令行上的输入字段中时,C-a将 point 放在输入字段的开头、提示符之后。在内部,这些字段是使用fieldtext 属性实现的(请参阅Emacs Lisp 参考手册中的Text Properties)。

Comint mode divides the buffer into two types of fields: input fields (where user input is typed) and output fields (everywhere else). Prompts are part of the output fields. Most Emacs motion commands do not cross field boundaries, unless they move over multiple lines. For instance, when point is in the input field on a shell command line, C-a puts point at the beginning of the input field, after the prompt. Internally, the fields are implemented using the field text property (see Text Properties in the Emacs Lisp Reference Manual).

如果将变量更改comint-use-prompt-regexp为非值nil,则 Comint 模式将使用正则表达式识别提示(请参阅正则表达式的语法)。在Shell模式下,正则表达式由变量 指定shell-prompt-patterncomint-use-prompt-regexp默认值为,因为这种识别提示的方法不可靠,但在异常情况下nil您可能希望将其设置为非值。nil在这种情况下,Emacs 不会将 Comint 缓冲区划分为字段,因此一般运动命令的行为与在没有特殊文本属性的缓冲区中通常的行为相同。但是,您可以使用段落运动命令来方便地导航缓冲区(请参阅段落);在 Shell 模式下,Emacs 使用shell-prompt-pattern作为段落边界。

If you change the variable comint-use-prompt-regexp to a non-nil value, then Comint mode will recognize prompts using a regular expression (see Syntax of Regular Expressions). In Shell mode, the regular expression is specified by the variable shell-prompt-pattern. The default value of comint-use-prompt-regexp is nil, because this method for recognizing prompts is unreliable, but you may want to set it to a non-nil value in unusual circumstances. In that case, Emacs does not divide the Comint buffer into fields, so the general motion commands behave as they normally do in buffers without special text properties. However, you can use the paragraph motion commands to conveniently navigate the buffer (see Paragraphs); in Shell mode, Emacs uses shell-prompt-pattern as paragraph boundaries.


39.5 Shell命令历史

39.5 Shell Command History

Shell 缓冲区支持三种重复早期命令的方法。您可以使用类似于迷你缓冲区历史记录的键;它们的工作方式与迷你缓冲区中的操作非常相似,从先前的命令插入文本,而点始终保留在缓冲区的末尾。您可以在缓冲区中移动到先前输入的原始位置,然后重新提交它们或将它们复制到末尾。或者你可以使用 ''式的历史参考。

Shell buffers support three ways of repeating earlier commands. You can use keys like those used for the minibuffer history; these work much as they do in the minibuffer, inserting text from prior commands while point remains always at the end of the buffer. You can move through the buffer to previous inputs in their original place, then resubmit them or copy them to the end. Or you can use a ‘!’-style history reference.


39.5.1 Shell 历史环

39.5.1 Shell History Ring

M-p
M-p
C-UP
C-UP

获取下一个较早的旧 shell 命令 ( comint-previous-input)。

Fetch the next earlier old shell command (comint-previous-input).

M-n
M-n
C-DOWN
C-DOWN

获取下一个较晚的旧 shell 命令 ( comint-next-input)。

Fetch the next later old shell command (comint-next-input).

M-r
M-r

开始对旧 shell 命令进行增量正则表达式搜索 ( comint-history-isearch-backward-regexp)。

Begin an incremental regexp search of old shell commands (comint-history-isearch-backward-regexp).

C-c C-x
C-c C-x

从历史记录中获取下一个后续命令 ( comint-get-next-from-history)。

Fetch the next subsequent command from the history (comint-get-next-from-history).

C-c .
C-c .

从旧 shell 命令中获取一个参数 ( comint-input-previous-argument)。

Fetch one argument from an old shell command (comint-input-previous-argument).

C-c C-l
C-c C-l

在另一个窗口 ( ) 中显示缓冲区的 shell 命令历史记录comint-dynamic-list-input-ring

Display the buffer’s history of shell commands in another window (comint-dynamic-list-input-ring).

Shell 缓冲区提供先前输入的 shell 命令的历史记录。要重用历史记录中的 shell 命令,请使用编辑命令M-pM-nM-r。它们的工作方式与迷你缓冲区历史命令类似(请参阅迷你缓冲区历史记录),不同之处在于它们在 Shell 缓冲区而不是迷你缓冲区内运行,并且M-r在 Shell 缓冲区中通过 shell 命令历史记录调用增量搜索。

Shell buffers provide a history of previously entered shell commands. To reuse shell commands from the history, use the editing commands M-p, M-n, and M-r. These work similar to the minibuffer history commands (see Minibuffer History), except that they operate within the Shell buffer rather than the minibuffer, and M-r in a Shell buffer invokes incremental search through shell command history.

M-p将较早的 shell 命令提取到 shell 缓冲区的末尾。连续使用会M-p连续获取较早的 shell 命令,每个命令都会替换已经作为潜在 shell 输入存在的任何文本。 M-n执行类似的操作,只是它会从缓冲区中依次找到更新的 shell 命令。 工作方式类似于、以及 。 C-UPM-pC-DOWNM-n

M-p fetches an earlier shell command to the end of the shell buffer. Successive use of M-p fetches successively earlier shell commands, each replacing any text that was already present as potential shell input. M-n does likewise except that it finds successively more recent shell commands from the buffer. C-UP works like M-p, and C-DOWN like M-n.

历史搜索命令M-r开始对以前的 shell 命令进行增量正则表达式搜索。输入后M-r,开始输入所需的字符串或正则表达式;最后匹配的 shell 命令将显示在当前行中。增量搜索命令具有其通常的效果,例如, C-s向前C-r和向后搜索下一个匹配项(请参阅增量搜索)。当您找到所需的输入时,键入 RET以终止搜索。这会将输入放入命令行中。当您转到历史记录环的开头或结尾时,您在导航历史列表之前编写的任何部分输入都会恢复。

The history search command M-r begins an incremental regular expression search of previous shell commands. After typing M-r, start typing the desired string or regular expression; the last matching shell command will be displayed in the current line. Incremental search commands have their usual effects—for instance, C-s and C-r search forward and backward for the next match (see Incremental Search). When you find the desired input, type RET to terminate the search. This puts the input in the command line. Any partial input you were composing before navigating the history list is restored when you go to the beginning or end of the history ring.

通常,重新执行先前按顺序执行的多个连续 shell 命令很有用。为此,首先查找并重新执行序列的第一个命令。然后输入C-c C-x;这将获取以下命令——您刚刚重复的命令后面的命令。然后键入RET以重新执行此命令。您可以通过反复键入来重新执行多个连续的命令。 C-c C-x RET

Often it is useful to reexecute several successive shell commands that were previously executed in sequence. To do this, first find and reexecute the first command of the sequence. Then type C-c C-x; that will fetch the following command—the one that follows the command you just repeated. Then type RET to reexecute this command. You can reexecute several successive commands by typing C-c C-x RET over and over.

命令C-c .( comint-insert-previous-argument) 从前一个命令复制单个参数,就像 ESC .Bash 和 中的那样zsh。最简单的用法是复制上一个 shell 命令的最后一个参数。使用前缀参数n时,它会复制第n 个参数。重复早期 shell 命令的副本,始终使用相同的nC-c .值 (重复命令时不要给出前缀参数)。 C-c .

The command C-c . (comint-insert-previous-argument) copies an individual argument from a previous command, like ESC . in Bash and zsh. The simplest use copies the last argument from the previous shell command. With a prefix argument n, it copies the nth argument instead. Repeating C-c . copies from an earlier shell commands, always using the same value of n (don’t give a prefix argument when you repeat the C-c . command).

如果设置comint-insert-previous-argument-from-end为非值nilC-c .则将复制从最后一个参数算起的第 n 个参数;这ESC .zsh.

If you set comint-insert-previous-argument-from-end to a non-nil value, C-c . will instead copy the nth argument counting from the last one; this emulates ESC . in zsh.

这些命令从特殊的历史列表中获取先前 shell 命令的文本,而不是从 shell 缓冲区本身。因此,编辑 shell 缓冲区,甚至删除其中的大部分,不会影响这些命令访问的历史记录。

These commands get the text of previous shell commands from a special history list, not from the shell buffer itself. Thus, editing the shell buffer, or even killing large parts of it, does not affect the history that these commands access.

某些 shell 将其命令历史记录存储在文件中,以便您可以引用以前的 shell 会话中的命令。 Emacs 读取您选择的 shell 的命令历史记录文件,以初始化其自己的命令历史记录。文件名是〜/.bash_history对于bash, ~/.sh_历史记录对于 ksh,以及~/.历史对于其他贝壳。

Some shells store their command histories in files so that you can refer to commands from previous shell sessions. Emacs reads the command history file for your chosen shell, to initialize its own command history. The file name is ~/.bash_history for bash, ~/.sh_history for ksh, and ~/.history for other shells.

如果您在远程主机上运行 shell,则此设置可能会被变量 覆盖tramp-histfile-override。建议将此变量设置为nil

If you run the shell on a remote host, this setting might be overwritten by the variable tramp-histfile-override. It is recommended to set this variable to nil.


39.5.2 Shell 历史记录复制

39.5.2 Shell History Copying

C-c C-p
C-c C-p

将点移至上一个提示 ( comint-previous-prompt)。

Move point to the previous prompt (comint-previous-prompt).

C-c C-n
C-c C-n

将光标移至以下提示(comint-next-prompt)处。

Move point to the following prompt (comint-next-prompt).

C-c RET
C-c RET

复制该点的输入命令,并将副本插入到缓冲区的末尾 ( comint-copy-old-input)。如果您将点移回到上一个命令,这非常有用。复制命令后,您可以使用 提交副本作为输入RET。如果您愿意,您可以在重新提交之前对其进行编辑。如果在输出行上使用此命令,则会将该行复制到缓冲区的末尾。

Copy the input command at point, inserting the copy at the end of the buffer (comint-copy-old-input). This is useful if you move point back to a previous command. After you copy the command, you can submit the copy as input with RET. If you wish, you can edit the copy before resubmitting it. If you use this command on an output line, it copies that line to the end of the buffer.

mouse-2
mouse-2

如果comint-use-prompt-regexpnil(默认),则复制您单击的旧输入命令,并将副本插入到缓冲区末尾 ( comint-insert-input)。如果 comint-use-prompt-regexp是非nil,或者如果点击不是在旧输入上,则像往常一样猛拉。

If comint-use-prompt-regexp is nil (the default), copy the old input command that you click on, inserting the copy at the end of the buffer (comint-insert-input). If comint-use-prompt-regexp is non-nil, or if the click is not over old input, just yank as usual.

移动到先前的输入,然后使用或复制它,会产生相同的结果(相同的缓冲区内容),您可以通过使用足够的时间从历史列表中获取先前的输入来获得该结果。但是,从缓冲区复制文本,如果您在发送后编辑缓冲区中的输入文本,则该文本可能与历史列表中的文本不同。 C-c RETmouse-2M-pC-c RET

Moving to a previous input and then copying it with C-c RET or mouse-2 produces the same results—the same buffer contents—that you would get by using M-p enough times to fetch that previous input from the history list. However, C-c RET copies the text from the buffer, which can be different from what is in the history list if you edit the input text in the buffer after it has been sent.


39.5.3 Shell 历史参考

39.5.3 Shell History References

各种 shell(包括 csh 和 bash)支持以 ' 开头的历史记录引用' 和 '^'。 Shell 模式可以识别这些结构,并且可以为您执行历史替换。

Various shells, including csh and bash, support history references that begin with ‘!’ and ‘^’. Shell mode recognizes these constructs, and can perform the history substitution for you.

如果插入历史引用并键入TAB,则会在输入历史中搜索匹配的命令,如有必要,执行替换,并将结果放置在缓冲区中代替历史引用。例如,您可以获取以 ' 开头的最新命令MV' 和。如果需要,您可以编辑该命令,然后通过键入 将该命令重新提交到 shell 。 ! m v TABRET

If you insert a history reference and type TAB, this searches the input history for a matching command, performs substitution if necessary, and places the result in the buffer in place of the history reference. For example, you can fetch the most recent command beginning with ‘mv’ with ! m v TAB. You can edit the command if you wish, and then resubmit the command to the shell by typing RET.

当您将历史引用发送到 shell 时,Shell 模式可以选择扩展缓冲区中的历史引用。要请求此操作,请将变量设置 comint-input-autoexpandinput。您可以 通过绑定命令来SPC执行历史扩展。请参阅交互更改键绑定SPCcomint-magic-space

Shell mode can optionally expand history references in the buffer when you send them to the shell. To request this, set the variable comint-input-autoexpand to input. You can make SPC perform history expansion by binding SPC to the command comint-magic-space. See Changing Key Bindings Interactively.

Shell 模式会在遵循提示时识别历史引用。请参阅Shell 提示符,了解 Shell 模式如何识别提示符。

Shell mode recognizes history references when they follow a prompt. See Shell Prompts, for how Shell mode recognizes prompts.


39.6 目录跟踪

39.6 Directory Tracking

Shell 模式跟踪 '光盘','推送' 和 '波普德' 给子 shell 的命令,以保持 Shell 缓冲区的默认目录(请参阅文件名)与 shell 的工作目录相同。它通过检查您发送的输入行来识别这些命令。

Shell mode keeps track of ‘cd’, ‘pushd’ and ‘popd’ commands given to the subshell, in order to keep the Shell buffer’s default directory (see File Names) the same as the shell’s working directory. It recognizes these commands by examining lines of input that you send.

如果您对这些命令使用别名,则可以通过将变量 shell-pushd-regexpshell-popd-regexp和 设置shell-cd-regexp为适当的正则表达式(请参阅正则表达式的语法)来告诉 Emacs 也识别它们。例如,如果shell-pushd-regexp匹配 shell 命令行的开头,则该行被视为 pushd命令。这些命令仅在 shell 命令行的开头被识别。

If you use aliases for these commands, you can tell Emacs to recognize them also, by setting the variables shell-pushd-regexp, shell-popd-regexp, and shell-cd-regexp to the appropriate regular expressions (see Syntax of Regular Expressions). For example, if shell-pushd-regexp matches the beginning of a shell command line, that line is regarded as a pushd command. These commands are recognized only at the beginning of a shell command line.

如果 Emacs 对子 shell 工作目录中的更改感到困惑,请输入M-x dirs。此命令向 shell 询问其工作目录并相应地更新默认目录。它适用于支持最常见命令语法的 shell,但可能不适用于不常见的 shell。

If Emacs gets confused about changes in the working directory of the subshell, type M-x dirs. This command asks the shell for its working directory and updates the default directory accordingly. It works for shells that support the most common command syntax, but may not work for unusual shells.

您还可以使用 Dirtrack 模式,这是一种本地缓冲区次要模式,它实现了跟踪 shell 工作目录的替代方法。要使用此方法,您的 shell 提示符必须始终包含工作目录,并且您必须提供正则表达式来识别提示符的哪一部分包含工作目录;有关详细信息,请参阅变量的文档 dirtrack-list。要使用 Dirtrack 模式,请M-x dirtrack-mode在 Shell 缓冲区中键入,或添加dirtrack-modeshell-mode-hook(请参阅Hooks)。

You can also use Dirtrack mode, a buffer-local minor mode that implements an alternative method of tracking the shell’s working directory. To use this method, your shell prompt must contain the working directory at all times, and you must supply a regular expression for recognizing which part of the prompt contains the working directory; see the documentation of the variable dirtrack-list for details. To use Dirtrack mode, type M-x dirtrack-mode in the Shell buffer, or add dirtrack-mode to shell-mode-hook (see Hooks).


39.7 Shell模式选项

39.7 Shell Mode Options

如果变量comint-scroll-to-bottom-on-input为非nil,则插入和复制命令会在插入之前将选定的窗口滚动到底部。默认为nil.

If the variable comint-scroll-to-bottom-on-input is non-nil, insertion and yank commands scroll the selected window to the bottom before inserting. The default is nil.

如果comint-scroll-show-maximum-output是 非- nil,则当点位于末尾时输出到达会尝试将最后一行文本滚动到窗口的底行,显示尽可能多的有用文本。 (这模仿了大多数终端的滚动行为。)默认值为t

If comint-scroll-show-maximum-output is non-nil, then arrival of output when point is at the end tries to scroll the last line of text to the bottom line of the window, showing as much useful text as possible. (This mimics the scrolling behavior of most terminals.) The default is t.

通过设置comint-move-point-for-output,您可以选择在输出到达时让点跳转到缓冲区的末尾 - 无论缓冲区点之前位于何处。如果值为 this,则点在所选窗口内跳转。如果值为 all,则在显示 Comint 缓冲区的每个窗口中进行点跳转。如果值为other,则在显示当前缓冲区的所有未选定窗口中进行点跳转。默认值为nil,表示点不跳转到末尾。

By setting comint-move-point-for-output, you can opt for having point jump to the end of the buffer whenever output arrives—no matter where in the buffer point was before. If the value is this, point jumps in the selected window. If the value is all, point jumps in each window that shows the Comint buffer. If the value is other, point jumps in all nonselected windows that show the current buffer. The default value is nil, which means point does not jump to the end.

如果设置comint-prompt-read-only,Comint 缓冲区中的提示是只读的。

If you set comint-prompt-read-only, the prompts in the Comint buffer are read-only.

该变量comint-input-ignoredups控制是否将连续的相同输入存储在输入历史记录中。非nil 值意味着省略与先前输入相同的输入。默认值为nil,这意味着存储每个输入,即使它与前一个输入相同。

The variable comint-input-ignoredups controls whether successive identical inputs are stored in the input history. A non-nil value means to omit an input that is the same as the previous input. The default is nil, which means to store each input even if it is equal to the previous input.

三个变量自定义文件名完成。该变量 comint-completion-addsuffix控制完成是否插入空格或斜杠以指示完全完成的文件或目录名(非nil表示插入空格或斜杠)。 comint-completion-recexact,如果非nil,则指示TAB 在通常的 Emacs 完成算法甚至无法添加单个字符的情况下选择最短的可能完成。 comint-completion-autolist,如果非nil,则表示只要完成不准确,就列出所有可能的完成。

Three variables customize file name completion. The variable comint-completion-addsuffix controls whether completion inserts a space or a slash to indicate a fully completed file or directory name (non-nil means do insert a space or slash). comint-completion-recexact, if non-nil, directs TAB to choose the shortest possible completion if the usual Emacs completion algorithm cannot add even a single character. comint-completion-autolist, if non-nil, says to list all the possible completions whenever completion is not exact.

命令完成通常只考虑可执行文件。如果您设置shell-completion-execonlynil,它也会考虑不可执行的文件。

Command completion normally considers only executable files. If you set shell-completion-execonly to nil, it considers nonexecutable files as well.

该变量shell-completion-fignore指定在 Shell 模式完成中要忽略的文件扩展名列表。默认设置是nil,但有些用户更喜欢("~" "#" "%")忽略以 ' 结尾的文件名','#' 或者 '%'。其他相关的 Comint 模式则使用该变量comint-completion-fignore

The variable shell-completion-fignore specifies a list of file name extensions to ignore in Shell mode completion. The default setting is nil, but some users prefer ("~" "#" "%") to ignore file names ending in ‘~’, ‘#’ or ‘%’. Other related Comint modes use the variable comint-completion-fignore instead.

shell 命令完成的一些实现细节也可以在该函数的 lisp 文档中找到shell-dynamic-complete-command

Some implementation details of the shell command completion may also be found in the lisp documentation of the shell-dynamic-complete-command function.

您可以配置'的行为推送'。变量控制是否 '推送'表现得像'光盘' 如果没有给出参数 ( shell-pushd-tohome),则弹出而不是使用数字参数进行旋转 ( shell-pushd-dextract),并且仅将目录添加到目录堆栈中(如果目录尚不存在的话) ( shell-pushd-dunique)。当然,您选择的值应该与底层 shell 匹配。

You can configure the behavior of ‘pushd’. Variables control whether ‘pushd’ behaves like ‘cd’ if no argument is given (shell-pushd-tohome), pop rather than rotate with a numeric argument (shell-pushd-dextract), and only add directories to the directory stack if they are not already on it (shell-pushd-dunique). The values you choose should match the underlying shell, of course.

Comint 模式将TERM环境变量设置为安全的默认值,但该值会禁用一些有用的功能。例如,在用于TERM确定是否支持颜色的应用程序中禁用颜色。因此,Emacs 提供了一个选项 comint-terminfo-terminal,让您选择具有更高级功能的终端,如系统 terminfo 数据库中所定义。TERM只要 system-uses-terminfo非, Emacs 就会使用此选项作为值nil

Comint mode sets the TERM environment variable to a safe default value, but this value disables some useful features. For example, color is disabled in applications that use TERM to determine if color is supported. Therefore, Emacs provides an option comint-terminfo-terminal to let you choose a terminal with more advanced features, as defined in your system’s terminfo database. Emacs will use this option as the value for TERM so long as system-uses-terminfo is non-nil.

comint-terminfo-terminal和都system-uses-terminfo 可以声明为连接本地变量,以调整这些选项以匹配远程系统的期望(请参阅每连接本地变量)。

Both comint-terminfo-terminal and system-uses-terminfo can be declared as connection-local variables to adjust these options to match what a remote system expects (see Per-Connection Local Variables).


39.8 Emacs 终端仿真器

39.8 Emacs Terminal Emulator

要在文本终端模拟器中运行子 shell,请使用M-x term.这将创建(或重用)一个名为的缓冲区*终端*,并运行一个子 shell,输入来自键盘,输出发送到该缓冲区。

To run a subshell in a text terminal emulator, use M-x term. This creates (or reuses) a buffer named *terminal*, and runs a subshell with input coming from your keyboard, and output going to that buffer.

终端仿真器使用Term模式,有两种输入模式。在行模式下 ,Term 的行为基本上类似于 Shell 模式(请参阅Shell 模式)。在字符模式下,每个字符都直接发送到子shell,作为终端输入;唯一的例外是终端转义字符,默认情况下是C-c(请参阅术语模式)。您的输入的任何回显都是子 shell 的责任;子 shell 的任何终端输出都会进入缓冲区,前进点。

The terminal emulator uses Term mode, which has two input modes. In line mode, Term basically acts like Shell mode (see Shell Mode). In char mode, each character is sent directly to the subshell, as terminal input; the sole exception is the terminal escape character, which by default is C-c (see Term Mode). Any echoing of your input is the responsibility of the subshell; any terminal output from the subshell goes into the buffer, advancing point.

某些程序(例如 Emacs 本身)需要详细控制终端屏幕的外观。他们通过发出特殊的控制代码来做到这一点。术语模式可识别并处理 ANSI 标准 VT100 样式的转义序列,大多数现代终端都接受这些序列,包括xterm. (因此,您实际上可以在 Emacs Term 窗口中运行 Emacs。)

Some programs (such as Emacs itself) need to control the appearance of the terminal screen in detail. They do this by emitting special control codes. Term mode recognizes and handles ANSI-standard VT100-style escape sequences, which are accepted by most modern terminals, including xterm. (Hence, you can actually run Emacs inside an Emacs Term window.)

脸部term指定终端模拟器中文本的默认外观(默认外观与脸部相同 default)。当终端控制代码用于更改文本的外观时,它们在终端仿真器中由面term-color-blackterm-color-redterm-color-greenterm-color-yellow term-color-blueterm-color-magentaterm-color-cyanterm-color-whiteterm-color-underline、 和表示term-color-bold。请参阅文本面孔

The term face specifies the default appearance of text in the terminal emulator (the default is the same appearance as the default face). When terminal control codes are used to change the appearance of text, these are represented in the terminal emulator by the faces term-color-black, term-color-red, term-color-green, term-color-yellow term-color-blue, term-color-magenta, term-color-cyan, term-color-white, term-color-underline, and term-color-bold. See Text Faces.

您还可以使用 Term 模式与连接到串行端口的设备进行通信。请参阅串行终端

You can also use Term mode to communicate with a device connected to a serial port. See Serial Terminal.

用于加载子 shell 的文件名的确定方式与 Shell 模式相同。要制作多个终端模拟器,请重命名缓冲区*终端*使用 来进行不同的操作M-x rename-uniquely,就像使用 Shell 模式一样。

The file name used to load the subshell is determined the same way as for Shell mode. To make multiple terminal emulators, rename the buffer *terminal* to something different using M-x rename-uniquely, just as with Shell mode.

与 Shell 模式不同,Term 模式不会通过检查您的输入来跟踪当前目录。但有些 shell 可以告诉 Term 当前目录是什么。这是bash1.15 及更高版本自动完成的。

Unlike Shell mode, Term mode does not track the current directory by examining your input. But some shells can tell Term what the current directory is. This is done automatically by bash version 1.15 and later.


39.9 期限模式

39.9 Term Mode

要在术语模式下在行模式和字符模式之间切换,请使用以下命令:

To switch between line and char mode in Term mode, use these commands:

C-c C-j
C-c C-j

切换到线路模式 ( term-line-mode)。如果已处于线路模式,则不执行任何操作。

Switch to line mode (term-line-mode). Do nothing if already in line mode.

C-c C-k
C-c C-k

切换到字符模式 ( term-char-mode)。如果已处于字符模式,则不执行任何操作。

Switch to char mode (term-char-mode). Do nothing if already in char mode.

以下命令仅在字符模式下可用:

The following commands are only available in char mode:

C-c C-c
C-c C-c

C-c向子 shell发送一个文字( term-interrupt-subjob)。

Send a literal C-c to the sub-shell (term-interrupt-subjob).

C-c char
C-c char

这相当于普通的 Emacs。例如,调用 的全局绑定,通常是 'C-x charC-c oC-x o其他窗口'。

This is equivalent to C-x char in normal Emacs. For example, C-c o invokes the global binding of C-x o, which is normally ‘other-window’.

术语模式具有一次一页的功能。启用后,它会使输出在每个屏幕结束时暂停:

Term mode has a page-at-a-time feature. When enabled, it makes output pause at the end of each screenful:

C-c C-q
C-c C-q

切换一次一页功能 ( term-pager-toggle)。该命令适用于行模式和字符模式。启用该功能后,模式行会显示单词 '',每次 Term 收到超过一屏的输出时,它都会暂停并显示 '**更多的**' 在模式行中。键入SPC以显示下一屏输出,或?查看其他选项。界面与more程序类似。

Toggle the page-at-a-time feature (term-pager-toggle). This command works in both line and char modes. When the feature is enabled, the mode-line displays the word ‘page’, and each time Term receives more than a screenful of output, it pauses and displays ‘**MORE**’ in the mode-line. Type SPC to display the next screenful of output, or ? to see your other options. The interface is similar to the more program.


39.10 远程主机外壳

39.10 Remote Host Shell

ssh您可以从术语窗口 使用常规终端(例如命令)中的任何命令登录到远程计算机。

You can login to a remote computer, using whatever commands you would from a regular terminal (e.g., the ssh command), from a Term window.

要求您输入密码的程序通常会抑制密码的回显,因此密码不会显示在缓冲区中。如果缓冲区处于字符模式,则会发生这种情况,就像您使用真实终端一样。如果处于线路模式,密码暂时可见,但当您按回车键时密码将被删除。 (这是自动发生的;没有特殊的密码处理。)

A program that asks you for a password will normally suppress echoing of the password, so the password will not show up in the buffer. This will happen just as if you were using a real terminal, if the buffer is in char mode. If it is in line mode, the password is temporarily visible, but will be erased when you hit return. (This happens automatically; there is no special password processing.)

TERM当您登录到不同的计算机时,您需要通过在远程登录命令的环境中设置环境变量来指定您所使用的终端类型。 (如果您使用 bash,则可以通过在远程登录命令之前编写变量赋值来实现,无需使用逗号分隔。) 终端类型 '安西' 或者 'VT100' 将适用于大多数系统。

When you log in to a different machine, you need to specify the type of terminal you’re using, by setting the TERM environment variable in the environment for the remote login command. (If you use bash, you do that by writing the variable assignment before the remote login command, without a separating comma.) Terminal types ‘ansi’ or ‘vt100’ will work on most systems.


39.11 串行终端

39.11 Serial Terminal

如果您有一个设备连接到计算机的串行端口,则可以通过键入 来与其通信M-x serial-term。此命令询问串行端口名称和速度,并切换到新的术语模式缓冲区。 Emacs 通过此缓冲区与串行设备进行通信,就像在普通 Term 模式下与终端进行通信一样。

If you have a device connected to a serial port of your computer, you can communicate with it by typing M-x serial-term. This command asks for a serial port name and speed, and switches to a new Term mode buffer. Emacs communicates with the serial device through this buffer just like it does with a terminal in ordinary Term mode.

串行端口的速度以每秒位数来衡量。最常见的速度是每秒 9600 位。您可以通过单击模式线以交互方式更改速度。

The speed of the serial port is measured in bits per second. The most common speed is 9600 bits per second. You can change the speed interactively by clicking on the mode line.

通过单击“可以对串行端口进行更多配置”8N1' 在模式行中。默认情况下,串行端口配置为“8N1',这意味着每个字节由 8 个数据位、无奇偶校验位和 1 个停止位组成。

A serial port can be configured even more by clicking on ‘8N1’ in the mode line. By default, a serial port is configured as ‘8N1’, which means that each byte consists of 8 data bits, No parity check bit, and 1 stopbit.

如果速度或配置错误,您将无法与设备通信,并且可能只会在窗口中看到垃圾输出。

If the speed or the configuration is wrong, you cannot communicate with your device and will probably only see garbage output in the window.


40 使用 Emacs 作为服务器

40 Using Emacs as a Server

各种程序可以调用您选择的编辑器来编辑特定的文本片段。例如,版本控制程序调用编辑器来输入版本控制日志(请参阅版本控制),并且 Unixmail实用程序调用编辑器来输入要发送的消息。按照惯例,您选择的编辑器是由环境变量指定的EDITOR。如果您设置 EDITOR为 'emacs',Emacs 将会被调用,但是以一种不方便的方式——通过启动一个新的 Emacs 进程。这很不方便,因为新的 Emacs 进程不与任何现有的 Emacs 进程共享缓冲区、命令历史记录或其他类型的信息。

Various programs can invoke your choice of editor to edit a particular piece of text. For instance, version control programs invoke an editor to enter version control logs (see Version Control), and the Unix mail utility invokes an editor to enter a message to send. By convention, your choice of editor is specified by the environment variable EDITOR. If you set EDITOR to ‘emacs’, Emacs would be invoked, but in an inconvenient way—by starting a new Emacs process. This is inconvenient because the new Emacs process doesn’t share buffers, a command history, or other kinds of information with any existing Emacs process.

您可以通过将 Emacs 设置为编辑服务器来解决此问题,以便它“侦听”外部编辑请求并采取相应的操作。有多种方法可以启动 Emacs 服务器:

You can solve this problem by setting up Emacs as an edit server, so that it “listens” for external edit requests and acts accordingly. There are various ways to start an Emacs server:

  • server-start在现有 Emacs 进程中 运行该命令:键入M-x server-start,或将表达式 (server-start)放入 init 文件中(请参阅Emacs 初始化文件)。现有的Emacs进程是服务器;当您退出 Emacs 时,服务器会随着 Emacs 进程一起终止。
  • Run the command server-start in an existing Emacs process: either type M-x server-start, or put the expression (server-start) in your init file (see The Emacs Initialization File). The existing Emacs process is the server; when you exit Emacs, the server dies with the Emacs process.
  • 使用以下之一 将 Emacs 作为守护进程运行:--守护进程' 命令行选项。请参阅初始选项。当 Emacs 以这种方式启动时,它会server-start在初始化后调用,并且不会打开初始框架。然后它等待来自客户端的编辑请求。
  • Run Emacs as a daemon, using one of the ‘--daemon’ command-line options. See Initial Options. When Emacs is started this way, it calls server-start after initialization and does not open an initial frame. It then waits for edit requests from clients.
  • emacsclient使用 '运行命令--备用编辑器=“”' 命令行选项。仅当没有 Emacs 守护进程正在运行时,这才会启动 Emacs 守护进程。
  • Run the command emacsclient with the ‘--alternate-editor=""’ command-line option. This starts an Emacs daemon only if no Emacs daemon is already running.
  • 如果您的操作系统使用管理启动,则当您使用提供的systemd 单元文件systemd登录时,可以自动以守护程序模式启动 Emacs 。要激活此功能:
    systemctl --用户启用 emacs
    

    (如果您的 Emacs 安装在非标准位置,您可能需要复制emacs.service文件到标准目录,例如〜/.config/systemd/用户/.)

  • If your operating system uses systemd to manage startup, you can automatically start Emacs in daemon mode when you login using the supplied systemd unit file. To activate this:
    systemctl --user enable emacs
    

    (If your Emacs was installed into a non-standard location, you may need to copy the emacs.service file to a standard directory such as ~/.config/systemd/user/.)

  • 当指定套接字上发生连接事件时,外部进程可以调用 Emacs 服务器,并将套接字传递给新的 Emacs 服务器进程。一个例子是套接字功能systemdsystemd服务创建一个套接字并侦听其上的连接;当emacsclient第一次连接到它时,systemd可以启动 Emacs 服务器并将套接字移交给它来服务emacsclient 连接。使用此功能的设置可以是:

    〜/.config/systemd/user/emacs.socket:

    [插座]
    ListenStream=/path/to/.emacs.socket
    目录模式=0700
    
    [安装]
    WantedBy=sockets.target
    

    (这emacs.service还必须安装上述文件。)

    ListenStream路径将是 Emacs 侦听来自 的连接的路径emacsclient;这是您选择的文件。

  • An external process can invoke the Emacs server when a connection event occurs upon a specified socket and pass the socket to the new Emacs server process. An instance of this is the socket functionality of systemd: the systemd service creates a socket and listens for connections on it; when emacsclient connects to it for the first time, systemd can launch the Emacs server and hand over the socket to it for servicing emacsclient connections. A setup to use this functionality could be:

    ~/.config/systemd/user/emacs.socket:

    [Socket]
    ListenStream=/path/to/.emacs.socket
    DirectoryMode=0700
    
    [Install]
    WantedBy=sockets.target
    

    (The emacs.service file described above must also be installed.)

    The ListenStream path will be the path that Emacs listens for connections from emacsclient; this is a file of your choice.

一旦 Emacs 服务器启动,您可以使用 shell 命令调用emacsclient来连接到 Emacs 进程并告诉它访问文件。然后您可以将EDITOR 环境变量设置为'emacs客户端',这样外部程序就会使用现有的Emacs进程进行编辑。23

Once an Emacs server is started, you can use a shell command called emacsclient to connect to the Emacs process and tell it to visit a file. You can then set the EDITOR environment variable to ‘emacsclient’, so that external programs will use the existing Emacs process for editing.23

您可以在同一台机器上运行多个 Emacs 服务器,方法是使用变量 为每个服务器指定一个唯一的服务器名称server-name。例如,将服务器名称设置为 'M-x set-variable RET server-name RET "foo" RET'。该emacsclient程序可以通过名称指定服务器,使用 '-s' 或者 '-F' 选项(请参阅emacsclient选项),具体取决于服务器是否使用 TCP 套接字(请参阅TCP Emacs 服务器)。

You can run multiple Emacs servers on the same machine by giving each one a unique server name, using the variable server-name. For example, M-x set-variable RET server-name RET "foo" RET sets the server name to ‘foo’. The emacsclient program can specify a server by name, using the ‘-s’ or the ‘-f’ option (see emacsclient Options), depending on whether or not the server uses a TCP socket (see TCP Emacs server).

如果您想运行多个 Emacs 守护进程(请参阅初始选项),您可以为每个守护进程指定自己的服务器名称,如下所示:

If you want to run multiple Emacs daemons (see Initial Options), you can give each daemon its own server name like this:

  emacs --daemon=foo
  emacs --daemon=foo

当满足某些条件时,可以选择自动停止 Emacs 服务器。为此,请 使用以下参数之一 调用server-stop-automaticallyinit 文件中的函数(请参阅Emacs 初始化文件):

The Emacs server can optionally be stopped automatically when certain conditions are met. To do this, call the function server-stop-automatically in your init file (see The Emacs Initialization File), with one of the following arguments:

  • 使用参数empty,当服务器没有客户端、没有未保存的文件访问缓冲区并且不再有正在运行的进程时,服务器将停止。
  • With the argument empty, the server is stopped when it has no clients, no unsaved file-visiting buffers and no running processes anymore.
  • 使用参数delete-frame,当最后一个客户端框架关闭时,系统会询问您是否必须保存每个未保存的文件访问缓冲区,并且是否可以停止每个未完成的进程,如果是,则停止服务器。
  • With the argument delete-frame, when the last client frame is being closed, you are asked whether each unsaved file-visiting buffer must be saved and each unfinished process can be stopped, and if so, the server is stopped.
  • 使用参数,当使用( )kill-terminal关闭最后一个客户端框架时,系统会询问您是否必须保存每个未保存的文件访问缓冲区,并且是否可以停止每个未完成的进程,如果是,则停止服务器。 C-x C-csave-buffers-kill-terminal
  • With the argument kill-terminal, when the last client frame is being closed with C-x C-c (save-buffers-kill-terminal), you are asked whether each unsaved file-visiting buffer must be saved and each unfinished process can be stopped, and if so, the server is stopped.

如果您通过唯一的服务器名称定义了服务器,则可以使用该server-eval-at函数从另一个 Emacs 实例连接到该服务器并计算服务器上的 Lisp 表达式。例如,计算' 上的(server-eval-at "foo" '(+ 1 2))表达式(+ 1 2)' 服务器,并返回 3. (如果没有具有该名称的服务器,则会发出错误信号。)目前,此功能主要对开发人员有用。

If you have defined a server by a unique server name, it is possible to connect to the server from another Emacs instance and evaluate Lisp expressions on the server, using the server-eval-at function. For instance, (server-eval-at "foo" '(+ 1 2)) evaluates the expression (+ 1 2) on the ‘foo’ server, and returns 3. (If there is no server with that name, an error is signaled.) Currently, this feature is mainly useful for developers.

如果您的操作系统的桌面环境与 freedesktop.org 兼容 (大多数 GNU/Linux 和其他最新的类 Unix GUI 都是如此),您可以使用 'Emacs(客户端)' 菜单项用于连接到 Emacs 服务器emacsclient。如果守护进程尚未运行,则该守护进程将启动。

If your operating system’s desktop environment is freedesktop.org-compatible (which is true of most GNU/Linux and other recent Unix-like GUIs), you may use the ‘Emacs (Client)’ menu entry to connect to an Emacs server with emacsclient. The daemon starts if not already running.


40.1 TCP Emacs 服务器

40.1 TCP Emacs server

Emacs 服务器通常侦听本地 Unix 域套接字上的连接。有些操作系统,例如MS-Windows,不支持本地套接字;在这种情况下,服务器将改用 TCP 套接字。在某些情况下,即使支持本地套接字,让服务器侦听 TCP 套接字也是有用的,例如,如果您需要从远程计算机联系 Emacs 服务器。您可以设置 server-use-tcp为 non-nil以使 Emacs 侦听 TCP 套接字而不是本地套接字。如果您的操作系统不支持本地套接字,则这是默认设置。

An Emacs server usually listens to connections on a local Unix domain socket. Some operating systems, such as MS-Windows, do not support local sockets; in that case, the server uses TCP sockets instead. In some cases it is useful to have the server listen on a TCP socket even if local sockets are supported, e.g., if you need to contact the Emacs server from a remote machine. You can set server-use-tcp to non-nil to have Emacs listen on a TCP socket instead of a local socket. This is the default if your OS does not support local sockets.

如果 Emacs 服务器设置为使用 TCP,则默认情况下它将侦听 localhost 接口上的随机端口。可以使用变量server-host和将其更改为另一个接口和/或固定端口 server-port

If the Emacs server is set to use TCP, it will by default listen on a random port on the localhost interface. This can be changed to another interface and/or a fixed port using the variables server-host and server-port.

TCP 套接字不受文件系统权限的约束。为了保留对哪些用户可以通过 TCP 套接字与 Emacs 服务器通信的控制,emacsclient程序必须向服务器发送授权密钥。该密钥通常由 Emacs 服务器随机生成。这是推荐的操作模式。

A TCP socket is not subject to file system permissions. To retain some control over which users can talk to an Emacs server over TCP sockets, the emacsclient program must send an authorization key to the server. This key is normally randomly generated by the Emacs server. This is the recommended mode of operation.

如果需要,您可以通过设置变量将授权密钥设置为静态值server-auth-key。密钥必须由 64 个 ASCII 可打印字符组成,空格除外(这意味着来自 '' 到 '',或从十进制代码 33 到 126)。您可以使用它M-x server-generate-key来获取随机密钥。

If needed, you can set the authorization key to a static value by setting the server-auth-key variable. The key must consist of 64 ASCII printable characters except for space (this means characters from ‘!’ to ‘~’, or from decimal code 33 to 126). You can use M-x server-generate-key to get a random key.

当您启动 TCP Emacs 服务器时,Emacs 会创建一个服务器文件 ,其中包含用于emacsclient连接到服务器的 TCP 信息。该变量server-auth-dir指定包含服务器文件的默认目录;默认情况下,这是 〜/.emacs.d/服务器/。在没有具有文件权限的本地套接字的情况下,此目录的权限决定哪些用户可以让其emacsclient进程与 Emacs 服务器通信。如果server-name是绝对文件名,则在该文件名指定的位置创建服务器文件。

When you start a TCP Emacs server, Emacs creates a server file containing the TCP information to be used by emacsclient to connect to the server. The variable server-auth-dir specifies the default directory containing the server file; by default, this is ~/.emacs.d/server/. In the absence of a local socket with file permissions, the permissions of this directory determine which users can have their emacsclient processes talk to the Emacs server. If server-name is an absolute file name, the server file is created where specified by that file name.

要指示emacsclient使用特定服务器文件通过 TCP 连接到服务器,请使用 '-F' 或者 '--服务器文件' 选项,或设置EMACS_SERVER_FILE环境变量(请参阅emacsclient选项)。如果server-auth-dir设置为非标准值,或者server-name设置为绝对文件名,则emacsclient需要服务器文件的绝对文件名,因为默认值server-auth-dir被硬编码 emacsclient为用作解析相对文件名的目录。

To tell emacsclient to connect to the server over TCP with a specific server file, use the ‘-f’ or ‘--server-file’ option, or set the EMACS_SERVER_FILE environment variable (see emacsclient Options). If server-auth-dir is set to a non-standard value, or if server-name is set to an absolute file name, emacsclient needs an absolute file name to the server file, as the default server-auth-dir is hard-coded in emacsclient to be used as the directory for resolving relative filenames.


40.2 调用emacsclient

40.2 Invoking emacsclient

使用该emacsclient程序的最简单方法是运行 shell 命令 'emacs客户端文件',其中file是文件名。它连接到 Emacs 服务器,并告诉 Emacs 进程访问其现有框架之一中的文件- 图形框架或文本终端中的框架(请参阅框架和图形显示)。然后您可以选择该帧开始编辑。

The simplest way to use the emacsclient program is to run the shell command ‘emacsclient file’, where file is a file name. This connects to an Emacs server, and tells that Emacs process to visit file in one of its existing frames—either a graphical frame, or one in a text terminal (see Frames and Graphical Displays). You can then select that frame to begin editing.

如果没有 Emacs 服务器,程序emacsclient将停止并显示错误消息(您可以使用 '--备用编辑器=“”' 选项emacsclient,请参阅emacsclient选项)。如果 Emacs 进程没有现有框架(如果它作为守护进程启动,则可能会发生这种情况(请参阅使用 Emacs 作为服务器)),那么 Emacs 将在您调用的终端上打开一个框架emacsclient

If there is no Emacs server, the emacsclient program halts with an error message (you can prevent this from happening by using the ‘--alternate-editor=""’ option to emacsclient, see emacsclient Options). If the Emacs process has no existing frame—which can happen if it was started as a daemon (see Using Emacs as a Server)—then Emacs opens a frame on the terminal in which you called emacsclient.

您还可以emacsclient使用 ' 强制在图形显示上打开一个新框架-C' 选项,或者在文本终端上使用 '-t' 选项。请参阅emacsclient选项

You can also force emacsclient to open a new frame on a graphical display using the ‘-c’ option, or on a text terminal using the ‘-t’ option. See emacsclient Options.

如果您在单个文本终端上运行,则可以 emacsclient使用以下两种方法之一在 's shell 和 Emacs 服务器之间切换: (i)emacsclient在不同的虚拟终端上运行 Emacs 服务器,并在调用后切换到 Emacs 服务器的虚拟终端emacsclient; (ii) 使用 Shell 模式(请参阅Interactive Subshel​​l)或 Term 模式(请参阅Term Modeemacsclient从 Emacs 服务器本身进行调用;仅阻止 Emacs 下的子 shell,您仍然可以使用 Emacs 编辑文件。 emacsclient

If you are running on a single text terminal, you can switch between emacsclient’s shell and the Emacs server using one of two methods: (i) run the Emacs server and emacsclient on different virtual terminals, and switch to the Emacs server’s virtual terminal after calling emacsclient; or (ii) call emacsclient from within the Emacs server itself, using Shell mode (see Interactive Subshell) or Term mode (see Term Mode); emacsclient blocks only the subshell under Emacs, and you can still use Emacs to edit the file.

当您在 Emacs 服务器中 完成文件编辑时,请在其缓冲区中键入C-x #( )。server-edit这将保存文件并向emacsclient程序发送一条消息,告诉它退出。使用的程序EDITOR通常会等待编辑器(在本例中emacsclient)退出,然后再执行其他操作。

When you finish editing file in the Emacs server, type C-x # (server-edit) in its buffer. This saves the file and sends a message back to the emacsclient program, telling it to exit. Programs that use EDITOR usually wait for the editor—in this case emacsclient—to exit before doing something else.

如果您想放弃编辑,请使用该命令。这会向程序发送回一条消息 ,告诉它以异常退出状态退出,并且不保存任何缓冲区。 M-x server-edit-abortemacsclient

If you want to abandon the edit instead, use the M-x server-edit-abort command. This sends a message back to the emacsclient program, telling it to exit with abnormal exit status, and doesn’t save any buffers.

您还可以emacsclient使用多个文件名参数进行调用:'emacsclient文件1 文件2 ...' 告诉 Emacs 服务器访问file1file2等等。 Emacs 选择访问file1 的缓冲区,并将其他缓冲区隐藏在缓冲区列表的底部(请参阅使用多个缓冲区)。emacsclient一旦所有指定的文件完成(即,一旦您C-x #在每个服务器缓冲区中键入内容), 程序 就会退出。

You can also call emacsclient with multiple file name arguments: ‘emacsclient file1 file2 ...’ tells the Emacs server to visit file1, file2, and so forth. Emacs selects the buffer visiting file1, and buries the other buffers at the bottom of the buffer list (see Using Multiple Buffers). The emacsclient program exits once all the specified files are finished (i.e., once you have typed C-x # in each server buffer).

完成服务器缓冲区也会杀死该缓冲区,除非在要求服务器创建它之前它已经存在于 Emacs 会话中。但是,如果设置server-kill-new-buffersnil,则使用不同的标准:如果文件名与正则表达式匹配,则使用服务器缓冲区完成将杀死它 server-temp-file-regexp。这是为了区分某些临时文件而设置的。

Finishing with a server buffer also kills the buffer, unless it already existed in the Emacs session before the server was asked to create it. However, if you set server-kill-new-buffers to nil, then a different criterion is used: finishing with a server buffer kills it if the file name matches the regular expression server-temp-file-regexp. This is set up to distinguish certain temporary files.

每个文件都会C-x #检查其他待处理的外部请求以编辑各种文件,并选择下一个此类文件。如果您愿意,您可以手动切换到服务器缓冲区;你不必通过 来实现它C-x #。但这是告诉你已经完成的 C-x #方法 。emacsclient

Each C-x # checks for other pending external requests to edit various files, and selects the next such file. You can switch to a server buffer manually if you wish; you don’t have to arrive at it with C-x #. But C-x # is the way to tell emacsclient that you are finished.

如果将变量的值设置server-window为窗口或框架,则C-x #始终在该窗口或该框架中显示下一个服务器缓冲区。

If you set the value of the variable server-window to a window or a frame, C-x # always displays the next server buffer in that window or in that frame.

连接时emacsclient,服务器通常会输出一条消息,说明如何退出客户端框架。如果 server-client-instructions设置为nil,则该消息被禁止。

When emacsclient connects, the server will normally output a message that says how to exit the client frame. If server-client-instructions is set to nil, this message is inhibited.


40.3emacsclient选项

40.3 emacsclient Options

您可以向emacsclient 程序传递一些可选参数,例如:

You can pass some optional arguments to the emacsclient program, such as:

emacsclient -c +12文件1 +4:3文件2
emacsclient -c +12 file1 +4:3 file2

这 '+线' 或者 '+:' 参数指定下一个文件参数的行号或行号和列号。它们的行为类似于 Emacs 本身的命令行参数。请参阅操作参数

The ‘+line’ or ‘+line:column’ arguments specify line numbers, or line and column numbers, for the next file argument. These behave like the command line arguments for Emacs itself. See Action Arguments.

emacsclient下面列出了 所识别的其他可选参数:

The other optional arguments recognized by emacsclient are listed below:

'- 一个命令'
-a command
'--alternate-editor=命令'
--alternate-editor=command

emacsclient指定在无法联系 Emacs时要运行的 shell 命令。这emacsclient在脚本中运行时很有用。该命令可以包含参数,这些参数可以“像这样”引用。目前,不支持转义引号。

作为一个特殊的例外,如果command是空字符串,则以 emacsclient守护进程模式启动 Emacs(如 'emacs——守护进程'),然后再次尝试连接。

环境变量ALTERNATE_EDITOR与 ' 具有相同的效果-A' 选项。如果两者都存在,则后者优先。

Specify a shell command to run if emacsclient fails to contact Emacs. This is useful when running emacsclient in a script. The command may include arguments, which may be quoted "like this". Currently, escaping of quotes is not supported.

As a special exception, if command is the empty string, then emacsclient starts Emacs in daemon mode (as ‘emacs --daemon’) and then tries connecting again.

The environment variable ALTERNATE_EDITOR has the same effect as the ‘-a’ option. If both are present, the latter takes precedence.

'-C'
-c
'--创建框架'
--create-frame

创建一个新的图形客户端框架,而不是使用现有的 Emacs 框架。请参阅下文了解C-x C-c客户端框架中的特殊行为。如果 Emacs 无法创建新的图形框架(例如,如果它无法连接到 X 服务器),它会尝试创建一个文本终端客户端框架,就好像您已经提供了 '-t' 选项代替。

在 MS-Windows 上,单个 Emacs 会话无法在图​​形和文本终端上显示框架,也不能在多个文本终端上显示框架。因此,如果 Emacs 服务器在文本终端上运行,则 '-C' 选项,例如 '-t' 选项,在服务器当前的文本终端中创建一个新框架。请参阅如何在 MS-Windows 上启动 Emacs

如果您在提供 ' 时省略文件名参数-C' 选项,新框架显示*划痕*默认情况下缓冲。您可以使用变量自定义此行为initial-buffer-choice (请参阅输入 Emacs)。

Create a new graphical client frame, instead of using an existing Emacs frame. See below for the special behavior of C-x C-c in a client frame. If Emacs cannot create a new graphical frame (e.g., if it cannot connect to the X server), it tries to create a text terminal client frame, as though you had supplied the ‘-t’ option instead.

On MS-Windows, a single Emacs session cannot display frames on both graphical and text terminals, nor on multiple text terminals. Thus, if the Emacs server is running on a text terminal, the ‘-c’ option, like the ‘-t’ option, creates a new frame in the server’s current text terminal. See How to Start Emacs on MS-Windows.

If you omit a filename argument while supplying the ‘-c’ option, the new frame displays the *scratch* buffer by default. You can customize this behavior with the variable initial-buffer-choice (see Entering Emacs).

'-r'
-r
'--重用框架'
--reuse-frame

如果不存在,则创建一个新的图形客户端框架,否则使用现有的 Emacs 框架。

Create a new graphical client frame if none exists, otherwise use an existing Emacs frame.

'-F阿里斯特'
-F alist
'--frame-parameters=列表'
--frame-parameters=alist

为新创建的图形框架设置参数(请参阅框架参数)。

Set the parameters for a newly-created graphical frame (see Frame Parameters).

'-d显示'
-d display
'--显示=显示'
--display=display

告诉 Emacs 在 X显示器上打开给定的文件 (假设有多个 X 显示器可用)。

Tell Emacs to open the given files on the X display display (assuming there is more than one X display available).

'-e'
-e
'--评估'
--eval

告诉 Emacs 评估一些 Emacs Lisp 代码,而不是访问一些文件。当给出此选项时, 的参数将 emacsclient被解释为要计算的表达式列表,而不是要访问的文件列表。

Tell Emacs to evaluate some Emacs Lisp code, instead of visiting some files. When this option is given, the arguments to emacsclient are interpreted as a list of expressions to evaluate, not as a list of files to visit.

'-f服务器文件'
-f server-file
'--服务器文件=服务器文件'
--server-file=server-file

指定用于通过 TCP 连接到 Emacs 服务器的服务器文件(请参阅TCP Emacs 服务器)。或者,您可以将 EMACS_SERVER_FILE环境变量设置为指向服务器文件。 (命令行选项覆盖环境变量。)

Emacs 服务器通常使用本地套接字来侦听连接,但也支持通过 TCP 的连接。要连接到 TCP Emacs 服务器,emacsclient需要读取服务器文件 包含 Emacs 服务器连接详细信息的。该文件的名称是使用此选项指定的,可以是相对于〜/.emacs.d/服务器或作为绝对文件名。请参阅TCP Emacs 服务器

Specify a server file (see TCP Emacs server) for connecting to an Emacs server via TCP. Alternatively, you can set the EMACS_SERVER_FILE environment variable to point to the server file. (The command-line option overrides the environment variable.)

An Emacs server usually uses a local socket to listen for connections, but also supports connections over TCP. To connect to a TCP Emacs server, emacsclient needs to read a server file containing the connection details of the Emacs server. The name of this file is specified with this option, either as a file name relative to ~/.emacs.d/server or as an absolute file name. See TCP Emacs server.

'-n'
-n
'--无需等待'
--no-wait

emacsclient立即退出,而不是等到所有服务器缓冲区都完成。只要您愿意,您可以在 Emacs 中编辑服务器缓冲区,并且在您输入内容时它们不会C-x #被终止。

Let emacsclient exit immediately, instead of waiting until all server buffers are finished. You can take as long as you like to edit the server buffers within Emacs, and they are not killed when you type C-x # in them.

'-w'
-w
'--超时= N'
--timeout=N

等待 Emacs 响应N秒,然后放弃。如果在此时间内没有响应,emacsclient将显示警告并退出。默认为 '0’,这意味着永远等待。

Wait for a response from Emacs for N seconds before giving up. If there is no response within that time, emacsclient will display a warning and exit. The default is ‘0’, which means to wait forever.

'--parent-id= id'
--parent-id=id

通过 XEmbed 协议,在idemacsclient为 id的父 X 窗口中打开一个框架作为客户端框架。目前,此选项主要对开发人员有用。

Open an emacsclient frame as a client frame in the parent X window with id id, via the XEmbed protocol. Currently, this option is mainly useful for developers.

'-q'
-q
'- 安静的'
--quiet

不要让emacsclient显示有关等待 Emacs 或连接到远程服务器套接字的消息。

Do not let emacsclient display messages about waiting for Emacs or connecting to remote server sockets.

'-u'
-u
'--抑制输出'
--suppress-output

不要让emacsclient显示从服务器返回的结果。主要与 ' 结合使用-e' 当进行的评估是针对副作用而不是结果时。

Do not let emacsclient display results returned from the server. Mostly useful in combination with ‘-e’ when the evaluation performed is for side-effect rather than result.

'-s服务器名称'
-s server-name
'--socket-name=服务器名称'
--socket-name=server-name

连接到名为server-name的 Emacs 服务器。 (MS-Windows 不支持此选项。)服务器名称由server-nameEmacs 服务器上的变量给出。如果省略此选项,则emacsclient连接到默认套接字。如果将server-nameEmacs 服务器设置为绝对文件名,请为此选项指定与server-nameemacsclient相同的绝对文件名,以指示连接到该服务器。如果您将 Emacs 作为守护进程启动(请参阅初始选项)并指定由守护进程启动的服务器的名称, 则需要使用此选项。

或者,您可以将EMACS_SOCKET_NAME环境变量设置为指向服务器套接字。 (命令行选项覆盖环境变量。)

Connect to the Emacs server named server-name. (This option is not supported on MS-Windows.) The server name is given by the variable server-name on the Emacs server. If this option is omitted, emacsclient connects to the default socket. If you set server-name of the Emacs server to an absolute file name, give the same absolute file name as server-name to this option to instruct emacsclient to connect to that server. You need to use this option if you started Emacs as daemon (see Initial Options) and specified the name for the server started by the daemon.

Alternatively, you can set the EMACS_SOCKET_NAME environment variable to point to the server socket. (The command-line option overrides the environment variable.)

'-t'
-t
'--tty'
--tty
'-西北'
-nw

在当前文本终端上创建新的客户端框架,而不是使用现有的 Emacs 框架。这就像'-C' 选项,如上所述,不同之处在于它创建一个文本终端框架(请参阅文本终端)。

在 MS-Windows 上,'-t' 的行为就像 '-C' 如果 Emacs 服务器正在使用图形显示,但如果 Emacs 服务器在文本终端上运行,它将在当前文本终端中创建一个新框架。

Create a new client frame on the current text terminal, instead of using an existing Emacs frame. This behaves just like the ‘-c’ option, described above, except that it creates a text terminal frame (see Text Terminals).

On MS-Windows, ‘-t’ behaves just like ‘-c’ if the Emacs server is using the graphical display, but if the Emacs server is running on a text terminal, it creates a new frame in the current text terminal.

'-T流浪者前缀'
-T tramp-prefix
'--tramp-prefix=流浪前缀'
--tramp-prefix=tramp-prefix

设置要添加到文件名的前缀,以便 Emacs使用 TRAMP(请参阅The Tramp Manual中的The Tramp Manual )定位远程计算机上的文件(请参阅远程文件) 。这在与通过 TCP 使用 Emacs 服务器结合使用时非常有用(请参阅TCP Emacs 服务器)。通过 ssh 转发侦听端口并使 服务器文件在远程计算机上可用,远程计算机上的程序可以用作和类似环境变量的值 ,但不是与远程计算机上的 Emacs 服务器通信,文件将在本地 Emacs 会话中使用 TRAMP 进行访问。 emacsclientEDITOR

设置环境变量EMACSCLIENT_TRAMP与使用 ' 具有相同的效果-T' 选项。如果两者都指定,则命令行选项优先。

例如,假设有两个主机,'当地的' 和 '偏僻的',并且本地 Emacs 侦听 tcp 端口 12345。进一步假设 /家位于共享文件系统上,因此服务器文件 〜/.emacs.d/服务器/服务器在两台主机上均可读取。

本地$ ssh -R12345:localhost:12345 远程
远程$导出编辑器=“emacsclient \”
        --服务器文件=服务器\
        --tramp=/ssh:远程:"
remote$ $EDITOR /tmp/foo.txt #应该在本地 emacs 中打开。

Set the prefix to add to filenames for Emacs to locate files on remote machines (see Remote Files) using TRAMP (see The Tramp Manual in The Tramp Manual). This is mostly useful in combination with using the Emacs server over TCP (see TCP Emacs server). By ssh-forwarding the listening port and making the server-file available on a remote machine, programs on the remote machine can use emacsclient as the value for the EDITOR and similar environment variables, but instead of talking to an Emacs server on the remote machine, the files will be visited in the local Emacs session using TRAMP.

Setting the environment variable EMACSCLIENT_TRAMP has the same effect as using the ‘-T’ option. If both are specified, the command-line option takes precedence.

For example, assume two hosts, ‘local’ and ‘remote’, and that the local Emacs listens on tcp port 12345. Assume further that /home is on a shared file system, so that the server file ~/.emacs.d/server/server is readable on both hosts.

local$ ssh -R12345:localhost:12345 remote
remote$ export EDITOR="emacsclient \
        --server-file=server \
        --tramp=/ssh:remote:"
remote$ $EDITOR /tmp/foo.txt #Should open in local emacs.

由 ' 创建的新图形或文本终端框架-C' 或者 '-t' 选项被视为客户端框架。您从客户端框架创建的任何新框架也被视为客户端框架。如果您在客户端框架中键入C-x C-c( save-buffers-kill-terminal),该命令不会像通常那样终止 Emacs 会话(请参阅退出 Emacs)。相反,Emacs 会删除客户端框架;此外,如果客户端框架等待emacsclient 重新获得控制权(即,如果您没有提供 '-n' 选项),Emacs 会删除同一客户端的所有其他帧,并将客户端的服务器缓冲区标记为已完成,就像您已输入 C-x #所有内容一样。如果删除客户端框架后没有剩余框架,则 Emacs 会话将退出。

The new graphical or text terminal frames created by the ‘-c’ or ‘-t’ options are considered client frames. Any new frame that you create from a client frame is also considered a client frame. If you type C-x C-c (save-buffers-kill-terminal) in a client frame, that command does not kill the Emacs session as it normally does (see Exiting Emacs). Instead, Emacs deletes the client frame; furthermore, if the client frame has an emacsclient waiting to regain control (i.e., if you did not supply the ‘-n’ option), Emacs deletes all other frames of the same client, and marks the client’s server buffers as finished, as though you had typed C-x # in all of them. If it so happens that there are no remaining frames after the client frame(s) are deleted, the Emacs session exits.

作为例外,当 Emacs 作为守护进程启动时,所有帧都被视为客户端帧,并且C-x C-c永远不会终止 Emacs。要终止守护进程会话,请键入M-x kill-emacs

As an exception, when Emacs is started as a daemon, all frames are considered client frames, and C-x C-c never kills Emacs. To kill a daemon session, type M-x kill-emacs.

请注意,'-t' 和 '-n'选项是矛盾的:'-t' 表示控制当前文本终端以创建新的客户端框架,而 '-n' 表示不要控制文本终端。如果您提供这两个选项,Emacs 将访问现有框架中的指定文件而不是新的客户端框架,从而消除 '-t'。

Note that the ‘-t’ and ‘-n’ options are contradictory: ‘-t’ says to take control of the current text terminal to create a new client frame, while ‘-n’ says not to take control of the text terminal. If you supply both options, Emacs visits the specified files(s) in an existing frame rather than a new client frame, negating the effect of ‘-t’.


41 打印硬拷贝

41 Printing Hard Copies

Emacs 提供了打印整个缓冲区或部分缓冲区硬拷贝的命令。您可以直接调用打印命令,如下所述,或使用 '文件' 菜单栏上的菜单。

Emacs provides commands for printing hardcopies of either an entire buffer or part of one. You can invoke the printing commands directly, as detailed below, or using the ‘File’ menu on the menu bar.

除了本节中描述的命令之外,您还可以从 Dired 打印硬拷贝(请参阅“文件操作”)和日记(请参阅“显示日记”)。您还可以使用命令将 Emacs 缓冲区“打印”为 HTML M-x htmlfontify-buffer,该命令将当前缓冲区转换为 HTML 文件,用基于 CSS 的标记替换 Emacs 界面。此外,Org 模式允许您将 Org 文件打印为多种格式,例如 PDF(请参阅Org 模式)。

Aside from the commands described in this section, you can also print hardcopies from Dired (see Operating on Files) and the diary (see Displaying the Diary). You can also “print” an Emacs buffer to HTML with the command M-x htmlfontify-buffer, which converts the current buffer to a HTML file, replacing Emacs faces with CSS-based markup. Furthermore, Org mode allows you to print Org files to a variety of formats, such as PDF (see Org Mode).

M-x print-buffer
M-x print-buffer

打印当前缓冲区的硬拷贝,其中页面标题包含文件名和页码。

Print hardcopy of current buffer with page headings containing the file name and page number.

M-x lpr-buffer
M-x lpr-buffer

打印当前缓冲区的硬拷贝,不带页面标题。

Print hardcopy of current buffer without page headings.

M-x print-region
M-x print-region

类似print-buffer,但仅打印当前区域。

Like print-buffer but print only the current region.

M-x lpr-region
M-x lpr-region

类似lpr-buffer,但仅打印当前区域。

Like lpr-buffer but print only the current region.

在大多数操作系统上,上述硬拷贝命令通过调用lpr程序提交文件进行打印。要更改打印机程序,请自定义变量lpr-command。要为打印机程序指定额外的开关,请自定义列表变量lpr-switches。它的值应该是选项字符串列表,每个选项字符串都应以 ' 开头-' (例如,选项字符串"-w80"指定 80 列的行宽)。默认值是空列表nil

On most operating systems, the above hardcopy commands submit files for printing by calling the lpr program. To change the printer program, customize the variable lpr-command. To specify extra switches to give the printer program, customize the list variable lpr-switches. Its value should be a list of option strings, each of which should start with ‘-’ (e.g., the option string "-w80" specifies a line width of 80 columns). The default is the empty list, nil.

要指定要使用的打印机,请设置变量printer-name。默认值nil指定默认打印机。如果将其设置为打印机名称(字符串),则该名称将lpr 通过 '传递给-P' 转变;如果您不使用lpr,则应使用 指定开关lpr-printer-switch

To specify the printer to use, set the variable printer-name. The default, nil, specifies the default printer. If you set it to a printer name (a string), that name is passed to lpr with the ‘-P’ switch; if you are not using lpr, you should specify the switch with lpr-printer-switch.

该变量lpr-headers-switches同样指定用于制作页眉的额外开关。该变量 lpr-add-switches控制是否提供 '-T' 和 '-Jlpr'打印机程序的 选项(适用于):nil表示不添加它们(如果您的打印机程序与 不兼容,则应为该值lpr)。

The variable lpr-headers-switches similarly specifies the extra switches to use to make page headers. The variable lpr-add-switches controls whether to supply ‘-T’ and ‘-J’ options (suitable for lpr) to the printer program: nil means don’t add them (this should be the value if your printer program is not compatible with lpr).


41.1 PostScript 硬拷贝

41.1 PostScript Hardcopy

这些命令将缓冲区内容转换为 PostScript,打印它或将其保留在另一个 Emacs 缓冲区中。

These commands convert buffer contents to PostScript, either printing it or leaving it in another Emacs buffer.

M-x ps-print-buffer
M-x ps-print-buffer

以 PostScript 形式打印当前缓冲区的硬拷贝。

Print hardcopy of the current buffer in PostScript form.

M-x ps-print-region
M-x ps-print-region

以 PostScript 形式打印当前区域的硬拷贝。

Print hardcopy of the current region in PostScript form.

M-x ps-print-buffer-with-faces
M-x ps-print-buffer-with-faces

以 PostScript 形式打印当前缓冲区的硬拷贝,通过 PostScript 功能显示文本中使用的面。

Print hardcopy of the current buffer in PostScript form, showing the faces used in the text by means of PostScript features.

M-x ps-print-region-with-faces
M-x ps-print-region-with-faces

以 PostScript 形式打印当前区域的硬拷贝,显示文本中使用的面孔。

Print hardcopy of the current region in PostScript form, showing the faces used in the text.

M-x ps-spool-buffer
M-x ps-spool-buffer

为当前缓冲区文本生成并后台打印 PostScript 图像。

Generate and spool a PostScript image for the current buffer text.

M-x ps-spool-region
M-x ps-spool-region

为当前区域生成并假脱机打印 PostScript 图像。

Generate and spool a PostScript image for the current region.

M-x ps-spool-buffer-with-faces
M-x ps-spool-buffer-with-faces

为当前缓冲区生成并假脱机打印 PostScript 图像,显示所使用的面。

Generate and spool a PostScript image for the current buffer, showing the faces used.

M-x ps-spool-region-with-faces
M-x ps-spool-region-with-faces

生成并假脱机当前区域的 PostScript 图像,显示所使用的面孔。

Generate and spool a PostScript image for the current region, showing the faces used.

M-x ps-despool
M-x ps-despool

将假脱机的 PostScript 发送到打印机。

Send the spooled PostScript to the printer.

M-x handwrite
M-x handwrite

为当前缓冲区生成/打印 PostScript,就像手写一样。

Generate/print PostScript for the current buffer as if handwritten.

ps-print-buffer命令ps-print-region以 PostScript 形式打印缓冲区内容。一个命令打印整个缓冲区;另一个,只是地区。命令 ps-print-buffer-with-facesps-print-region-with-faces行为类似,但使用 PostScript 功能来显示缓冲区文本的外观(字体和颜色)。

The ps-print-buffer and ps-print-region commands print buffer contents in PostScript form. One command prints the entire buffer; the other, just the region. The commands ps-print-buffer-with-faces and ps-print-region-with-faces behave similarly, but use PostScript features to show the faces (fonts and colors) of the buffer text.

以交互方式,当您使用前缀参数 ( C-u) 时,这些命令会提示用户输入文件名,并将 PostScript 图像保存在该文件中,而不是将其发送到打印机。

Interactively, when you use a prefix argument (C-u), these commands prompt the user for a file name, and save the PostScript image in that file instead of sending it to the printer.

名称带有 ' 的命令线轴' 代替 '打印',在 Emacs 缓冲区中生成 PostScript 输出,而不是将其发送到打印机。

The commands whose names have ‘spool’ instead of ‘print’, generate the PostScript output in an Emacs buffer instead of sending it to the printer.

使用该命令ps-despool将假脱机图像发送到打印机。此命令发送由 ' 生成的 PostScript-线轴-' 命令(参见上面的命令)到打印机。使用前缀参数 ( C-u),它会提示输入文件名,并将假脱机的 PostScript 图像保存在该文件中,而不是将其发送到打印机。

Use the command ps-despool to send the spooled images to the printer. This command sends the PostScript generated by ‘-spool-’ commands (see commands above) to the printer. With a prefix argument (C-u), it prompts for a file name, and saves the spooled PostScript image in that file instead of sending it to the printer.

M-x handwrite是比较轻浮的。它生成当前缓冲区的 PostScript 再现作为草书手写文档。可以分组定制handwrite。此函数仅支持 ISO 8859-1 字符。

M-x handwrite is more frivolous. It generates a PostScript rendition of the current buffer as a cursive handwritten document. It can be customized in group handwrite. This function only supports ISO 8859-1 characters.


41.2 PostScript 硬拷贝的变量

41.2 Variables for PostScript Hardcopy

所有 PostScript 硬拷贝命令都使用变量 ps-lpr-commandps-lpr-switches来指定如何打印输出。 ps-lpr-command指定要运行的命令名称、 ps-lpr-switches指定要使用的命令行选项以及 ps-printer-name指定打印机。如果您没有自己设置前两个变量,它们将从 lpr-command和获取初始值lpr-switches。如果ps-printer-namenilprinter-name则使用。

All the PostScript hardcopy commands use the variables ps-lpr-command and ps-lpr-switches to specify how to print the output. ps-lpr-command specifies the command name to run, ps-lpr-switches specifies command line options to use, and ps-printer-name specifies the printer. If you don’t set the first two variables yourself, they take their initial values from lpr-command and lpr-switches. If ps-printer-name is nil, printer-name is used.

该变量ps-print-header控制这些命令是否向每个页面添加标题行 - 将其设置nil为关闭标题。

The variable ps-print-header controls whether these commands add header lines to each page—set it to nil to turn headers off.

如果您的打印机不支持颜色,则应通过设置ps-print-color-p为 来关闭颜色处理nil。默认情况下,如果显示器支持颜色,Emacs 会生成带有颜色信息的硬拷贝输出;在黑白打印机上,颜色是用灰色阴影来模拟的。即使您的屏幕颜色仅使用灰色阴影,这也可能会产生难以阅读甚至难以辨认的输出。

If your printer doesn’t support colors, you should turn off color processing by setting ps-print-color-p to nil. By default, if the display supports colors, Emacs produces hardcopy output with color information; on black-and-white printers, colors are emulated with shades of gray. This might produce barely-readable or even illegible output, even if your screen colors only use shades of gray.

或者,您可以设置ps-print-color-pblack-white 让颜色在黑白打印机上显示得更好。它的工作原理是使用信息ps-black-white-faces通过可定制的灰色阴影列表来表达颜色,并通过粗体和斜体面属性进行增强。

Alternatively, you can set ps-print-color-p to black-white to have colors display better on black/white printers. This works by using information in ps-black-white-faces to express colors by customizable list of shades of gray, augmented by bold and italic face attributes.

默认情况下,PostScript 打印会忽略各个面的背景颜色,除非该变量ps-use-face-background为非nil。这是为了避免对斑马条纹和背景图像/文本产生不必要的干扰。

By default, PostScript printing ignores the background colors of the faces, unless the variable ps-use-face-background is non-nil. This is to avoid unwanted interference with the zebra stripes and background image/text.

该变量ps-paper-type指定要格式化的纸张尺寸;合法值包括a4, a3, a4small, b4, b5, executive, ledger, legal, letter, letter-small, statement, tabloid。默认为letter.您可以通过更改变量来定义其他纸张尺寸 ps-page-dimensions-database

The variable ps-paper-type specifies which size of paper to format for; legitimate values include a4, a3, a4small, b4, b5, executive, ledger, legal, letter, letter-small, statement, tabloid. The default is letter. You can define additional paper sizes by changing the variable ps-page-dimensions-database.

该变量ps-landscape-mode指定页面上的打印方向。默认为nil,代表纵向模式。任何非nil值都指定横向模式。

The variable ps-landscape-mode specifies the orientation of printing on the page. The default is nil, which stands for portrait mode. Any non-nil value specifies landscape mode.

变量ps-number-of-columns指定列数;它在横向和纵向模式下均有效。默认值为 1。

The variable ps-number-of-columns specifies the number of columns; it takes effect in both landscape and portrait mode. The default is 1.

该变量ps-font-family指定用于打印普通文本的字体系列。合法值包括CourierHelveticaNewCenturySchlbkPalatinoTimes该变量ps-font-size指定普通文本的字体大小,默认为 8.5 磅。的值 ps-font-size也可能是 2 个浮点的缺点:一个用于横向模式,另一个用于纵向模式。

The variable ps-font-family specifies which font family to use for printing ordinary text. Legitimate values include Courier, Helvetica, NewCenturySchlbk, Palatino and Times. The variable ps-font-size specifies the size of the font for ordinary text and defaults to 8.5 points. The value of ps-font-size can also be a cons of 2 floats: one for landscape mode, the other for portrait mode.

Emacs 比典型的 PostScript 打印机支持更多的脚本和字符。因此,缓冲区中的某些字符可能无法使用打印机内置的字体进行打印。您可以使用 GNU Intlfonts 包中的字体来扩充随打印机提供的字体,也可以指示 Emacs 专门使用 Intlfonts。变量ps-multibyte-buffer对此进行控制:默认值 nil适合打印ASCII和 Latin-1 字符;值适用于内置ASCII、Latin-1、日语和韩语字符non-latin-printer字体的打印机。值安排 Intlfonts 包中的 BDF 字体用于所有 字符。最后,值指示打印机对ASCII和 Latin-1 字符 使用内置字体,对其余字符使用 Intlfonts BDF 字体。 bdf-fontbdf-font-except-latin

Emacs supports more scripts and characters than a typical PostScript printer. Thus, some of the characters in your buffer might not be printable using the fonts built into your printer. You can augment the fonts supplied with the printer with those from the GNU Intlfonts package, or you can instruct Emacs to use Intlfonts exclusively. The variable ps-multibyte-buffer controls this: the default value, nil, is appropriate for printing ASCII and Latin-1 characters; a value of non-latin-printer is for printers which have the fonts for ASCII, Latin-1, Japanese, and Korean characters built into them. A value of bdf-font arranges for the BDF fonts from the Intlfonts package to be used for all characters. Finally, a value of bdf-font-except-latin instructs the printer to use built-in fonts for ASCII and Latin-1 characters, and Intlfonts BDF fonts for the rest.

为了能够使用 BDF 字体,Emacs 需要知道在哪里可以找到它们。该变量bdf-directory-list保存 Emacs 应在其中查找字体的目录列表;默认值包括单个目录/usr/local/share/emacs/fonts/bdf

To be able to use the BDF fonts, Emacs needs to know where to find them. The variable bdf-directory-list holds the list of directories where Emacs should look for the fonts; the default value includes a single directory /usr/local/share/emacs/fonts/bdf.

这些命令的许多其他自定义变量在 Lisp 文件中定义和描述ps-打印.elps-mule.el

Many other customization variables for these commands are defined and described in the Lisp files ps-print.el and ps-mule.el.


41.3 打印包装

41.3 Printing Package

用于打印硬拷贝的基本 Emacs 功能可以使用 Printing 包进行扩展。这提供了一个易于使用的界面,用于选择打印内容、在打印前预览 PostScript 文件以及设置各种打印选项,例如打印标题、横向或纵向模式、双面模式等。在 GNU/Linux 或 Unix 系统上,打印包依赖于GS电压实用程序,作为 GhostScript 程序的一部分分发。在 MS-Windows 上,工具箱可以使用 Ghostscript 的端口。

The basic Emacs facilities for printing hardcopy can be extended using the Printing package. This provides an easy-to-use interface for choosing what to print, previewing PostScript files before printing, and setting various printing options such as print headers, landscape or portrait modes, duplex modes, and so forth. On GNU/Linux or Unix systems, the Printing package relies on the gs and gv utilities, which are distributed as part of the GhostScript program. On MS-Windows, the gstools port of Ghostscript can be used.

要使用 Printing 包,请添加(require 'printing)到您的 init 文件(请参阅Emacs 初始化文件),后跟(pr-update-menus).此功能用 ' 替换菜单栏中常用的打印命令印刷' 包含各种打印选项的子菜单。您还可以输入;这创建了一个 M-x pr-interface RET*打印接口*buffer,类似于自定义缓冲区,您可以在其中设置打印选项。选择打印内容和方式后,您可以使用“打印' 按钮(单击 mouse-2它,或将点移到它上面并键入RET)。有关各种选项的更多信息,请使用“界面帮助' 按钮。

To use the Printing package, add (require 'printing) to your init file (see The Emacs Initialization File), followed by (pr-update-menus). This function replaces the usual printing commands in the menu bar with a ‘Printing’ submenu that contains various printing options. You can also type M-x pr-interface RET; this creates a *Printing Interface* buffer, similar to a customization buffer, where you can set the printing options. After selecting what and how to print, you start the print job using the ‘Print’ button (click mouse-2 on it, or move point over it and type RET). For further information on the various options, use the ‘Interface Help’ button.


42 文本排​​序

42 Sorting Text

Emacs 提供了几个用于对缓冲区中的文本进行排序的命令。所有操作都针对该区域的内容。它们将区域的文本划分为许多排序记录,为每个记录标识一个排序键,然后将记录重新排序为排序键确定的顺序。对记录进行排序,使其键按字母顺序排列,或者对于数字排序,按数字顺序排列。按字母顺序排序时,全部大写字母 'A' 通过 'Z'位于小写字母之前'A',按照 ASCII字符序列(但是sort-fold-case,如下所述,可以更改它)。

Emacs provides several commands for sorting text in the buffer. All operate on the contents of the region. They divide the text of the region into many sort records, identify a sort key for each record, and then reorder the records into the order determined by the sort keys. The records are ordered so that their keys are in alphabetical order, or, for numeric sorting, in numeric order. In alphabetic sorting, all upper-case letters ‘A’ through ‘Z’ come before lower-case ‘a’, in accordance with the ASCII character sequence (but sort-fold-case, described below, can change that).

各种排序命令的不同之处在于它们如何将文本划分为排序记录以及每个记录的哪一部分用作排序键。大多数命令使每一行成为单独的排序记录,但某些命令使用段落或页面作为排序记录。大多数排序命令使用每个完整的排序记录作为其自己的排序键,但有些命令仅使用记录的一部分作为排序键。

The various sort commands differ in how they divide the text into sort records and in which part of each record is used as the sort key. Most of the commands make each line a separate sort record, but some commands use paragraphs or pages as sort records. Most of the sort commands use each entire sort record as its own sort key, but some use only a portion of the record as the sort key.

M-x sort-lines
M-x sort-lines

将区域分为几行,并通过比较一行的整个文本来排序。数字参数意味着按降序排序。

Divide the region into lines, and sort by comparing the entire text of a line. A numeric argument means sort into descending order.

M-x sort-paragraphs
M-x sort-paragraphs

将区域划分为段落,并通过比较段落的整个文本(前导空白行除外)进行排序。数字参数意味着按降序排序。

Divide the region into paragraphs, and sort by comparing the entire text of a paragraph (except for leading blank lines). A numeric argument means sort into descending order.

M-x sort-pages
M-x sort-pages

将区域划分为多个页面,并通过比较页面的整个文本(前导空白行除外)进行排序。数字参数意味着按降序排序。

Divide the region into pages, and sort by comparing the entire text of a page (except for leading blank lines). A numeric argument means sort into descending order.

M-x sort-fields
M-x sort-fields

将区域分为几行,并通过比较每行中一个字段的内容来排序。字段被定义为由空格分隔,因此一行中连续的非空格字符的第一个运行构成字段 1,第二个这样的运行构成字段 2,依此类推。

使用数字参数指定要按哪个字段排序:1 按字段 1 排序,等等;默认值为 1。负参数表示从右侧而不是从左侧开始计数字段;因此,负 1 表示按最后一个字段排序。如果多行在要排序的字段中具有相同的内容,它们将保持与原始缓冲区中相同的相对顺序。

Divide the region into lines, and sort by comparing the contents of one field in each line. Fields are defined as separated by whitespace, so the first run of consecutive non-whitespace characters in a line constitutes field 1, the second such run constitutes field 2, etc.

Specify which field to sort by with a numeric argument: 1 to sort by field 1, etc.; the default is 1. A negative argument means count fields from the right instead of from the left; thus, minus 1 means sort by the last field. If several lines have identical contents in the field being sorted, they keep the same relative order that they had in the original buffer.

M-x sort-numeric-fields
M-x sort-numeric-fields

类似M-x sort-fields,只是每行将指定字段转换为整数,并对数字进行比较。 '10'先于'2' 当被视为文本时,但在其后被视为数字时。默认情况下,数字根据 进行解释sort-numeric-base,但以 ' 开头的数字0x' 或者 '0' 分别解释为十六进制和八进制。

Like M-x sort-fields except the specified field is converted to an integer for each line, and the numbers are compared. ‘10’ comes before ‘2’ when considered as text, but after it when considered as a number. By default, numbers are interpreted according to sort-numeric-base, but numbers beginning with ‘0x’ or ‘0’ are interpreted as hexadecimal and octal, respectively.

M-x sort-columns
M-x sort-columns

类似M-x sort-fields,只是用于比较的每行中的文本来自固定范围的列。使用前缀参数,按相反顺序排序。有关此命令的更多详细信息,请参阅下文。

Like M-x sort-fields except that the text within each line used for comparison comes from a fixed range of columns. With a prefix argument, sort in reverse order. See below for more details on this command.

M-x reverse-region
M-x reverse-region

反转该区域中的线的顺序。这对于按字段降序排序非常有用,因为这些排序命令没有执行此操作的功能。

Reverse the order of the lines in the region. This is useful for sorting into descending order by fields, since those sort commands do not have a feature for doing that.

例如,如果缓冲区包含以下内容:

For example, if the buffer contains this:

在冲突检测(锁定正在编辑的文件)的系统上
实现后,Emacs 还会在您第一次修改缓冲区时进行检查
自上次访问以来该文件在磁盘上是否已更改或
已保存。如果有,系统会要求您确认是否要更改
缓冲区。
On systems where clash detection (locking of files being edited) is
implemented, Emacs also checks the first time you modify a buffer
whether the file has changed on disk since it was last visited or
saved.  If it has, you are asked to confirm that you want to change
the buffer.

应用于M-x sort-lines整个缓冲区会产生以下结果:

applying M-x sort-lines to the entire buffer produces this:

在冲突检测(锁定正在编辑的文件)的系统上
实现后,Emacs 还会在您第一次修改缓冲区时进行检查
已保存。如果有,系统会要求您确认是否要更改
缓冲区。
自上次访问以来该文件在磁盘上是否已更改或
On systems where clash detection (locking of files being edited) is
implemented, Emacs also checks the first time you modify a buffer
saved.  If it has, you are asked to confirm that you want to change
the buffer.
whether the file has changed on disk since it was last visited or

其中大写 '' 在所有小写字母之前排序。如果你使用C-u 2 M-x sort-fields它,你会得到这个:

where the upper-case ‘O’ sorts before all lower-case letters. If you use C-u 2 M-x sort-fields instead, you get this:

实现后,Emacs 还会在您第一次修改缓冲区时进行检查
已保存。如果有,系统会要求您确认是否要更改
缓冲区。
在冲突检测(锁定正在编辑的文件)的系统上
自上次访问以来该文件在磁盘上是否已更改或
implemented, Emacs also checks the first time you modify a buffer
saved.  If it has, you are asked to confirm that you want to change
the buffer.
On systems where clash detection (locking of files being edited) is
whether the file has changed on disk since it was last visited or

排序键在哪里 'Emacs','如果','缓冲','系统' 和 ''。

where the sort keys were ‘Emacs’, ‘If’, ‘buffer’, ‘systems’ and ‘the’.

M-x sort-columns需要更多解释。您可以通过在其中一列上放置点并在另一列上放置标记来指定列。因为这意味着您不能将点或标记放在要排序的文本的第一行的开头,所以此命令使用“区域”的不寻常定义:所有行点都被视为区域的一部分,标记所在的所有行以及其间的所有行也是如此。

M-x sort-columns requires more explanation. You specify the columns by putting point at one of the columns and the mark at the other column. Because this means you cannot put point or the mark at the beginning of the first line of the text you want to sort, this command uses an unusual definition of “region”: all of the line point is in is considered part of the region, and so is all of the line the mark is in, as well as all the lines in between.

例如,要按第 10 至 15 列中的信息对表进行排序,您可以将标记放在表第一行的第 10 列上,并指向表最后一行的第 15 列,然后运行 sort-columns​​。同样,您可以使用第一行第 15 列上的标记和最后一行第 10 列上的点来运行它。

For example, to sort a table by information found in columns 10 to 15, you could put the mark on column 10 in the first line of the table, and point on column 15 in the last line of the table, and then run sort-columns. Equivalently, you could run it with the mark on column 15 in the first line and point on column 10 in the last line.

这可以被认为是对由点和标记指定的矩形进行排序,只不过矩形左侧或右侧每行上的文本与矩形内部的文本一起移动。请参阅矩形

This can be thought of as sorting the rectangle specified by point and the mark, except that the text on each line to the left or right of the rectangle moves along with the text inside the rectangle. See Rectangles.

许多排序命令在比较时忽略大小写差异,如果 sort-fold-case是非nil

Many of the sort commands ignore case differences when comparing, if sort-fold-case is non-nil.


43 编辑图片

43 Editing Pictures

要编辑由文本字符组成的图片(例如,将寄存器划分为字段的图片,作为程序中的注释),请使用命令M-x picture-mode进入图片模式。

To edit a picture made out of text characters (for example, a picture of the division of a register into fields, as a comment in a program), use the command M-x picture-mode to enter Picture mode.

在图片模式下,编辑基于文本的四分之一平面模型,根据该模型,文本字符镶嵌在向右和向下无限延伸的区域上。该模型中不存在行尾的概念;您最多可以说的是在该行中找到最后一个非空白字符的位置。

In Picture mode, editing is based on the quarter-plane model of text, according to which the text characters lie studded on an area that stretches infinitely far to the right and downward. The concept of the end of a line does not exist in this model; the most you can say is where the last nonblank character on the line is found.

当然,Emacs 实际上总是将文本视为字符序列,并且行确实有结尾。但图片模式用模拟文本四分之一平面模型的变体取代了最常用的命令。他们通过插入空格或将制表符转换为空格来实现这一点。

Of course, Emacs really always considers text as a sequence of characters, and lines really do have ends. But Picture mode replaces the most frequently-used commands with variants that simulate the quarter-plane model of text. They do this by inserting spaces or by converting tabs to spaces.

Emacs 的大多数基本编辑命令都由图片模式重新定义,以执行基本相同的操作,但以四分之一平面的方式进行。此外,图片模式定义了以前缀C-c开头的各种按键来运行特殊的图片编辑命令。

Most of the basic editing commands of Emacs are redefined by Picture mode to do essentially the same thing but in a quarter-plane way. In addition, Picture mode defines various keys starting with the C-c prefix to run special picture editing commands.

其中一个键C-c C-c特别重要。通常,图片是较大文件的一部分,该文件通常在其他一些主要模式下进行编辑。图像模式会记录上一个主要模式的名称,以便您稍后可以使用命令C-c C-c( picture-mode-exit) 返回到该模式。 C-c C-c除非给出数字参数,否则还会删除行尾的空格。

One of these keys, C-c C-c, is particularly important. Often a picture is part of a larger file that is usually edited in some other major mode. Picture mode records the name of the previous major mode so you can use the C-c C-c command (picture-mode-exit) later to go back to that mode. C-c C-c also deletes spaces from the ends of lines, unless given a numeric argument.

图片模式的特殊命令在其他模式下均有效(前提是图片库已加载),但除图片模式外,不绑定到按键。下面的描述讨论了移动“一列”等,但所有图片模式命令都像正常的等效命令一样处理数字参数。

The special commands of Picture mode all work in other modes (provided the picture library is loaded), but are not bound to keys except in Picture mode. The descriptions below talk of moving “one column” and so on, but all the picture mode commands handle numeric arguments as their normal equivalents do.

打开图片模式运行挂钩picture-mode-hook。图片模式的其他扩展可以在 艺术家.el

Turning on Picture mode runs the hook picture-mode-hook. Additional extensions to Picture mode can be found in artist.el.


43.1 图片模式下的基本编辑

43.1 Basic Editing in Picture Mode

大多数键在图片模式下执行与通常相同的操作,但以四分之一平面样式执行。例如,C-f反弹到运行picture-forward-column,该命令将点向右移动一列,必要时插入一个空格,以便行的实际结尾没有区别。 C-b是反弹到运行 picture-backward-column,它总是将点向左移动一列,如有必要,将制表符转换为多个空格。 C-nC-p被反弹到 runpicture-move-downpicture-move-up,它可以根据需要插入空格或转换制表符,以确保该点保持在完全相同的列中。 C-erunning picture-end-of-line,移动到该行最后一个非空白字符之后。 C-a运行 picture-beginning-of-line。 (屏幕模型的选择不会影响行的开头;该命令唯一做的额外事情是将当前图片列更新为 0。)

Most keys do the same thing in Picture mode that they usually do, but do it in a quarter-plane style. For example, C-f is rebound to run picture-forward-column, a command which moves point one column to the right, inserting a space if necessary so that the actual end of the line makes no difference. C-b is rebound to run picture-backward-column, which always moves point left one column, converting a tab to multiple spaces if necessary. C-n and C-p are rebound to run picture-move-down and picture-move-up, which can either insert spaces or convert tabs as necessary to make sure that point stays in exactly the same column. C-e runs picture-end-of-line, which moves to after the last nonblank character on the line. C-a runs picture-beginning-of-line. (The choice of screen model does not affect beginnings of lines; the only extra thing this command does is update the current picture column to 0.)

通过使用覆盖模式(请参阅次要模式),文本插入将适应四分之一平面屏幕模型。自插入字符逐列替换现有文本,而不是将现有文本推到右侧。 RETrunning picture-newline,它只是移动到下一行的开头,以便新文本将替换该行。

Insertion of text is adapted to the quarter-plane screen model through the use of Overwrite mode (see Minor Modes.) Self-inserting characters replace existing text, column by column, rather than pushing existing text to the right. RET runs picture-newline, which just moves to the beginning of the following line so that new text will replace that line.

在图片模式下,通常删除或终止文本的命令,而是擦除文本(用空格替换)。 DEL ( picture-backward-clear-column) 用空格替换前面的字符而不是删除它;这个移动点向后。 C-d( picture-clear-column) 用空格替换下一个或多个字符,但不移动点。 (如果您想将字符清除为空格并向前移动,请使用 SPC。) C-k( picture-clear-line) 确实会删除行的内容,但不会从缓冲区中删除换行符。

In Picture mode, the commands that normally delete or kill text, instead erase text (replacing it with spaces). DEL (picture-backward-clear-column) replaces the preceding character with a space rather than removing it; this moves point backwards. C-d (picture-clear-column) replaces the next character or characters with spaces, but does not move point. (If you want to clear characters to spaces and move forward over them, use SPC.) C-k (picture-clear-line) really kills the contents of lines, but does not delete the newlines from the buffer.

要进行实际插入,您必须使用特殊命令。 C-o ( picture-open-line) 在当前行之后创建一个空行;它永远不会分割线。 C-M-o( split-line) 在图片模式下有意义,因此不会改变。 C-j ( picture-duplicate-line) 在当前行下方插入另一行内容相同的行。

To do actual insertion, you must use special commands. C-o (picture-open-line) creates a blank line after the current line; it never splits a line. C-M-o (split-line) makes sense in Picture mode, so it is not changed. C-j (picture-duplicate-line) inserts another line with the same contents below the current line.

要在图片模式下进行实际删除,请使用C-w, C-c C-d (定义为delete-char,与C-d其他模式一样)或图片矩形命令之一(请参阅图片模式矩形命令)。

To do actual deletion in Picture mode, use C-w, C-c C-d (which is defined as delete-char, as C-d is in other modes), or one of the picture rectangle commands (see Picture Mode Rectangle Commands).


43.2 插入后控制运动

43.2 Controlling Motion after Insert

由于图片模式下的自插入字符会覆盖并移动点,因此对于如何移动点没有本质限制。通常点向右移动,但您可以指定自插入字符后运动的八个正交或对角线方向中的任何一个。这对于在缓冲区中绘制线条很有用。

Since self-inserting characters in Picture mode overwrite and move point, there is no essential restriction on how point should be moved. Normally point moves right, but you can specify any of the eight orthogonal or diagonal directions for motion after a self-inserting character. This is useful for drawing lines in the buffer.

C-c <
C-c <
C-c LEFT
C-c LEFT

插入后向左移动 ( picture-movement-left)。

Move left after insertion (picture-movement-left).

C-c >
C-c >
C-c RIGHT
C-c RIGHT

插入后向右移动 ( picture-movement-right)。

Move right after insertion (picture-movement-right).

C-c ^
C-c ^
C-c UP
C-c UP

插入后向上移动 ( picture-movement-up)。

Move up after insertion (picture-movement-up).

C-c .
C-c .
C-c DOWN
C-c DOWN

插入后向下移动 ( picture-movement-down)。

Move down after insertion (picture-movement-down).

C-c `
C-c `
C-c Home
C-c Home

插入后向上和向左移动(“西北”)( picture-movement-nw)。

Move up and left (“northwest”) after insertion (picture-movement-nw).

C-c '
C-c '
C-c PageUp
C-c PageUp
C-c prior
C-c prior

插入后向上向右移动(“东北”)(picture-movement-ne)。

Move up and right (“northeast”) after insertion (picture-movement-ne).

C-c /
C-c /
C-c End
C-c End

插入后向下和向左移动(“西南”)
( picture-movement-sw)。

Move down and left (“southwest”) after insertion
(picture-movement-sw).

C-c \
C-c \
C-c PageDown
C-c PageDown
C-c next
C-c next

插入后向下向右移动(“东南”)
picture-movement-se)。

Move down and right (“southeast”) after insertion
(picture-movement-se).

两个运动命令根据当前图片插入方向移动。命令C-c C-f( picture-motion) 与当前插入后的运动方向相同,而C-c C-b( picture-motion-reverse) 则相反。

Two motion commands move based on the current Picture insertion direction. The command C-c C-f (picture-motion) moves in the same direction as motion after insertion currently does, while C-c C-b (picture-motion-reverse) moves in the opposite direction.


43.3 图像模式选项卡

43.3 Picture Mode Tabs

图片模式下提供了两种类似选项卡的操作。使用 ( ) 进行基于上下文的选项卡。如果没有参数,它会移动到下一个“有趣”字符下方的点,该字符位于上一个非空行中的空白之后。这里的“下一个”是指“出现在比起始点更大的水平位置”。使用前缀参数,如 中 ,此命令移动到当前行中的下一个这样有趣的字符。 不改变文本;它只移动点。 “有趣的”字符由变量 定义,该变量应该定义一组字符。该变量的语法类似于 ' 内部使用的语法M-TABpicture-tab-searchC-u M-TABM-TABpicture-tab-chars[…]' 在正则表达式中 - 但没有 '[' 和 ']'。它的默认值为"!-~"

Two kinds of tab-like action are provided in Picture mode. Use M-TAB (picture-tab-search) for context-based tabbing. With no argument, it moves to a point underneath the next “interesting” character that follows whitespace in the previous nonblank line. “Next” here means “appearing at a horizontal position greater than the one point starts out at”. With prefix argument, as in C-u M-TAB, this command moves to the next such interesting character in the current line. M-TAB does not change the text; it only moves point. “Interesting” characters are defined by the variable picture-tab-chars, which should define a set of characters. The syntax for this variable is like the syntax used inside of ‘[…]’ in a regular expression—but without the ‘[’ and the ‘]’. Its default value is "!-~".

TAB本身运行picture-tab,它根据当前制表位设置进行操作;它相当于图片模式 tab-to-tab-stop。通常它只是移动点,但使用数字参数时它会清除它移动的文本。

TAB itself runs picture-tab, which operates based on the current tab stop settings; it is the Picture mode equivalent of tab-to-tab-stop. Normally it just moves point, but with a numeric argument it clears the text that it moves over.

基于上下文和基于制表位的制表符形式由命令( ) 组合在一起。此命令将制表位设置到 当前行中认为重要的位置。该命令与 一起使用,可以获得基于上下文的 Tab 键切换效果。但 在足够的情况下更方便。 C-c TABpicture-set-tab-stopsM-TABTABM-TAB

The context-based and tab-stop-based forms of tabbing are brought together by the command C-c TAB (picture-set-tab-stops). This command sets the tab stops to the positions which M-TAB would consider significant in the current line. The use of this command, together with TAB, can get the effect of context-based tabbing. But M-TAB is more convenient in the cases where it is sufficient.

防止在图片中使用实际制表符可能会很方便。例如,这可以防止弄乱图片。您可以通过将变量设置 为 来做到这一点。 C-x TABindent-tabs-modenil

It may be convenient to prevent use of actual tab characters in pictures. For example, this prevents C-x TAB from messing up the picture. You can do this by setting the variable indent-tabs-mode to nil.


43.4 图像模式矩形命令

43.4 Picture Mode Rectangle Commands

图片模式定义了以适合四分之一平面模型的方式处理矩形文本片段的命令。标准矩形命令也可能有用。请参阅矩形

Picture mode defines commands for working on rectangular pieces of the text in ways that fit with the quarter-plane model. The standard rectangle commands may also be useful. See Rectangles.

C-c C-k
C-c C-k

清除带有空格 ( picture-clear-rectangle) 的区域矩形。使用前缀参数,删除文本。

Clear out the region-rectangle with spaces (picture-clear-rectangle). With a prefix argument, delete the text.

C-c C-w r
C-c C-w r

类似,但首先将矩形内容保存到寄存器r中( picture-clear-rectangle-to-register)。请参阅寄存器

Similar, but save rectangle contents in register r first (picture-clear-rectangle-to-register). See Registers.

C-c C-y
C-c C-y

通过覆盖将最后一个被杀死的矩形复制到缓冲区中,左上角位于点( picture-yank-rectangle)处。如果有参数,则插入。

Copy last killed rectangle into the buffer by overwriting, with upper left corner at point (picture-yank-rectangle). With argument, insert instead.

C-c C-x r
C-c C-x r

类似,但使用寄存器r ( )中的矩形picture-yank-rectangle-from-register

Similar, but use the rectangle in register r (picture-yank-rectangle-from-register).

图片矩形命令C-c C-k ( picture-clear-rectangle) 和C-c C-w ( picture-clear-rectangle-to-register) 与标准矩形命令的不同之处在于,它们通常清除矩形而不是删除它;这与C-d图片模式中的更改 方式类似。

The picture rectangle commands C-c C-k (picture-clear-rectangle) and C-c C-w (picture-clear-rectangle-to-register) differ from the standard rectangle commands in that they normally clear the rectangle instead of deleting it; this is analogous with the way C-d is changed in Picture mode.

但是,删除矩形在图片模式下可能很有用,因此如果给定数字参数,这些命令将删除矩形。 C-c C-k无论带或不带数字参数,都会保存矩形C-c C-y

However, deletion of rectangles can be useful in Picture mode, so these commands delete the rectangle if given a numeric argument. C-c C-k either with or without a numeric argument saves the rectangle for C-c C-y.

用于拉动矩形的图片模式命令与标准命令的不同之处在于它们是覆盖而不是插入。这与其他文本的图片模式插入与其他模式的不同之处相同。 C-c C-y( picture-yank-rectangle) 插入(通过覆盖)最近被杀死的矩形,而 C-c C-x( picture-yank-rectangle-from-register) 对在指定寄存器中找到的矩形执行同样的操作。

The Picture mode commands for yanking rectangles differ from the standard ones in that they overwrite instead of inserting. This is the same way that Picture mode insertion of other text differs from other modes. C-c C-y (picture-yank-rectangle) inserts (by overwriting) the rectangle that was most recently killed, while C-c C-x (picture-yank-rectangle-from-register) does likewise for the rectangle found in a specified register.


44 编辑二进制文件

44 Editing Binary Files

有一种特殊的主要模式用于编辑二进制文件:Hexl 模式。要使用它,请使用M-x hexl-find-file而不是C-x C-f访问该文件。此命令将文件的内容转换为十六进制并允许您编辑翻译。保存文件时,它会自动转换回二进制文件。

There is a special major mode for editing binary files: Hexl mode. To use it, use M-x hexl-find-file instead of C-x C-f to visit the file. This command converts the file’s contents to hexadecimal and lets you edit the translation. When you save the file, it is converted automatically back to binary.

您还可以使用M-x hexl-mode将现有缓冲区转换为十六进制。如果您正常访问文件然后发现它是二进制文件,这非常有用。

You can also use M-x hexl-mode to translate an existing buffer into hex. This is useful if you visit a file normally and then discover it is a binary file.

在 Hexl 模式下插入文本始终会覆盖。这是为了降低意外破坏文件中数据对齐的风险。普通文本字符会插入自身(即用自身覆盖)。有些命令可以通过代码插入特殊字符。大多数光标移动键以及C-x C-s都在 Hexl 模式下绑定到产生相同效果的命令。以下是 Hexl 模式特有的其他重要命令的列表:

Inserting text always overwrites in Hexl mode. This is to reduce the risk of accidentally spoiling the alignment of data in the file. Ordinary text characters insert themselves (i.e., overwrite with themselves). There are commands for insertion of special characters by their code. Most cursor motion keys, as well as C-x C-s, are bound in Hexl mode to commands that produce the same effect. Here is a list of other important commands special to Hexl mode:

C-M-d
C-M-d

插入一个带有十进制代码的字节。

Insert a byte with a code typed in decimal.

C-M-o
C-M-o

插入一个带有八进制代码的字节。

Insert a byte with a code typed in octal.

C-M-x
C-M-x

插入一个带有十六进制代码的字节。

Insert a byte with a code typed in hex.

C-M-a
C-M-a

移至 512 字节页面的开头。

Move to the beginning of a 512-byte page.

C-M-e
C-M-e

移至 512 字节页面的末尾。

Move to the end of a 512-byte page.

C-x [
C-x [

移至 1k 字节页面的开头。

Move to the beginning of a 1k-byte page.

C-x ]
C-x ]

移至 1k 字节页面的末尾。

Move to the end of a 1k-byte page.

M-g
M-g

移动到十六进制指定的地址。

Move to an address specified in hex.

M-j
M-j

移动到以十进制指定的地址。

Move to an address specified in decimal.

C-c C-c
C-c C-c

离开 Hexl 模式,返回到调用之前该缓冲区所具有的主要模式hexl-mode

Leave Hexl mode, going back to the major mode this buffer had before you invoked hexl-mode.

其他 Hexl 命令允许您插入二进制字节的字符串(序列)、按shorts 或ints 移动等;键入以获取详细信息。 C-h a hexl- TAB

Other Hexl commands let you insert strings (sequences) of binary bytes, move by shorts or ints, etc.; type C-h a hexl- TAB for details.

Hexl 模式也可用于编辑文本文件。如果文本文件包含不寻常的字符或使用不寻常的编码(请参阅编码系统),这可能会派上用场。为此,插入字节的 Hexl 命令还可以插入ASCII和非ASCII字符,包括多字节字符。要使用 Hexl 编辑文本文件,请照常访问该文件,然后键入 以切换到 Hexl 模式。您现在可以通过键入文本字符来插入它们。但是,插入多字节字符需要特别小心,以避免创建无效多字节序列的危险:您应该在 point 位于文件中多字节序列的第一个字节上时开始键入此类字符。 M-x hexl-mode RET

Hexl mode can also be used for editing text files. This could come in handy if the text file includes unusual characters or uses unusual encoding (see Coding Systems). For this purpose, Hexl commands that insert bytes can also insert ASCII and non-ASCII characters, including multibyte characters. To edit a text file with Hexl, visit the file as usual, and then type M-x hexl-mode RET to switch to Hexl mode. You can now insert text characters by typing them. However, inserting multibyte characters requires special care, to avoid the danger of creating invalid multibyte sequences: you should start typing such characters when point is on the first byte of a multibyte sequence in the file.


45 保存 Emacs 会话

45 Saving Emacs Sessions

您可以使用桌面库将 Emacs 的状态从一个会话保存到另一个会话。保存的 Emacs桌面配置 包括缓冲区、文件名、主要模式、缓冲区位置、窗口和框架配置以及一些重要的全局变量。

You can use the desktop library to save the state of Emacs from one session to another. The saved Emacs desktop configuration includes the buffers, their file names, major modes, buffer positions, window and frame configuration, and some important global variables.

要启用此功能,请使用自定义缓冲区(请参阅轻松自定义界面)将其设置desktop-save-modet将来的会话,或在 init 文件中添加此行(请参阅Emacs 初始化文件):

To enable this feature, use the Customization buffer (see Easy Customization Interface) to set desktop-save-mode to t for future sessions, or add this line in your init file (see The Emacs Initialization File):

(桌面保存模式 1)
(desktop-save-mode 1)

desktop-save-mode如果您在 init 文件中打开,那么当 Emacs 启动时,它会在其中查找已保存的桌面desktop-path (默认为user-emacs-directory您的主目录)并使用它找到的第一个桌面。当 Emacs 在 desktop-save-mode打开状态下运行时,默认情况下,每当桌面配置发生任何更改时,它都会自动保存桌面。该变量desktop-auto-save-timeout决定 Emacs 检查桌面修改的频率。当您退出 Emacs 时,桌面也会被保存。

If you turn on desktop-save-mode in your init file, then when Emacs starts, it looks for a saved desktop in desktop-path (which defaults to user-emacs-directory and then your home directory) and uses the first desktop it finds. While Emacs runs with desktop-save-mode turned on, it by default auto-saves the desktop whenever any of the desktop configuration changes. The variable desktop-auto-save-timeout determines how frequently Emacs checks for modifications to your desktop. The desktop is also saved when you exit Emacs.

指定选项 '--无桌面当您不希望 Emacs 重新加载任何已保存的桌面配置时,请在 Emacs 命令行上执行此操作。这desktop-save-mode对当前会话关闭。使用 ' 启动 Emacs--无初始化文件desktop-save-mode' 选项还会禁用桌面重新加载,因为它绕过通常打开的 初始化文件 。

Specify the option ‘--no-desktop’ on the Emacs command line when you don’t want it to reload any saved desktop configurations. This turns off desktop-save-mode for the current session. Starting Emacs with the ‘--no-init-file’ option also disables desktop reloading, since it bypasses the init file, where desktop-save-mode is usually turned on.

您可以在不同的目录中单独保存桌面配置;从保存桌面配置的目录启动 Emacs 将恢复该配置,前提是您自定义desktop-path为前置(当前目录)到那里的其他目录。您可以保存当前桌面并通过键入 重新加载保存在另一目录中的桌面 M-x desktop-change-dir。键入内容M-x desktop-revert将恢复到之前重新加载的桌面。

You can have separate saved desktop configurations in different directories; starting Emacs from a directory where you have a saved desktop configuration will restore that configuration, provided that you customize desktop-path to prepend . (the current directory) to the other directories there. You can save the current desktop and reload the one saved in another directory by typing M-x desktop-change-dir. Typing M-x desktop-revert reverts to the previously reloaded desktop.

Emacs 保存桌面的文件在会话运行时被锁定,以避免无意中从另一个 Emacs 会话覆盖它。当 Emacs 退出时,该锁通常会被删除,但如果 Emacs 或您的系统崩溃,锁会保留下来,并且当您重新启动 Emacs 时,它会默认询问您是否使用锁定的桌面文件。您可以通过将变量自定义 desktop-load-locked-desktop为 来避免这个问题nil,这意味着在这种情况下永远不会加载桌面,或者t,这意味着加载桌面而不询问。您还可以将该变量自定义为特殊值check-pid,这意味着如果锁定桌面的 Emacs 进程未在本地计算机上运行,​​则加载该文件。当锁定 Emacs 可能仍在另一台计算机上运行时,不应使用此方法,这可能是在使用 NFS 或类似工具远程安装主目录的多用户环境中的情况。

The file in which Emacs saves the desktop is locked while the session runs, to avoid inadvertently overwriting it from another Emacs session. That lock is normally removed when Emacs exits, but if Emacs or your system crashes, the lock stays, and when you restart Emacs, it will by default ask you whether to use the locked desktop file. You can avoid the question by customizing the variable desktop-load-locked-desktop to either nil, which means never load the desktop in this case, or t, which means load the desktop without asking. You can also customize the variable to the special value check-pid, which means to load the file if the Emacs process that has locked the desktop is not running on the local machine. This should not be used in circumstances where the locking Emacs might still be running on another machine, which could be the case in multi-user environments where your home directory is mounted remotely using NFS or similar.

当 Emacs 以守护进程模式启动时,它不能问你任何问题,因此如果它发现桌面文件被锁定,它不会加载它,除非 desktop-load-locked-desktopt.请注意,由于其他原因,在守护程序模式下恢复桌面有些问题:例如,守护程序无法使用 GUI 功能,因此无法恢复框架位置、大小和装饰等参数。因此,您可能希望延迟在守护程序模式下恢复桌面,直到第一个客户端连接为止,方法是desktop-read在您添加的挂钩函数中调用(见下文)server-after-make-frame-hook (请参阅《Emacs Lisp 参考手册》中的创建框架)。

When Emacs starts in daemon mode, it cannot ask you any questions, so if it finds the desktop file locked, it will not load it, unless desktop-load-locked-desktop is t. Note that restoring the desktop in daemon mode is somewhat problematic for other reasons: e.g., the daemon cannot use GUI features, so parameters such as frame position, size, and decorations cannot be restored. For that reason, you may wish to delay restoring the desktop in daemon mode until the first client connects, by calling desktop-read (see below) in a hook function that you add to server-after-make-frame-hook (see Creating Frames in The Emacs Lisp Reference Manual).

无论何时,您都可以使用该命令M-x desktop-save强制立即保存当前桌面。如果您不想使用自动桌面恢复,因此不打开desktop-save-mode,或者您对桌面进行了重大更改,并且希望确保配置不会在 Emacs 或你的系统崩溃了。M-x desktop-read如果当前 Emacs 会话尚未加载任何桌面, 您可以使用恢复之前保存的桌面。

Whenever you want, you can use the command M-x desktop-save to force immediate saving of the current desktop. This is useful either if you do not want to use the automatic desktop restoration, and thus don’t turn on desktop-save-mode, or when you have made significant changes to the desktop, and want to make sure the configuration doesn’t get lost if Emacs or your system crashes. You can use M-x desktop-read to restore a previously-saved desktop if the current Emacs session didn’t load any desktop yet.

默认情况下,桌面会尝试保存和恢复框架和窗口配置。要禁用此功能,请设置 desktop-restore-framesnil。 (请参阅该变量的文档,了解一些相关选项,您可以自定义这些选项来微调此行为。)

By default, the desktop tries to save and restore the frame and window configuration. To disable this, set desktop-restore-frames to nil. (See that variable’s documentation for some related options that you can customize to fine-tune this behavior.)

当桌面恢复框架和窗口配置时,它使用框架参数的记录值,忽略 init 文件中这些参数的任何设置(请参阅Emacs 初始化文件)。这意味着恢复框架的字体和外观等框架参数将来自桌面文件,它们是在您退出之前的 Emacs 会话时保存的。初始化文件中这些参数的任何设置都将被忽略。要禁用此功能,请自定义 的值frameset-filter-alist以过滤掉您不想恢复的帧参数;然后,它们将根据您在 init 文件中的自定义设置进行设置。

When the desktop restores the frame and window configuration, it uses the recorded values of frame parameters, disregarding any settings for those parameters you have in your init file (see The Emacs Initialization File). This means that frame parameters such as fonts and faces for the restored frames will come from the desktop file, where they were saved when you exited your previous Emacs session; any settings for those parameters in your init file will be ignored. To disable this, customize the value of frameset-filter-alist to filter out the frame parameters you don’t want to be restored; they will then be set according to your customizations in the init file.

默认情况下,不保存有关访问远程文件的缓冲区的信息。自定义变量desktop-files-not-to-save来改变这一点。

Information about buffers visiting remote files is not saved by default. Customize the variable desktop-files-not-to-save to change this.

默认情况下,桌面上的所有缓冲区都会一次性恢复。但是,如果桌面中有大量缓冲区,这可能会很慢。您可以使用变量指定要立即恢复的缓冲区的最大数量desktop-restore-eager;当 Emacs 空闲时,剩余的缓冲区会延迟恢复。

By default, all the buffers in the desktop are restored in one go. However, this may be slow if there are a lot of buffers in the desktop. You can specify the maximum number of buffers to restore immediately with the variable desktop-restore-eager; the remaining buffers are restored lazily, when Emacs is idle.

键入M-x desktop-clear以清空 Emacs 桌面;例如,如果您想通过调用M-x desktop-readnext 切换到另一个桌面,这可能很有用。该desktop-clear 命令杀死除内部缓冲区之外的所有缓冲区,并清除 中列出的全局变量desktop-globals-to-clear。如果您希望它保留某些缓冲区,请自定义变量 desktop-clear-preserve-buffers-regexp,其值是与不杀死的缓冲区名称匹配的正则表达式。

Type M-x desktop-clear to empty the Emacs desktop; this can be useful, for example, if you want to switch to another desktop by invoking M-x desktop-read next. The desktop-clear command kills all buffers except for internal ones, and clears the global variables listed in desktop-globals-to-clear. If you want it to preserve certain buffers, customize the variable desktop-clear-preserve-buffers-regexp, whose value is a regular expression matching the names of buffers not to kill.

如果您想将迷你缓冲区历史记录从一个会话保存到另一个会话,请使用该savehist库。desktop-save-mode如果将这些变量添加到 的值,您还可以保存选定的迷你缓冲区历史记录变量desktop-globals-to-save

If you want to save minibuffer history from one session to another, use the savehist library. You can also save selected minibuffer-history variables as part of desktop-save-mode if you add those variables to the value of desktop-globals-to-save.


46 个递归编辑级别

46 Recursive Editing Levels

递归编辑是指您使用 Emacs 命令在另一个 Emacs 命令中间执行任意编辑的情况。例如,当您C-r在 a 内部 键入时query-replace,您将进入递归编辑,您可以在其中更改当前缓冲区。退出递归编辑后,您将返回到query-replace.请参阅查询替换

A recursive edit is a situation in which you are using Emacs commands to perform arbitrary editing while in the middle of another Emacs command. For example, when you type C-r inside of a query-replace, you enter a recursive edit in which you can change the current buffer. On exiting from the recursive edit, you go back to the query-replace. See Query Replace.

退出递归编辑意味着返回到未完成的命令,继续执行。退出的命令是C-M-c ( exit-recursive-edit)。

Exiting the recursive edit means returning to the unfinished command, which continues execution. The command to exit is C-M-c (exit-recursive-edit).

您还可以中止递归编辑。这就像退出一样,也是立即退出未完成的命令。使用命令 C-]( abort-recursive-edit) 来执行此操作。请参阅退出和中止

You can also abort the recursive edit. This is like exiting, but also quits the unfinished command immediately. Use the command C-] (abort-recursive-edit) to do this. See Quitting and Aborting.

模式行通过在始终围绕主要和次要模式名称的括号周围显示方括号来显示您何时处于递归编辑中。每个窗口的模式行都以相同的方式显示这一点,因为 Emacs 作为一个整体而不是任何特定的窗口或缓冲区都处于递归编辑状态。

The mode line shows you when you are in a recursive edit by displaying square brackets around the parentheses that always surround the major and minor mode names. Every window’s mode line shows this in the same way, since being in a recursive edit is true of Emacs as a whole rather than any particular window or buffer.

可以在递归编辑中进行递归编辑。例如,输入C-ra后query-replace,您可以输入进入调试器的命令。这将在 的递归编辑级别内开始调试器的递归编辑级别C-r。模式行为当前正在进行的每个递归编辑级别显示一对方括号。

It is possible to be in recursive edits within recursive edits. For example, after typing C-r in a query-replace, you may type a command that enters the debugger. This begins a recursive editing level for the debugger, within the recursive editing level for C-r. Mode lines display a pair of square brackets for each recursive editing level currently in progress.

退出内部递归编辑(例如使用调试器c 命令)会恢复在下一个级别运行的命令。该命令完成后,您可以使用C-M-c退出另一个递归编辑级别,依此类推。退出仅适用于最内层。中止也只退出一级递归编辑;它立即返回到上一个递归编辑的命令级别。如果您愿意,您可以中止下一个递归编辑级别。

Exiting the inner recursive edit (such as with the debugger c command) resumes the command running in the next level up. When that command finishes, you can then use C-M-c to exit another recursive editing level, and so on. Exiting applies to the innermost level only. Aborting also gets out of only one level of recursive edit; it returns immediately to the command level of the previous recursive edit. If you wish, you can then abort the next recursive editing level.

或者,该命令M-x top-level中止所有级别的递归编辑,立即返回到顶级命令读取器。如果迷你缓冲区处于活动状态,它也会退出。

Alternatively, the command M-x top-level aborts all levels of recursive edits, returning immediately to the top-level command reader. It also exits the minibuffer, if it is active.

在递归编辑中编辑的文本不必与您在顶层编辑的文本相同。这取决于递归编辑的目的。如果调用递归编辑的命令首先选择不同的缓冲区,那就是您将递归编辑的缓冲区。在任何情况下,您都可以以正常方式在递归编辑中切换缓冲区(只要缓冲区切换键没有被反弹)。您可能可以在递归编辑中完成所有其余的编辑,访问文件等。但这有时可能会产生令人惊讶的影响(例如堆栈溢出)。因此,当您不再需要递归编辑时,请记住退出或中止它。

The text being edited inside the recursive edit need not be the same text that you were editing at top level. It depends on what the recursive edit is for. If the command that invokes the recursive edit selects a different buffer first, that is the buffer you will edit recursively. In any case, you can switch buffers within the recursive edit in the normal manner (as long as the buffer-switching keys have not been rebound). You could probably do all the rest of your editing inside the recursive edit, visiting files and all. But this could have surprising effects (such as stack overflow) from time to time. So remember to exit or abort the recursive edit when you no longer need it.

一般来说,我们会尽量减少 GNU Emacs 中递归编辑级别的使用。这是因为它们限制您按特定顺序返回 - 从最内层到顶层。如果可能,我们会在单独的缓冲区中呈现不同的活动,以便您可以根据需要在它们之间切换。某些命令会切换到新的主要模式,该模式提供了切换回来的命令。这些方法使您能够更灵活地按照您选择的顺序返回未完成的任务。

In general, we try to minimize the use of recursive editing levels in GNU Emacs. This is because they constrain you to go back in a particular order—from the innermost level toward the top level. When possible, we present different activities in separate buffers so that you can switch between them as you please. Some commands switch to a new major mode which provides a command to switch back. These approaches give you more flexibility to go back to unfinished tasks in the order you choose.


47 超链接和 Web 导航功能

47 Hyperlinking and Web Navigation Features

以下小节描述了处理 Emacs 缓冲区文本中出现的 URL 和其他类型链接的便利功能。

The following subsections describe convenience features for handling URLs and other types of links occurring in Emacs buffer text.


47.1 使用 EWW 进行网页浏览

47.1 Web Browsing with EWW

EWW,即 Emacs Web Wowser,是 Emacs 的 Web 浏览器包。它允许浏览 Emacs 缓冲区内的 URL。该命令M-x eww将打开 URL 或搜索网络。您可以使用命令打开文件M-x eww-open-file。您可以使用 EWW 作为 Web 浏览器browse-url,请参阅以下 URL。有关完整详细信息,请参阅Emacs Web Wowser 手册中的EWW

EWW, the Emacs Web Wowser, is a web browser package for Emacs. It allows browsing URLs within an Emacs buffer. The command M-x eww will open a URL or search the web. You can open a file using the command M-x eww-open-file. You can use EWW as the web browser for browse-url, see Following URLs. For full details, see EWW in The Emacs Web Wowser Manual.


47.2 嵌入式WebKit小部件

47.2 Embedded WebKit Widgets

如果 Emacs 是使用适当的支持包编译的,它就能够在其缓冲区中显示浏览器小部件。该命令M-x xwidget-webkit-browse-url要求提供要在浏览器小部件中显示的 URL。 URL 通常默认为点处或之前的 URL,但如果存在活动区域​​(请参阅标记和区域),则默认 URL 在删除其中的任何空格后来自该区域。然后,该命令创建一个新的缓冲区,其中嵌入式浏览器显示指定的 URL。缓冲区置于 Xwidget-WebKit 模式(类似于图像模式,请参阅查看图像文件),该模式提供用于滚动小部件、更改其大小和重新加载小部件的一键命令。输入C-h b该缓冲区以查看键绑定。

If Emacs was compiled with the appropriate support packages, it is able to show browser widgets in its buffers. The command M-x xwidget-webkit-browse-url asks for a URL to display in the browser widget. The URL normally defaults to the URL at or before point, but if there is an active region (see The Mark and the Region), the default URL comes from the region instead, after removing any whitespace from it. The command then creates a new buffer with the embedded browser showing the specified URL. The buffer is put in the Xwidget-WebKit mode (similar to Image mode, see Viewing Image Files), which provides one-key commands for scrolling the widget, changing its size, and reloading it. Type C-h b in that buffer to see the key bindings.

默认情况下,在 xwidget webkit 缓冲区中输入自插入字符不会执行任何操作,或者会触发某些特殊操作。要使这些字符和其他常见编辑键在按下时自动插入,您可以启用xwidget-webkit-edit-mode,这会重新定义它们以传递到 WebKit xwidget。

By default, typing a self-inserting character inside an xwidget webkit buffer will do nothing, or trigger some special action. To make those characters and other common editing keys insert themselves when pressed, you can enable xwidget-webkit-edit-mode, which redefines them to be passed through to the WebKit xwidget.

您还可以xwidget-webkit-edit-mode通过e 在 xwidget webkit 缓冲区中键入内容来启用。

You can also enable xwidget-webkit-edit-mode by typing e inside the xwidget webkit buffer.

xwidget-webkit-isearch-mode是一种次要模式,其行为类似于增量搜索(请参阅增量搜索),但对 WebKit 小部件的内容而不是当前缓冲区进行操作。它绑定到xwidget-webkit 缓冲区C-sC-r位于 xwidget-webkit 缓冲区内。当 调用时C-r,初始搜索将以相反方向执行。

xwidget-webkit-isearch-mode is a minor mode that behaves similarly to incremental search (see Incremental Search), but operates on the contents of a WebKit widget instead of the current buffer. It is bound to C-s and C-r inside xwidget-webkit buffers. When it is invoked by C-r, the initial search will be performed in reverse direction.

输入任何自插入字符都会导致该字符被插入到当前搜索查询中。键入C-s将导致 WebKit 小部件显示下一个搜索结果,而键入 C-r将导致它显示上一个搜索结果。

Typing any self-inserting character will cause the character to be inserted into the current search query. Typing C-s will cause the WebKit widget to display the next search result, while typing C-r will cause it to display the previous one.

要退出增量搜索,您可以键入C-g

To leave incremental search, you can type C-g.

该命令xwidget-webkit-browse-history显示一个缓冲区,其中包含当前 WebKit 缓冲区先前加载的页面列表,并允许您通过点击 导航到这些页面RET

The command xwidget-webkit-browse-history displays a buffer containing a list of pages previously loaded by the current WebKit buffer, and lets you navigate to those pages by hitting RET.

这是必然的H

It is bound to H.


47.3 跟随 URL

47.3 Following URLs

M-x browse-url RET url RET
M-x browse-url RET url RET

将 URL 加载到 Web 浏览器中。

Load a URL into a Web browser.

Browse-URL 包允许您轻松地从 Emacs 中跟踪 URL。大多数 URL 后面都会调用 Web 浏览器; '邮寄地址:' URL 后面是调用compose-mail Emacs 命令将邮件发送到指定地址(请参阅发送邮件)。

The Browse-URL package allows you to easily follow URLs from within Emacs. Most URLs are followed by invoking a web browser; ‘mailto:’ URLs are followed by invoking the compose-mail Emacs command to send mail to the specified address (see Sending Mail).

该命令M-x browse-url会提示输入 URL,然后跟随它。如果点位于合理的 URL 附近,则该 URL 将作为默认值提供。 Browse-URL 包还提供了您可能希望绑定到键的其他命令,例如browse-url-at-pointbrowse-url-at-mouse

The command M-x browse-url prompts for a URL, and follows it. If point is located near a plausible URL, that URL is offered as the default. The Browse-URL package also provides other commands which you might like to bind to keys, such as browse-url-at-point and browse-url-at-mouse.

您可以通过“自定义”组中的各种选项自定义 Browse-URL 的行为 browse-url。特别是,该选项 browse-url-mailto-function允许您定义如何遵循 '邮寄地址:' URL,同时browse-url-browser-function 指定您的默认浏览器。

You can customize Browse-URL’s behavior via various options in the browse-url Customize group. In particular, the option browse-url-mailto-function lets you define how to follow ‘mailto:’ URLs, while browse-url-browser-function specifies your default browser.

browse-url-handlers您可以通过自定义、与函数配对的正则表达式或谓词列表来 定义使用其他函数来浏览某些 URL,以浏览匹配的 URL。

You can define that certain URLs are browsed with other functions by customizing browse-url-handlers, an alist of regular expressions or predicates paired with functions to browse matching URLs.

有关更多信息,请输入 来查看包注释。 C-h P browse-url RET

For more information, view the package commentary by typing C-h P browse-url RET.

Emacs 还有一个次要模式,它支持像 处理文件一样 处理URLurl-handler-mode 。是一个全局次要模式,影响大多数处理文件名的 Emacs 命令和原语。开启此模式后,您可以C-x C-f https://www.gnu.org/ RET查看该网页的HTML,然后可以对其进行编辑并将其保存到本地文件等。

Emacs also has a minor mode that has some support for handling URLs as if they were files. url-handler-mode is a global minor mode that affects most of the Emacs commands and primitives that deal with file names. After switching on this mode, you can say, for instance, C-x C-f https://www.gnu.org/ RET to see the HTML for that web page, and you can then edit it and save it to a local file, for instance.


47.4 激活 URL

47.4 Activating URLs

M-x goto-address-mode
M-x goto-address-mode

激活当前缓冲区中的 URL 和电子邮件地址。

Activate URLs and e-mail addresses in the current buffer.

M-x global-goto-address-mode
M-x global-goto-address-mode

goto-address-mode在所有缓冲区中 激活。

Activate goto-address-mode in all buffers.

您可以通过键入 使 Emacs 在当前缓冲区中专门标记 URL M-x goto-address-mode。当启用此缓冲区本地次要模式时,它会查找缓冲区中的所有 URL,突出显示它们,并将它们转换为可单击的按钮。当点位于文本上时,您可以通过键入( )来跟踪 URL ;或者通过单击或快速单击 (请参阅使用鼠标跟随参考文献)。跟踪 URL 是通过调用子例程来完成的(请参阅跟踪 URL)。 C-c RETgoto-address-at-pointmouse-2mouse-1browse-url

You can make Emacs mark out URLs specially in the current buffer, by typing M-x goto-address-mode. When this buffer-local minor mode is enabled, it finds all the URLs in the buffer, highlights them, and turns them into clickable buttons. You can follow the URL by typing C-c RET (goto-address-at-point) while point is on its text; or by clicking with mouse-2, or by clicking mouse-1 quickly (see Following References with the Mouse). Following a URL is done by calling browse-url as a subroutine (see Following URLs).

goto-address-mode添加模式挂钩和用于显示传入消息的挂钩(例如,rmail-show-message-hook对于 Rmail)可能很有用。 Gnus 或 MH-E 不需要这样做,它们有类似的功能。

It can be useful to add goto-address-mode to mode hooks and hooks for displaying an incoming message (e.g., rmail-show-message-hook for Rmail). This is not needed for Gnus or MH-E, which have similar features of their own.


47.5 查找点处的文件和URL

47.5 Finding Files and URLs at Point

C-x C-fFFAP 包用提供更合理默认值的命令替换了用于查找文件的某些键绑定,例如。当给定前缀参数时,这些命令的行为与普通命令类似。否则,他们会从点周围的文本中获取默认文件名或 URL。如果在缓冲区中找到的内容采用 URL 形式而不是文件名形式,则使用命令 browse-url来查看它(请参阅以下 URL)。

The FFAP package replaces certain key bindings for finding files, such as C-x C-f, with commands that provide more sensible defaults. These commands behave like the ordinary ones when given a prefix argument. Otherwise, they get the default file name or URL from the text around point. If what is found in the buffer has the form of a URL rather than a file name, the commands use browse-url to view it (see Following URLs).

此功能对于跟踪邮件或新闻缓冲区中的引用非常有用,自述文件文件,显现文件等。有关更多信息,请输入 来查看包注释。 C-h P ffap RET

This feature is useful for following references in mail or news buffers, README files, MANIFEST files, and so on. For more information, view the package commentary by typing C-h P ffap RET.

要启用 FFAP,请键入M-x ffap-bindings。这将进行以下键绑定,并在 Rmail、Gnus 和 VM 文章缓冲区中安装附加 FFAP 功能的挂钩。

To enable FFAP, type M-x ffap-bindings. This makes the following key bindings, and also installs hooks for additional FFAP functionality in Rmail, Gnus and VM article buffers.

C-x C-f filename RET
C-x C-f filename RET

查找filename,从点 ( find-file-at-point) 周围的文本猜测默认值。

Find filename, guessing a default from text around point (find-file-at-point).

C-x C-r filename RET
C-x C-r filename RET

ffap-read-only,类似于find-file-read-only

ffap-read-only, analogous to find-file-read-only.

C-x C-v filename RET
C-x C-v filename RET

ffap-alternate-file,类似于find-alternate-file

ffap-alternate-file, analogous to find-alternate-file.

C-x d directory RET
C-x d directory RET

在目录上启动 Dired ,默认为点 ( ) 处的目录dired-at-point

Start Dired on directory, defaulting to the directory at point (dired-at-point).

C-x C-d directory RET
C-x C-d directory RET

ffap-list-directory,类似于list-directory

ffap-list-directory, analogous to list-directory.

C-x 4 f filename RET
C-x 4 f filename RET

ffap-other-window,类似于find-file-other-window

ffap-other-window, analogous to find-file-other-window.

C-x 4 r filename RET
C-x 4 r filename RET

ffap-read-only-other-window,类似于 find-file-read-only-other-window

ffap-read-only-other-window, analogous to find-file-read-only-other-window.

C-x 4 d directory RET
C-x 4 d directory RET

ffap-dired-other-window, 喜欢dired-other-window

ffap-dired-other-window, like dired-other-window.

C-x 5 f filename RET
C-x 5 f filename RET

ffap-other-frame,类似于find-file-other-frame

ffap-other-frame, analogous to find-file-other-frame.

C-x 5 r filename RET
C-x 5 r filename RET

ffap-read-only-other-frame,类似于 find-file-read-only-other-frame

ffap-read-only-other-frame, analogous to find-file-read-only-other-frame.

C-x 5 d directory RET
C-x 5 d directory RET

ffap-dired-other-frame,类似于dired-other-frame

ffap-dired-other-frame, analogous to dired-other-frame.

C-x t C-f filename return
C-x t C-f filename return

ffap-other-tab,类似于find-file-other-tab

ffap-other-tab, analogous to find-file-other-tab.

C-x t C-r filename return
C-x t C-r filename return

ffap-read-only-other-tab,类似于find-file-read-only-other-tab

ffap-read-only-other-tab, analogous to find-file-read-only-other-tab.

M-x ffap-next
M-x ffap-next

在缓冲区中搜索下一个文件名或 URL,然后找到该文件或 URL。

Search buffer for next file name or URL, then find that file or URL.

S-mouse-3
S-mouse-3

ffap-at-mouse查找根据鼠标单击位置周围的文本猜测的文件。

ffap-at-mouse finds the file guessed from text around the position of a mouse click.

C-S-mouse-3
C-S-mouse-3

显示当前缓冲区中提到的文件和 URL 的菜单,然后找到您选择的 ( ffap-menu)。

Display a menu of files and URLs mentioned in current buffer, then find the one you select (ffap-menu).


48 游戏和其他娱乐

48 Games and Other Amusements

animate软件包使文本跳舞(例如,M-x animate-birthday-present)。

The animate package makes text dance (e.g., M-x animate-birthday-present).

M-x blackboxM-x mpuzM-x 5x5都是谜题。 blackbox挑战您通过断层扫描确定盒子内物体的位置。 mpuz显示一个乘法谜题,其中的字母代表您必须猜测的代码中的数字 - 要猜测一个值,请键入一个字母,然后输入您认为它代表的数字。的目的5x5是填满所有的方块。

M-x blackbox, M-x mpuz and M-x 5x5 are puzzles. blackbox challenges you to determine the location of objects inside a box by tomography. mpuz displays a multiplication puzzle with letters standing for digits in a code that you must guess—to guess a value, type a letter and then the digit you think it stands for. The aim of 5x5 is to fill in all the squares.

M-x bubbles是一种游戏,其目标是以最少的步数消除尽可能多的气泡。

M-x bubbles is a game in which the object is to remove as many bubbles as you can in the smallest number of moves.

M-x decipher帮助您对用简单的单字母替换密码加密的缓冲区进行密码分析。

M-x decipher helps you to cryptanalyze a buffer which is encrypted in a simple monoalphabetic substitution cipher.

M-x dissociated-press逐字或逐字符地打乱当前 Emacs 缓冲区中的文本,将其输出写入名为的缓冲区*解离*。正参数告诉它逐个字符地操作,并指定重叠字符的数量。负参数告诉它逐字操作,并指定重叠字的数量。分离新闻产生的结果与马尔可夫链的结果非常相似,但它是一项独立的、无知的发明;它在随机跳转之间巧妙地从样本文本中复制几个连续的字符,这与在每个单词或字符之后随机跳转的马尔可夫链不同。如果您希望文档易于使用且正确,请不要在文档中使用分离词。

M-x dissociated-press scrambles the text in the current Emacs buffer, word by word or character by character, writing its output to a buffer named *Dissociation*. A positive argument tells it to operate character by character, and specifies the number of overlap characters. A negative argument tells it to operate word by word, and specifies the number of overlap words. Dissociated Press produces results fairly like those of a Markov chain, but is however, an independent, ignoriginal invention; it techniquitously copies several consecutive characters from the sample text between random jumps, unlike a Markov chain which would jump randomly after each word or character. Keep dissociwords out of your documentation, if you want it to be well userenced and properbose.

M-x dunnet运行基于文本的冒险游戏。

M-x dunnet runs a text-based adventure game.

如果您想要更多的个人参与,请尝试M-x gomoku,它会和您一起玩围棋游戏。

If you want a little more personal involvement, try M-x gomoku, which plays the game Go Moku with you.

如果你有点无聊,你可以尝试一下M-x hanoi。如果您相当无聊,请给它一个数字参数。如果你非常非常无聊,可以尝试争论 9。坐下来观看。

If you are a little bit bored, you can try M-x hanoi. If you are considerably bored, give it a numeric argument. If you are very, very bored, try an argument of 9. Sit back and watch.

M-x life运行康威的生命游戏元胞自动机。

M-x life runs Conway’s Game of Life cellular automaton.

M-x morse-region将区域中的文本转换为摩尔斯电码;M-x unmorse-region将其转换回来。 M-x nato-region将区域内的文本转换为北约拼音字母;M-x denato-region将其转换回来。

M-x morse-region converts the text in the region to Morse code; M-x unmorse-region converts it back. M-x nato-region converts the text in the region to NATO phonetic alphabet; M-x denato-region converts it back.

M-x pongM-x snake并且M-x tetris是著名的 Pong、Snake 和 Tetris 游戏的实现。

M-x pong, M-x snake and M-x tetris are implementations of the well-known Pong, Snake and Tetris games.

M-x solitaire玩一种纸牌游戏,您可以将钉子跳到其他钉子上。

M-x solitaire plays a game of solitaire in which you jump pegs across other pegs.

当 Emacs 空闲时,该命令M-x zone在显示屏上玩游戏。

The command M-x zone plays games with the display when Emacs is idle.

“真正的程序员”部署M-x butterfly,它使用蝴蝶在驱动器盘片上翻转一点,请参阅https://xkcd.com/378

“Real Programmers” deploy M-x butterfly, which uses butterflies to flip a bit on the drive platter, see https://xkcd.com/378.

最后,如果您发现自己感到沮丧,请尝试向著名心理治疗师伊丽莎描述您的问题。做就是了M-x doctor。通过键入两次来结束每个输入RET

Finally, if you find yourself frustrated, try describing your problems to the famous psychotherapist Eliza. Just do M-x doctor. End each input by typing RET twice.


49 个 Emacs Lisp 包

49 Emacs Lisp Packages

Emacs 通过在包(即 Emacs Lisp 库)中实现附加功能来扩展 。这些可以由您编写或由其他人提供。如果您想安装这样的包以便在将来的 Emacs 会话中可用,您需要编译它并将其放在 Emacs 查找 Lisp 库的目录中。有关此手动安装方法的更多详细信息,请参阅Libraries of Lisp Code for Emacs 。许多软件包在 Lisp 文件开头附近的大量注释中提供了安装和使用说明;您可以使用这些说明来安装和微调您对该软件包的使用。

Emacs is extended by implementing additional features in packages, which are Emacs Lisp libraries. These could be written by you or provided by someone else. If you want to install such a package so it is available in your future Emacs session, you need to compile it and put it in a directory where Emacs looks for Lisp libraries. See Libraries of Lisp Code for Emacs, for more details about this manual installation method. Many packages provide installation and usage instructions in the large commentary near the beginning of the Lisp file; you can use those instructions for installing and fine-tuning your use of the package.

包也可以由包档案提供,它是 Emacs Lisp 包的大型集合。每个包都是一个单独的 Emacs Lisp 程序,有时还包括其他组件,例如信息手册。 Emacs 包含一个功能,可以让您轻松地从此类档案中下载和安装软件包。本章的其余部分将介绍此功能。

Packages can also be provided by package archives, which are large collections of Emacs Lisp packages. Each package is a separate Emacs Lisp program, sometimes including other components such as an Info manual. Emacs includes a facility that lets you easily download and install packages from such archives. The rest of this chapter describes this facility.

要列出可从包存档中安装的包,请键入。它调出一个名为M-x list-packages RET*套餐*以及所有包的列表。您可以通过此缓冲区安装或卸载软件包。请参阅包菜单缓冲区

To list the packages available for installation from package archives, type M-x list-packages RET. It brings up a buffer named *Packages* with a list of all packages. You can install or uninstall packages via this buffer. See The Package Menu Buffer.

命令C-h P( describe-package) 提示输入包的名称,并显示帮助缓冲区,描述包的属性及其实现的功能。

The command C-h P (describe-package) prompts for the name of a package, and displays a help buffer describing the attributes of the package and the features that it implements.

默认情况下,Emacs 从 Emacs 开发人员维护并由 GNU 项目托管的包存档中下载包。或者,您还可以从第三方维护的档案中下载软件包。请参阅软件包安装

By default, Emacs downloads packages from a package archive maintained by the Emacs developers and hosted by the GNU project. Optionally, you can also download packages from archives maintained by third parties. See Package Installation.

有关将 Emacs Lisp 程序转换为可安装包的信息,请参阅Emacs Lisp 参考手册中的打包

For information about turning an Emacs Lisp program into an installable package, See Packaging in The Emacs Lisp Reference Manual.


49.1 包菜单缓冲区

49.1 The Package Menu Buffer

该命令M-x list-packages将打开包菜单。这是一个缓冲区,列出了 Emacs 知道的所有包,每行一个,包含以下信息:

The command M-x list-packages brings up the package menu. This is a buffer listing all the packages that Emacs knows about, one on each line, with the following information:

  • 包名称(例如,'奥克泰克斯')。
  • The package name (e.g., ‘auctex’).
  • 包的版本号(例如,'11.86')。
  • The package’s version number (e.g., ‘11.86’).
  • 包裹的状态——通常是 '可用的'(可以从包存档中下载),'已安装', 或者 '内置'(默认情况下包含在 Emacs 中)。请参阅包状态
  • The package’s status—normally one of ‘available’ (can be downloaded from the package archive), ‘installed’, or ‘built-in’ (included in Emacs by default). See Package Statuses.
  • 如果您启用了多个包存档,则该包来自哪个包存档。
  • Which package archive this package is from, if you have more than one package archive enabled.
  • 包的简短描述。
  • A short description of the package.

list-packages命令访问网络,从包存档服务器检索可用包的列表。如果网络不可用,它将退回到最近检索的列表。

The list-packages command accesses the network, to retrieve the list of available packages from package archive servers. If the network is unavailable, it falls back on the most recently retrieved list.

在包列表缓冲区中使用的主要命令是命令x 。如果尚未安装点下的软件包,此命令将安装它。如果点下的软件包已经安装,此命令将删除它。

The main command to use in the package list buffer is the x command. If the package under point isn’t installed already, this command will install it. If the package under point is already installed, this command will delete it.

包菜单中提供了以下命令:

The following commands are available in the package menu:

h
h

打印一条简短消息,总结如何使用包菜单 ( package-menu-quick-help)。

Print a short message summarizing how to use the package menu (package-menu-quick-help).

?
?
RET
RET

在当前行 ( ) 显示包的帮助缓冲区package-menu-describe-package,类似于命令显示的帮助窗口C-h P(请参阅Emacs Lisp Packages)。

Display a help buffer for the package on the current line (package-menu-describe-package), similar to the help window displayed by the C-h P command (see Emacs Lisp Packages).

i
i

将当前行上的包标记为安装 ( package-menu-mark-install)。如果包裹状态是'可用的',这会添加一个 '' 字符到行的开头;键入x(见下文)将下载并安装该软件包。

Mark the package on the current line for installation (package-menu-mark-install). If the package status is ‘available’, this adds an ‘I’ character to the start of the line; typing x (see below) will download and install the package.

d
d

将当前行上的包标记为删除 ( package-menu-mark-delete)。如果包裹状态是'已安装',这增加了一个'D' 字符到行的开头;输入x(见下文)将删除该包。有关包删除所需内容的信息, 请参阅包文件和目录布局。

Mark the package on the current line for deletion (package-menu-mark-delete). If the package status is ‘installed’, this adds a ‘D’ character to the start of the line; typing x (see below) will delete the package. See Package Files and Directory Layout, for information about what package deletion entails.

w
w

在浏览器中打开当前行的包网站 ( package-browse-url)。 browse-url用于打开浏览器。

Open the package website on the current line in a browser (package-browse-url). browse-url is used to open the browser.

~
~

将所有过时的包标记为删除 ( package-menu-mark-obsolete-for-deletion)。这标记为删除所有状态为 '过时的'。

Mark all obsolete packages for deletion (package-menu-mark-obsolete-for-deletion). This marks for deletion all the packages whose status is ‘obsolete’.

u
u
DEL
DEL

i删除先前通过ord命令 ( )添加到当前行的任何安装或删除标记package-menu-mark-unmark

Remove any installation or deletion mark previously added to the current line by an i or d command (package-menu-mark-unmark).

U
U

将所有软件包标记为具有更新的可用版本以进行升级 ( package-menu-mark-upgrades)。这会在新的可用版本上放置一个安装标记,并在旧的已安装版本上放置一个删除标记(标记为“状态”)过时的')。默认情况下,这不会标记有新版本可用的内置包,但自定义package-install-upgrade-built-in可以改变这一点。请参阅软件包安装。如果您自定义 package-install-upgrade-built-in为非值nil,请务必检查命令标记的所有内置包U,以避免更新您不想覆盖的内置包。

Mark all package with a newer available version for upgrading (package-menu-mark-upgrades). This places an installation mark on the new available versions, and a deletion mark on the old installed versions (marked with status ‘obsolete’). By default, this won’t mark built-in packages for which a newer version is available, but customizing package-install-upgrade-built-in can change that. See Package Installation. If you customize package-install-upgrade-built-in to a non-nil value, be sure to review all the built-in packages the U command marks, to avoid updating built-in packages you don’t want to overwrite.

x
x

下载并安装所有标有 的软件包i及其依赖项;另外,删除所有标有d ( package-menu-execute) 的包。这也消除了标记。如果没有标记任何软件包,此命令将安装 point 下的软件包(如果尚未安装),或删除 point 下的软件包(如果已安装)。

Download and install all packages marked with i, and their dependencies; also, delete all packages marked with d (package-menu-execute). This also removes the marks. If no packages are marked, this command will install the package under point (if it isn’t installed already), or delete the package under point (if it’s already installed).

g
g
r
r

刷新包列表 ( revert-buffer)。这会再次从包存档中获取可用包的列表,并重新显示包列表。

Refresh the package list (revert-buffer). This fetches the list of available packages from the package archive again, and redisplays the package list.

H
H

隐藏名称与正则表达式 ( package-menu-hide-package) 匹配的包。这会提示输入正则表达式,然后隐藏具有匹配名称的包。正则表达式的默认值将仅隐藏其名称所在的包,因此只需按RET提示符即可隐藏当前包。

Hide packages whose names match a regexp (package-menu-hide-package). This prompts for a regexp, and then hides the packages with matching names. The default value of the regexp will hide only the package whose name is at point, so just pressing RET to the prompt will hide the current package.

(
(

切换旧版本包以及低优先级存档版本的可见性 ( package-menu-toggle-hiding)。

Toggle visibility of old versions of packages and also of versions from lower-priority archives (package-menu-toggle-hiding).

/ a
/ a

按存档过滤包列表 ( package-menu-filter-by-archive)。这会提示您提供包存档(例如,'格努'),然后仅显示该存档中的包。您可以通过键入以逗号分隔的名称来指定多个存档。

Filter package list by archive (package-menu-filter-by-archive). This prompts for a package archive (e.g., ‘gnu’), then shows only packages from that archive. You can specify several archives by typing their names separated by commas.

/ d
/ d

按描述过滤包列表 ( package-menu-filter-by-description)。这会提示输入正则表达式,然后仅显示其描述与该正则表达式匹配的包。

Filter package list by description (package-menu-filter-by-description). This prompts for a regular expression, then shows only packages with descriptions matching that regexp.

/ k
/ k

package-menu-filter-by-keyword按关键字 ( )过滤包列表。这会提示输入关键字(例如,'游戏'),然后仅显示带有该关键字的包。您可以通过键入以逗号分隔的方式指定多个关键字。

Filter package list by keyword (package-menu-filter-by-keyword). This prompts for a keyword (e.g., ‘games’), then shows only packages with that keyword. You can specify several keywords by typing them separated by commas.

/ N
/ N

按名称或描述过滤包列表 ( package-menu-filter-by-name-or-description)。这会提示输入正则表达式,然后仅显示名称或描述与该正则表达式匹配的包。

Filter package list by name or description (package-menu-filter-by-name-or-description). This prompts for a regular expression, then shows only packages with a name or description matching that regexp.

/ n
/ n

按名称过滤包列表 ( package-menu-filter-by-name)。这会提示输入正则表达式,然后仅显示名称与该正则表达式匹配的包。

Filter package list by name (package-menu-filter-by-name). This prompts for a regular expression, then shows only packages with names matching that regexp.

/ s
/ s

按状态过滤包裹列表 ( package-menu-filter-by-status)。这会提示输入一种或多种状态(例如,'可用的',请参阅包状态),然后仅显示具有匹配状态的包。您可以通过键入以逗号分隔的状态值来指定多个状态值。

Filter package list by status (package-menu-filter-by-status). This prompts for one or more statuses (e.g., ‘available’, see Package Statuses), then shows only packages with matching status. You can specify several status values by typing them separated by commas.

/ v
/ v

package-menu-filter-by-version按版本 ( )过滤软件包列表。这首先提示输入比较符号之一'<','>' 或者 '=' 以及版本字符串,然后显示其版本相应低于、等于或高于您键入的版本的包。

Filter package list by version (package-menu-filter-by-version). This prompts first for one of the comparison symbols ‘<’, ‘>’ or ‘=’ and for a version string, and then shows packages whose versions are correspondingly lower, equal or higher than the version you typed.

/ m
/ m

按非空标记 ( package-menu-filter-marked) 过滤包列表。这仅显示已标记为要安装或删除的软件包。

Filter package list by non-empty mark (package-menu-filter-marked). This shows only the packages that have been marked to be installed or deleted.

/ u
/ u

筛选软件包列表以仅显示有可用升级的软件包 ( package-menu-filter-upgradable)。默认情况下,此过滤器排除有较新版本可用的内置包,但自定义 package-install-upgrade-built-in可以更改这一点。请参阅软件包安装

Filter package list to show only packages for which there are available upgrades (package-menu-filter-upgradable). By default, this filter excludes the built-in packages for which a newer version is available, but customizing package-install-upgrade-built-in can change that. See Package Installation.

/ /
/ /

清除当前应用于包列表的过滤器 ( package-menu-filter-clear)。

Clear filter currently applied to the package list (package-menu-filter-clear).

例如,您可以通过i在列出该程序包的行中键入后跟 来安装该程序包x

For example, you can install a package by typing i on the line listing that package, followed by x.


49.2 包状态

49.2 Package Statuses

包可以具有以下状态之一:

A package can have one of the following statuses:

'可用的'
available

该软件包尚未安装,但可以从软件包存档中下载并安装。

The package is not installed, but can be downloaded and installed from the package archive.

'阿利奥布索'
avail-obso

该软件包可供安装,但也提供更新版本。具有此状态的包默认是隐藏的。

The package is available for installation, but a newer version is also available. Packages with this status are hidden by default.

'内置'
built-in

该包默认包含在 Emacs 中。它无法通过软件包菜单删除,并且默认情况下不考虑升级(但您可以通过自定义更改它 package-install-upgrade-built-in,请参阅软件包安装)。

The package is included in Emacs by default. It cannot be deleted through the package menu, and by default is not considered for upgrading (but you can change that by customizing package-install-upgrade-built-in, see Package Installation).

'依赖性'
dependency

该软件包是自动安装的,以满足另一个软件包的依赖关系。

The package was installed automatically to satisfy a dependency of another package.

'残疾人'
disabled

已使用该package-load-list 变量禁用该包。

The package has been disabled using the package-load-list variable.

'外部的'
external

该包不是内置的,也不是来自指定的目录 package-user-dir(请参阅包文件和目录布局)。外部包的处理方式很像 '内置' 包且无法删除。

The package is not built-in and not from the directory specified by package-user-dir (see Package Files and Directory Layout). External packages are treated much like ‘built-in’ packages and cannot be deleted.

'握住'
held

包被持有,参见包安装

The package is held, See Package Installation.

'不兼容'
incompat

由于某种原因无法安装该软件包,例如因为它依赖于可卸载的软件包。

The package cannot be installed for some reason, for example because it depends on uninstallable packages.

'已安装'
installed

该软件包已安装。

The package is installed.

'新的'
new

相当于 '可用的',除了在您上次调用 M-x list-packages.

Equivalent to ‘available’, except that the package became newly available on the package archive after your last invocation of M-x list-packages.

'过时的'
obsolete

该软件包是过时的安装版本;除了此版本的软件包外,还安装了较新的版本。

The package is an outdated installed version; in addition to this version of the package, a newer version is also installed.


49.3 软件包安装

49.3 Package Installation

使用包菜单最方便地安装包(请参阅包菜单缓冲区),但您也可以使用命令M-x package-install。这会提示输入带有 ' 的包的名称可用的' 状态,然后下载并安装它。同样,如果要升级某个包,可以使用该M-x package-upgrade命令,如果要升级所有包,可以使用该M-x package-upgrade-all命令。

Packages are most conveniently installed using the package menu (see The Package Menu Buffer), but you can also use the command M-x package-install. This prompts for the name of a package with the ‘available’ status, then downloads and installs it. Similarly, if you want to upgrade a package, you can use the M-x package-upgrade command, and if you want to upgrade all the packages, you can use the M-x package-upgrade-all command.

默认情况下,package-install不考虑可从档案中获取新版本的内置包。 (如果包包含在 Emacs 发行版中,则该包是内置的。)特别是,当您在提示符下键入时,它不会在补全候选列表中显示内置包。但如果您 package-install使用前缀参数调用,它还会考虑可以升级的内置包。您可以通过自定义变量使此行为成为默认行为 package-install-upgrade-built-in:如果其值为非nilpackage-install即使在没有前缀参数的情况下调用,也会考虑内置包。请注意,包菜单命令(请参阅包菜单缓冲区)也受 的影响 package-install-upgrade-built-in

By default, package-install doesn’t consider built-in packages for which new versions are available from the archives. (A package is built-in if it is included in the Emacs distribution.) In particular, it will not show built-in packages in the list of completion candidates when you type at its prompt. But if you invoke package-install with a prefix argument, it will also consider built-in packages that can be upgraded. You can make this behavior the default by customizing the variable package-install-upgrade-built-in: if its value is non-nil, package-install will consider built-in packages even when invoked without a prefix argument. Note that the package-menu commands (see The Package Menu Buffer) are also affected by package-install-upgrade-built-in.

相比之下,package-upgrade永远package-upgrade-all 不要考虑内置包。如果您想使用这些命令来升级某些内置软件包,则需要通过或自定义 为非值来升级每个软件包一次,然后通过软件包菜单或通过。 C-u M-x package-install RETpackage-install-upgrade-built-innilpackage-install

By contrast, package-upgrade and package-upgrade-all never consider built-in packages. If you want to use these commands for upgrading some built-in packages, you need to upgrade each of those packages, once, either via C-u M-x package-install RET, or by customizing package-install-upgrade-built-in to a non-nil value, and then upgrading the package once via the package menu or by package-install.

如果您自定义package-install-upgrade-built-in为非值nil,则在使用一次更新多个软件包的命令(例如软件包菜单中的package-upgrade-all和 )时要非常小心U:这些命令可能会覆盖您不打算用存档中的较新版本替换的内置软件包。如果您只想更新少量内置软件包,请不要使用这些批量命令。

If you customize package-install-upgrade-built-in to a non-nil value, be very careful when using commands that update many packages at once, like package-upgrade-all and U in the package menu: those might overwrite built-in packages that you didn’t intent to replace with newer versions from the archives. Don’t use these bulk commands if you want to update only a small number of built-in packages.

软件包可能需要安装某些其他软件包,因为它依赖于它们提供的功能。当 Emacs 安装此类软件包时,它还会自动下载并安装任何尚未安装的所需软件包。 (如果所需的软件包因​​某种原因不可用,Emacs 会发出错误信号并停止安装。)软件包的要求列表显示在其帮助缓冲区中。

A package may require certain other packages to be installed, because it relies on functionality provided by them. When Emacs installs such a package, it also automatically downloads and installs any required package that is not already installed. (If a required package is somehow unavailable, Emacs signals an error and stops installation.) A package’s requirements list is shown in its help buffer.

默认情况下,包是从 Emacs 开发人员维护的单个包存档中下载的。这是由变量 控制的package-archives,其值是 Emacs 已知的包存档列表。每个列表元素必须具有 形式 ,其中id是包存档的名称,location是包存档目录的URL或名称。如果您希望使用第三方软件包档案,您可以更改此列表,但这样做的风险由您自己承担,并且仅使用您认为可以信任的第三方! (id . location)

By default, packages are downloaded from a single package archive maintained by the Emacs developers. This is controlled by the variable package-archives, whose value is a list of package archives known to Emacs. Each list element must have the form (id . location), where id is the name of a package archive and location is the URL or name of the package archive directory. You can alter this list if you wish to use third party package archives—but do so at your own risk, and use only third parties that you think you can trust!

软件包存档的维护者可以通过对软件包进行签名来增加您对其软件包的信任。他们生成一对私钥/公钥对,并使用私钥为每个包创建签名文件。有了公钥,您就可以使用签名文件来验证包的创建者并确保包没有被篡改。签名验证 通过 EasyPG 接口使用GnuPG 包(参见Emacs EasyPG 助手手册中的EasyPG)。有效签名并不能保证包不是恶意的,因此您仍应谨慎行事。软件包档案应提供有关如何获取其公钥的说明。一种方法是从服务器下载密钥,例如https://pgp.mit.edu/。用于将密钥导入 Emacs。 Emacs 将包密钥存储在变量指定的目录中 ,默认情况下位于M-x package-import-keyringpackage-gnupghome-dir格努普格 的子目录package-user-dir,这会导致 Emacs 使用选项 ' 调用 GnuPG--主目录' 验证签名时。如果package-gnupghome-dirnil,GnuPG 的选项 '--主目录' 被省略。 GNU 软件包存档的公钥随 Emacs 一起分发,位于等/package-keyring.gpg。 Emacs 自动使用它。

The maintainers of package archives can increase the trust that you can have in their packages by signing them. They generate a private/public pair of cryptographic keys, and use the private key to create a signature file for each package. With the public key, you can use the signature files to verify the package creator and make sure the package has not been tampered with. Signature verification uses the GnuPG package via the EasyPG interface (see EasyPG in Emacs EasyPG Assistant Manual). A valid signature is not a cast-iron guarantee that a package is not malicious, so you should still exercise caution. Package archives should provide instructions on how you can obtain their public key. One way is to download the key from a server such as https://pgp.mit.edu/. Use M-x package-import-keyring to import the key into Emacs. Emacs stores package keys in the directory specified by the variable package-gnupghome-dir, by default in the gnupg subdirectory of package-user-dir, which causes Emacs to invoke GnuPG with the option ‘--homedir’ when verifying signatures. If package-gnupghome-dir is nil, GnuPG’s option ‘--homedir’ is omitted. The public key for the GNU package archive is distributed with Emacs, in the etc/package-keyring.gpg. Emacs uses it automatically.

如果用户选项package-check-signature为 non- nil,Emacs 将在您安装软件包时尝试验证签名。如果该选项的值为allow-unsigned,并且找到可用的 OpenPGP 配置,则会检查签名的软件包,但您仍然可以安装未签名的软件包。如果您使用一些未对其包进行签名的存档,您可以将它们添加到列表中 package-unsigned-archives。 (如果该值为 allow-unsigned且未找到可用的 OpenPGP,则该选项被视为其值为nil。)如果该值为t,则至少有一个签​​名必须有效;如果值为all,则所有这些都必须有效。

If the user option package-check-signature is non-nil, Emacs attempts to verify signatures when you install packages. If the option has the value allow-unsigned, and a usable OpenPGP configuration is found, signed packages will be checked, but you can still install a package that is not signed. If you use some archives that do not sign their packages, you can add them to the list package-unsigned-archives. (If the value is allow-unsigned and no usable OpenPGP is found, this option is treated as if its value was nil.) If the value is t, at least one signature must be valid; if the value is all, all of them must be valid.

有关加密密钥和签名的更多信息,请参阅GNU Privacy Guard Manual中的GnuPG。 Emacs 附带了 GNU Privacy Guard 的接口,请参阅Emacs EasyPG 助手手册中的EasyPG

For more information on cryptographic keys and signing, see GnuPG in The GNU Privacy Guard Manual. Emacs comes with an interface to GNU Privacy Guard, see EasyPG in Emacs EasyPG Assistant Manual.

如果您启用了多个软件包存档,并且其中一些提供同一软件包的不同版本,您可能会发现该选项 package-pinned-packages很有用。您可以将包/存档对添加到此列表,以确保仅从指定的存档下载指定的包。

If you have more than one package archive enabled, and some of them offer different versions of the same package, you may find the option package-pinned-packages useful. You can add package/archive pairs to this list, to ensure that the specified package is only ever downloaded from the specified archive.

当您启用多个包存档时另一个有用的选项是package-archive-priorities.它指定每个存档的优先级(数字越大指定优先级越高的存档)。默认情况下,存档的优先级为零,除非此选项的值另有指定。如果来自较高优先级存档的相同包可用,则来自较低优先级存档的包将不会显示在菜单中。 (这由 的值控制package-menu-hide-low-priority。)

Another option that is useful when you have several package archives enabled is package-archive-priorities. It specifies the priority of each archive (higher numbers specify higher priority archives). By default, archives have the priority of zero, unless specified otherwise by this option’s value. Packages from lower-priority archives will not be shown in the menu, if the same package is available from a higher-priority archive. (This is controlled by the value of package-menu-hide-low-priority.)

一旦包被下载、字节编译并安装,它就可供当前的 Emacs 会话使用。使包可用会将其目录添加到自动加载中load-path并加载其自动加载。包自动加载的效果因包而异。大多数软件包仅提供一些新命令,而其他软件包则对 Emacs 会话产生更广泛的影响。有关此类信息,请参阅软件包的帮助缓冲区。

Once a package is downloaded, byte-compiled and installed, it is made available to the current Emacs session. Making a package available adds its directory to load-path and loads its autoloads. The effect of a package’s autoloads varies from package to package. Most packages just make some new commands available, while others have more wide-ranging effects on the Emacs session. For such information, consult the package’s help buffer.

Emacs 在所有后续会话中自动提供已安装的软件包。这种情况发生在启动时、处理 init 文件之前但处理早期 init 文件之后(请参阅早期初始化文件)。作为例外,如果使用 ' 调用,Emacs 不会在启动时提供可用的包-q' 或者 '--无初始化文件' 选项(参见初始选项)。

Installed packages are automatically made available by Emacs in all subsequent sessions. This happens at startup, before processing the init file but after processing the early init file (see The Early Init File). As an exception, Emacs does not make packages available at startup if invoked with the ‘-q’ or ‘--no-init-file’ options (see Initial Options).

要阻止 Emacs 在启动时自动提供包,请将变量更改package-enable-at-startupnil.您必须在早期的初始化文件中执行此操作,因为在加载常规初始化文件之前会读取变量。目前该变量无法通过自定义进行设置。

To keep Emacs from automatically making packages available at startup, change the variable package-enable-at-startup to nil. You must do this in the early init file, as the variable is read before loading the regular init file. Currently this variable cannot be set via Customize.

如果安装了许多软件包,可以通过将用户选项设置为package-quickstart来缩短启动时间t。设置此选项将使 Emacs 预先计算许多东西,而不是在每次 Emacs 启动时重新计算它们。但是,如果您这样做,则package-quickstart-refresh在需要更改激活时(例如更改 的值时), 您必须手动运行该命令 package-load-list

If you have many packages installed, you can improve startup times by setting the user option package-quickstart to t. Setting this option will make Emacs precompute many things instead of re-computing them on every Emacs startup. However, if you do this, then you have to manually run the command package-quickstart-refresh when the activations need to be changed, such as when you change the value of package-load-list.

如果您已设置package-enable-at-startupnil,您仍然可以在启动期间或启动后使软件包可用。要使已安装的软件包在启动期间可用,请调用package-activate-allinit 文件中的函数 。要使已安装的软件包在启动后可用,请调用命令M-: (package-activate-all) RET

If you have set package-enable-at-startup to nil, you can still make packages available either during or after startup. To make installed packages available during startup, call the function package-activate-all in your init file. To make installed packages available after startup, invoke the command M-: (package-activate-all) RET.

为了更好地控制启动时哪些包可用,您可以使用变量package-load-list。它的值应该是一个列表。表单的列表元素告诉 Emacs 提供名为name的包的可用版本version。这里,version应该是一个版本字符串(对应于包的特定版本),或者 (这意味着使任何已安装的版本可用),或者 (这意味着没有版本;这会禁用该包,阻止它变得可用) 。列表元素也可以是 符号,这意味着提供其他列表元素未命名的任何软件包的最新安装版本。默认值只是。 (name version)tnilall'(all)

For finer control over which packages are made available at startup, you can use the variable package-load-list. Its value should be a list. A list element of the form (name version) tells Emacs to make available version version of the package named name. Here, version should be a version string (corresponding to a specific version of the package), or t (which means to make available any installed version), or nil (which means no version; this disables the package, preventing it from being made available). A list element can also be the symbol all, which means to make available the latest installed version of any package not named by the other list elements. The default value is just '(all).

例如,如果您设置package-load-list'((muse "3.20") all),则 Emacs 仅提供 3.20 版本的 '沉思' 软件包,以及除 ' 之外的任何已安装软件包版本沉思'。任何其他版本的 '沉思' 恰好安装的将被忽略。这 '沉思' 软件包将在软件包菜单中列出,并带有 '握住' 地位。

For example, if you set package-load-list to '((muse "3.20") all), then Emacs only makes available version 3.20 of the ‘muse’ package, plus any installed version of packages other than ‘muse’. Any other version of ‘muse’ that happens to be installed will be ignored. The ‘muse’ package will be listed in the package menu with the ‘held’ status.

Emacs 字节代码相当稳定,但字节代码可能会过时,或者编译的文件依赖于新版本 Emacs 中已更改的宏。您可以使用该命令重新编译特定包,或 重新编译所有包。 (如果您安装了许多软件包,后一个命令可能需要相当长的时间才能运行。) M-x package-recompileM-x package-recompile-all

Emacs byte code is quite stable, but it’s possible for byte code to become outdated, or for the compiled files to rely on macros that have changed in new versions of Emacs. You can use the command M-x package-recompile to recompile a particular package, or M-x package-recompile-all to recompile all the packages. (The latter command might take quite a while to run if you have many installed packages.)


49.4 包文件和目录布局

49.4 Package Files and Directory Layout

每个包都以单个包文件的形式从包存档中下载- 可以是 Emacs Lisp 源文件,也可以是包含多个 Emacs Lisp 源文件和其他文件的 tar 文件。包文件由安装包的 Emacs 命令自动检索、处理和处置。通常,您不需要直接处理它们,除非您正在制作一个包(请参阅《Emacs Lisp 参考手册》中的“打包”)。如果您需要直接从包文件安装包,请使用命令。 M-x package-install-file

Each package is downloaded from the package archive in the form of a single package file—either an Emacs Lisp source file, or a tar file containing multiple Emacs Lisp source and other files. Package files are automatically retrieved, processed, and disposed of by the Emacs commands that install packages. Normally, you will not need to deal directly with them, unless you are making a package (see Packaging in The Emacs Lisp Reference Manual). Should you ever need to install a package directly from a package file, use the command M-x package-install-file.

安装后,包的内容将放置在以下子目录中〜/.emacs.d/elpa/(您可以通过更改变量来更改该目录的名称package-user-dir)。包子目录名为名称-版本,其中 name是包名称,version是其版本字符串。

Once installed, the contents of a package are placed in a subdirectory of ~/.emacs.d/elpa/ (you can change the name of that directory by changing the variable package-user-dir). The package subdirectory is named name-version, where name is the package name and version is its version string.

此外package-user-dir,Emacs 还会在 中列出的目录中查找已安装的软件包package-directory-list。这些目录旨在供系统管理员使 Emacs 软件包在系统范围内可用; Emacs 本身从不在那里安装软件包。的包子目录的package-directory-list 布局方式与 中的相同package-user-dir

In addition to package-user-dir, Emacs looks for installed packages in the directories listed in package-directory-list. These directories are meant for system administrators to make Emacs packages available system-wide; Emacs itself never installs packages there. The package subdirectories for package-directory-list are laid out in the same way as in package-user-dir.

删除包(请参阅包菜单缓冲区)涉及删除相应的包子目录。这仅适用于安装在package-user-dir;中的软件包。如果被告知对系统范围的包目录中的包进行操作,则删除命令会发出错误信号。

Deleting a package (see The Package Menu Buffer) involves deleting the corresponding package subdirectory. This only works for packages installed in package-user-dir; if told to act on a package in a system-wide package directory, the deletion command signals an error.


49.5 获取包源

49.5 Fetching Package Sources

默认情况下,package-install从包存档下载 Tarball 并安装其文件。如果您希望破解软件包源并与其他人共享您的更改,这可能是不够的。在这种情况下,您可能更愿意直接获取并处理上游源。这通常使得开发补丁和报告错误变得更加容易。

By default package-install downloads a Tarball from a package archive and installs its files. This might be inadequate if you wish to hack on the package sources and share your changes with others. In that case, you may prefer to directly fetch and work on the upstream source. This often makes it easier to develop patches and report bugs.

一种方法是使用package-vc-install, 直接从源获取包的源代码。该命令还将自动确保所有文件都经过字节编译并自动加载,就像常规包一样。以这种方式安装的软件包的行为就像任何其他软件包一样。您可以使用package-upgrade或升级它们 package-upgrade-all并使用 再次删除它们package-delete。它们甚至显示在常规包装清单中。如果您只想克隆包的源代码,而不将其添加到包列表中,请使用 package-vc-checkout.

One way to do this is to use package-vc-install, to fetch the source code for a package directly from source. The command will also automatically ensure that all files are byte-compiled and auto-loaded, just like with a regular package. Packages installed this way behave just like any other package. You can upgrade them using package-upgrade or package-upgrade-all and delete them again using package-delete. They are even displayed in the regular package listing. If you just wish to clone the source of a package, without adding it to the package list, use package-vc-checkout.

通过源代码检查,您可能希望针对当前开发头重现错误或实现新功能来解决问题。如果包元数据指示如何联系维护者,您可以使用该命令package-report-bug通过电子邮件报告错误。该报告将包括您自定义的所有用户选项。如果您进行了更改并希望与维护者共享,请首先提交更改,然后使用命令 package-vc-prepare-patch来共享它。请参阅准备补丁

With the source checkout, you might want to reproduce a bug against the current development head or implement a new feature to scratch an itch. If the package metadata indicates how to contact the maintainer, you can use the command package-report-bug to report a bug via Email. This report will include all the user options that you have customized. If you have made a change you wish to share with the maintainers, first commit your changes then use the command package-vc-prepare-patch to share it. See Preparing Patches.

如果您维护自己的软件包,您可能希望使用本地检出而不是克隆远程存储库。您可以使用 来完成此操作,它创建从包目录(请参阅包文件和目录布局package-vc-install-from-checkout)到您的结账的符号链接并初始化代码。请注意,您可能必须使用 重复初始化并更新自动加载。 package-vc-rebuild

If you maintain your own packages you might want to use a local checkout instead of cloning a remote repository. You can do this by using package-vc-install-from-checkout, which creates a symbolic link from the package directory (see Package Files and Directory Layout) to your checkout and initializes the code. Note that you might have to use package-vc-rebuild to repeat the initialization and update the autoloads.

49.5.1 指定包源

49.5.1 Specifying Package Sources

要从源安装包,Emacs 必须知道从哪里获取包的源代码(例如代码存储库)以及有关代码结构的基本信息(例如多文件包中的主文件)。包规范描述了这些属性。

To install a package from source, Emacs must know where to get the package’s source code (such as a code repository) and basic information about the structure of the code (such as the main file in a multi-file package). A package specification describes these properties.

当受到包存档的支持时(请参阅Emacs Lisp 参考手册中的包存档),Emacs 可以自动从所述存档下载包的规范。如果传递给的第一个参数是命名包的符号,那么 Emacs 将使用该包的存档提供的规范。 package-vc-install

When supported by a package archive (see Package Archives in The Emacs Lisp Reference Manual), Emacs can automatically download a package’s specification from said archive. If the first argument passed to package-vc-install is a symbol naming a package, then Emacs will use the specification provided by the archive for that package.

;; Emacs 将从 GNU ELPA 下载 BBDB 的规范:
(包-vc-安装'bbdb)
;; Emacs will download BBDB's specification from GNU ELPA:
(package-vc-install 'bbdb)

第一个参数package-vc-install也可以是包规范。这允许您从用户选项中列出的已知存档之外的位置安装源包 package-archives。包规范是 形式的列表,其中规范应该是使用下表中的任何键的属性列表。 (name . spec)

The first argument to package-vc-install may also be a package specification. This allows you to install source packages from locations other than the known archives listed in the user option package-archives. A package specification is a list of the form (name . spec), in which spec should be a property list using any of the keys in the table below.

有关使用代码存储库和版本控制系统的基本术语的定义,请参阅GNU Emacs 手册中的VCS 概念

For definitions of basic terms for working with code repositories and version control systems, see VCS Concepts in The GNU Emacs Manual.

:url
:url

提供 URL 的字符串,该 URL 指定从中获取包源代码的存储库。

A string providing the URL that specifies the repository from which to fetch the package’s source code.

:branch
:branch

提供要安装的代码修订版本的字符串。不要将其与包的版本号混淆。

A string providing the revision of the code to install. Do not confuse this with a package’s version number.

:lisp-dir
:lisp-dir

一个字符串,提供用于加载 Lisp 源代码的目录的存储库相对名称,默认为存储库的根目录。

A string providing the repository-relative name of the directory to use for loading the Lisp sources, which defaults to the root directory of the repository.

:main-file
:main-file

提供项目主文件的字符串,从中收集包元数据。如果未给出,则默认为附加“.el”的包名称。

A string providing the main file of the project, from which to gather package metadata. If not given, the default is the package name with ".el" appended to it.

:doc
:doc

一个字符串,提供用于构建信息文件的文档文件的存储库相对名称。这可以是 Texinfo 文件或 Org 文件。

A string providing the repository-relative name of the documentation file from which to build an Info file. This can be a Texinfo file or an Org file.

:vc-backend
:vc-backend

命名 VC 后端的符号,用于下载包存储库的副本(请参阅GNU Emacs 手册中的版本控制系统)。如果省略,Emacs 将尝试根据提供的 URL 进行猜测,否则,该过程将回退到 的值。 package-vc-default-backend

A symbol naming the VC backend to use for downloading a copy of the package’s repository (see Version Control Systems in The GNU Emacs Manual). If omitted, Emacs will attempt to make a guess based on the provided URL, or, failing that, the process will fall back onto the value of package-vc-default-backend.

;;手动指定信息:
(包-vc-安装
  '(bbdb :url "https://git.savannah.nongnu.org/git/bbdb.git"
         :lisp-dir "lisp"
         :doc“doc/bbdb.texi”))
;; Specifying information manually:
(package-vc-install
  '(bbdb :url "https://git.savannah.nongnu.org/git/bbdb.git"
         :lisp-dir "lisp"
         :doc "doc/bbdb.texi"))

50 定制

50 Customization

本章介绍一些自定义 Emacs 行为的简单方法。

This chapter describes some simple methods to customize the behavior of Emacs.

除了此处描述的方法之外,请参阅X 选项和资源以获取有关使用 X 资源自定义 Emacs 的信息,并参阅 键盘宏以获取有关记录和重播键盘宏的信息。进行更深远和开放式的改变涉及编写 Emacs Lisp 代码;请参阅 《Emacs Lisp 参考手册》中的Emacs Lisp

Apart from the methods described here, see X Options and Resources for information about using X resources to customize Emacs, and see Keyboard Macros for information about recording and replaying keyboard macros. Making more far-reaching and open-ended changes involves writing Emacs Lisp code; see Emacs Lisp in The Emacs Lisp Reference Manual.


50.1 轻松定制界面

50.1 Easy Customization Interface

Emacs 有许多可以更改的设置。大多数设置都是可自定义的变量(请参阅变量),也称为用户选项。有大量可定制的变量,控制 Emacs 行为的许多方面;本手册中记录的变量列在变量索引中。单独的一类设置是faces,它确定文本的字体、颜色和其他属性(请参阅文本 Faces)。

Emacs has many settings which you can change. Most settings are customizable variables (see Variables), which are also called user options. There is a huge number of customizable variables, controlling numerous aspects of Emacs behavior; the variables documented in this manual are listed in Variable Index. A separate class of settings are the faces, which determine the fonts, colors, and other attributes of text (see Text Faces).

要浏览和更改设置(变量和面),请键入 M-x customize。这将创建一个自定义缓冲区,让您可以浏览按逻辑组织的设置列表、编辑和设置其值,并永久保存它们。

To browse and alter settings (both variables and faces), type M-x customize. This creates a customization buffer, which lets you navigate through a logically organized list of settings, edit and set their values, and save them permanently.


50.1.1 自定义组

50.1.1 Customization Groups

自定义设置被组织成自定义组。这些组被收集成更大的组,一直到一个名为 的主组Emacs

Customization settings are organized into customization groups. These groups are collected into bigger groups, all the way up to a master group called Emacs.

M-x customize创建一个显示顶级Emacs组的自定义缓冲区。部分看起来像这样:

M-x customize creates a customization buffer that shows the top-level Emacs group. It looks like this, in part:

有关使用此缓冲区的帮助,请参阅 [Emacs 手册] 中的 [轻松自定义]。

________________________________________ [ 搜索 ]

 对该缓冲区中的所有设置进行操作:
 [ 恢复... ] [ 应用 ] [ 应用并保存 ]


Emacs 组:One True Editor 的定制。
      【状态】:可见组成员均处于标准值。
      另请参阅[手册]。

[编辑] 基本的文本编辑工具。
[便利] 便利的功能可实现更快的编辑。

...更多二级组...
For help using this buffer, see [Easy Customization] in the [Emacs manual].

________________________________________ [ Search ]

 Operate on all settings in this buffer:
 [ Revert... ] [ Apply ] [ Apply and Save ]


Emacs group: Customization of the One True Editor.
      [State]: visible group members are all at standard values.
      See also [Manual].

[Editing]      Basic text editing facilities.
[Convenience]  Convenience features for faster editing.

...more second-level groups...

该缓冲区的主要部分显示了'Emacs' 自定义组,其中包含其他几个组 ('编辑','方便', ETC。)。这里没有列出这些组的内容,每个组只有一行文档。

The main part of this buffer shows the ‘Emacs’ customization group, which contains several other groups (‘Editing’, ‘Convenience’, etc.). The contents of those groups are not listed here, only one line of documentation each.

组的状态指示该组中的设置是否已被编辑、设置或保存。请参阅更改变量

The state of the group indicates whether setting in that group has been edited, set, or saved. See Changing a Variable.

大多数自定义缓冲区是只读的,但它包括一些 您可以编辑的可编辑字段。例如,自定义缓冲区的顶部是一个用于搜索设置的可编辑字段(请参阅浏览和搜索设置)。还有按钮链接,您可以通过单击鼠标或将点移动到那里并键入来激活它们RET。例如,组名称如 '[编辑]' 是链接;激活这些链接之一会调出该组的自定义缓冲区。

Most of the customization buffer is read-only, but it includes some editable fields that you can edit. For example, at the top of the customization buffer is an editable field for searching for settings (see Browsing and Searching for Settings). There are also buttons and links, which you can activate by either clicking with the mouse, or moving point there and typing RET. For example, the group names like ‘[Editing]’ are links; activating one of these links brings up the customization buffer for that group.

在自定义缓冲区中,您可以键入TAB ( widget-forward) 以前进到下一个按钮或可编辑字段。 ( ) 返回到上一个按钮或可编辑字段。 S-TABwidget-backward

In the customization buffer, you can type TAB (widget-forward) to move forward to the next button or editable field. S-TAB (widget-backward) moves back to the previous button or editable field.


50.1.2 浏览和搜索设置

50.1.2 Browsing and Searching for Settings

从创建的顶级自定义缓冲区中M-x customize,您可以通过链接到达“Emacs' 定制组。这些子组可能包含供您自定义的设置;它们还可能包含更多的子组,处理 Emacs 的更专业的子系统。当您浏览自定义组的层次结构时,您应该会找到一些要自定义的设置。

From the top-level customization buffer created by M-x customize, you can follow the links to the subgroups of the ‘Emacs’ customization group. These subgroups may contain settings for you to customize; they may also contain further subgroups, dealing with yet more specialized subsystems of Emacs. As you navigate the hierarchy of customization groups, you should find some settings that you want to customize.

如果您有兴趣自定义特定设置或自定义组,可以使用命令 M-x customize-optionM-x customize-face或直接进入那里。请参阅自定义特定项目M-x customize-group

If you are interested in customizing a particular setting or customization group, you can go straight there with the commands M-x customize-option, M-x customize-face, or M-x customize-group. See Customizing Specific Items.

如果您不确切知道要自定义哪些组或设置,可以使用每个自定义缓冲区顶部的可编辑搜索字段来搜索它们。在这里,您可以输入搜索词 - 用空格分隔的一个或多个单词,或者正则表达式(请参阅正则表达式的语法)。然后RET在字段中键入,或激活“搜索' 旁边的按钮,切换到包含与这些术语匹配的组和设置的自定义缓冲区。但请注意,此功能仅查找当前 Emacs 会话中加载的组和设置。

If you don’t know exactly what groups or settings you want to customize, you can search for them using the editable search field at the top of each customization buffer. Here, you can type in a search term—either one or more words separated by spaces, or a regular expression (see Syntax of Regular Expressions). Then type RET in the field, or activate the ‘Search’ button next to it, to switch to a customization buffer containing groups and settings that match those terms. Note, however, that this feature only finds groups and settings that are loaded in the current Emacs session.

如果您不希望自定义缓冲区显示搜索字段,请将变量更改custom-search-fieldnil

If you don’t want customization buffers to show the search field, change the variable custom-search-field to nil.

该命令M-x customize-apropos与使用搜索字段类似,不同之处在于它使用迷你缓冲区读取搜索词。请参阅自定义特定项目

The command M-x customize-apropos is similar to using the search field, except that it reads the search term(s) using the minibuffer. See Customizing Specific Items.

M-x customize-browse是浏览可用设置的另一种方式。此命令创建一个特殊的自定义缓冲区,它以结构化布局仅显示组和设置的名称。您可以通过调用 ' 在同一缓冲区中显示组的内容[+]' 组名称旁边的按钮。当显示组内容时,按钮变为“[-]';调用再次隐藏组内容。该缓冲区中的每个组或设置都有一个链接,上面写着“[团体]','[选项]' 或者 '[脸]'。调用此链接会创建一个普通的自定义缓冲区,仅显示该组、选项或面孔;这是更改您使用 找到的设置的方法M-x customize-browse

M-x customize-browse is another way to browse the available settings. This command creates a special customization buffer, which shows only the names of groups and settings, in a structured layout. You can show the contents of a group, in the same buffer, by invoking the ‘[+]’ button next to the group name. When the group contents are shown, the button changes to ‘[-]’; invoking that hides the group contents again. Each group or setting in this buffer has a link which says ‘[Group]’, ‘[Option]’ or ‘[Face]’. Invoking this link creates an ordinary customization buffer showing just that group, option, or face; this is the way to change settings that you find with M-x customize-browse.


50.1.3 更改变量

50.1.3 Changing a Variable

以下是自定义缓冲区中变量或用户选项的示例:

Here is an example of what a variable, or user option, looks like in the customization buffer:

[隐藏]杀戮环最大:整数(正或零):120
   【状态】:标准。
   最旧元素被丢弃之前杀戮环的最大长度。
[Hide] Kill Ring Max: Integer (positive or zero): 120
   [State]: STANDARD.
   Maximum length of kill ring before oldest elements are thrown away.

第一行显示变量名为 kill-ring-max,格式为 '杀环最大' 以便于查看,并且还显示其预期类型:正整数或零。默认值为 '120'。标记为 ' 的按钮[隐藏]',如果激活,则隐藏变量的值和状态;这对于避免非常长的值使自定义缓冲区变得混乱非常有用(因此,具有很长值的变量可能会开始隐藏)。如果您使用 '[隐藏]' 按钮,它变为 '[显示价值]',您可以激活它以显示值和状态。在图形显示上,'[隐藏]' 和 '[显示价值]' 按钮被替换为分别指向向下和向右的图形三角形。

The first line shows that the variable is named kill-ring-max, formatted as ‘Kill Ring Max’ for easier viewing, and also shows its expected type: a positive integer or zero. The default value is ‘120’. The button labeled ‘[Hide]’, if activated, hides the variable’s value and state; this is useful to avoid cluttering up the customization buffer with very long values (for this reason, variables that have very long values may start out hidden). If you use the ‘[Hide]’ button, it changes to ‘[Show Value]’, which you can activate to reveal the value and state. On a graphical display, the ‘[Hide]’ and ‘[Show Value]’ buttons are replaced with graphical triangles pointing downwards and rightwards respectively.

变量名称后面的行表示变量的自定义状态:在此示例中,'标准' 表示您尚未更改该变量,因此其值是默认值。这 '[状态]' 按钮提供用于自定义变量的操作菜单。

The line after the variable name indicates the customization state of the variable: in this example, ‘STANDARD’ means you have not changed the variable, so its value is the default one. The ‘[State]’ button gives a menu of operations for customizing the variable.

自定义状态下方是变量的文档。这与命令显示的文档相同C-h v (请参阅检查和设置变量)。如果文档长度超过一行,则只能显示一行。如果是这样,该行以 ' 结尾[更多的]' 按钮;激活它以查看完整的文档。

Below the customization state is the documentation for the variable. This is the same documentation that would be shown by the C-h v command (see Examining and Setting Variables). If the documentation is more than one line long, only one line may be shown. If so, that line ends with a ‘[More]’ button; activate this to see the full documentation.

要为 ' 输入新值杀环最大',只需将指针移至该值并对其进行编辑即可。例如,键入M-d删除 '60'并输入另一个数字。当您开始更改文本时,'[状态]' 行将会改变:

To enter a new value for ‘Kill Ring Max’, just move point to the value and edit it. For example, type M-d to delete the ‘60’ and type in another number. As you begin to alter the text, the ‘[State]’ line will change:

[状态]:已编辑,显示的值只有在您同意后才会生效
         设置或保存。
[State]: EDITED, shown value does not take effect until you
         set or save it.

编辑该值不会使其立即生效。为此,您必须通过激活'[状态]'按钮并选择'设置为当前会话'。那么变量的状态就变成:

Editing the value does not make it take effect right away. To do that, you must set the variable by activating the ‘[State]’ button and choosing ‘Set for Current Session’. Then the variable’s state becomes:

[状态]:仅针对当前会话设置。
[State]: SET for current session only.

您不必担心指定的值无效;这 '设置为当前会话' 操作检查有效性并且不会安装不可接受的值。

You don’t have to worry about specifying a value that is not valid; the ‘Set for Current Session’ operation checks for validity and will not install an unacceptable value.

在编辑某些类型的值(例如文件名、目录名和 Emacs 命令名)时,您可以使用 C-M-i( widget-complete) 或等效键 或执行补全。这与迷你缓冲区完成非常相似(请参阅完成)。 M-TABESC TAB

While editing certain kinds of values, such as file names, directory names, and Emacs command names, you can perform completion with C-M-i (widget-complete), or the equivalent keys M-TAB or ESC TAB. This behaves much like minibuffer completion (see Completion).

RET在可编辑值字段上键入会将点向前移动到下一个字段或按钮,例如TAB。因此,您可以RET在完成编辑字段后键入内容,以移至下一个按钮或字段。要在可编辑字段中插入换行符,请使用C-oC-q C-j

Typing RET on an editable value field moves point forward to the next field or button, like TAB. You can thus type RET when you are finished editing a field, to move on to the next button or field. To insert a newline within an editable field, use C-o or C-q C-j.

对于某些变量,只有一组固定的合法值,并且不允许直接编辑该值。相反,一个 '[超值菜单]' 按钮出现在值之前;激活此按钮可以选择值。对于布尔“开或关”值,按钮显示“[切换]',并翻转该值。使用后 '[超值菜单]' 或者 '[切换]' 按钮后,必须再次设置变量才能使所选值生效。

For some variables, there is only a fixed set of legitimate values, and you are not allowed to edit the value directly. Instead, a ‘[Value Menu]’ button appears before the value; activating this button presents a choice of values. For a boolean “on or off” value, the button says ‘[Toggle]’, and flips the value. After using the ‘[Value Menu]’ or ‘[Toggle]’ button, you must again set the variable to make the chosen value take effect.

有些变量的值具有复杂的结构。例如, 的值为minibuffer-frame-alist关联列表。以下是它在自定义缓冲区中的显示方式:

Some variables have values with complex structure. For example, the value of minibuffer-frame-alist is an association list. Here is how it appears in the customization buffer:

[隐藏] 迷你缓冲区帧列表:
[INS] [DEL] 参数:宽度
            价值:80
[INS] [DEL] 参数:高度
            值:2
[INS]
   [状态]:标准。
   初始迷你缓冲区帧的参数列表。 [隐藏]
   [...更多行文档...]
[Hide] Minibuffer Frame Alist:
[INS] [DEL] Parameter: width
            Value: 80
[INS] [DEL] Parameter: height
            Value: 2
[INS]
   [ State ]: STANDARD.
   Alist of parameters for the initial minibuffer frame. [Hide]
   […more lines of documentation…]

在这种情况下,列表中的每个关联都包含两项,其中一项标记为 '范围' 和一个标有 '价值';两者都是可编辑字段。您可以使用 ' 从列表中删除关联[删除]' 旁边的按钮。要添加关联,请使用 '[INS]' 按钮位于您要插入的位置;最后的'[INS]' 按钮插入到列表末尾。

In this case, each association in the list consists of two items, one labeled ‘Parameter’ and one labeled ‘Value’; both are editable fields. You can delete an association from the list with the ‘[DEL]’ button next to it. To add an association, use the ‘[INS]’ button at the position where you want to insert it; the very last ‘[INS]’ button inserts at the end of the list.

当您设置变量时,新值仅在当前 Emacs 会话中生效。要为将来的会话保存该值,请使用 '[状态]' 按钮并选择 '为未来的会议保存' 手术。请参阅保存自定义

When you set a variable, the new value takes effect only in the current Emacs session. To save the value for future sessions, use the ‘[State]’ button and select the ‘Save for Future Sessions’ operation. See Saving Customizations.

您还可以使用 ' 将变量恢复为其标准值[状态]' 按钮并选择 '删除自定义' 手术。实际上有四种复位操作:

You can also restore the variable to its standard value by using the ‘[State]’ button and selecting the ‘Erase Customization’ operation. There are actually four reset operations:

'撤消编辑'
Undo Edits

如果您已修改但尚未设置变量,则会恢复自定义缓冲区中的文本以匹配实际值。

If you have modified but not yet set the variable, this restores the text in the customization buffer to match the actual value.

'恢复此会话的自定义'
Revert This Session's Customizations

这会将变量的值恢复为最后保存的值(如果有)。否则恢复标准值。它相应地更新文本。

This restores the value of the variable to the last saved value, if there was one. Otherwise it restores the standard value. It updates the text accordingly.

'删除自定义'
Erase Customization

这会将变量设置为其标准值。您所拥有的任何节省的价值也将被消除。

This sets the variable to its standard value. Any saved value that you have is also eliminated.

'设置为备份值'
Set to Backup Value

这会将变量设置为此会话中自定义缓冲区中设置的先前值。如果你自定义了一个变量,然后重置它,这会丢弃自定义的值,通过此操作可以再次取回丢弃的值。

This sets the variable to a previous value that was set in the customization buffer in this session. If you customize a variable and then reset it, which discards the customized value, you can get the discarded value back again with this operation.

有时记录有关特定定制的评论很有用。使用 '添加评论' 项目来自 '[状态]' 菜单创建一个用于输入评论的字段。

Sometimes it is useful to record a comment about a specific customization. Use the ‘Add Comment’ item from the ‘[State]’ menu to create a field for entering the comment.

自定义缓冲区顶部附近有两行按钮:

Near the top of the customization buffer are two lines of buttons:

对该缓冲区中的所有设置进行操作:
 [恢复...] [应用] [应用并保存]
 Operate on all settings in this buffer:
 [Revert...] [Apply] [Apply and Save]

这 '[恢复...]' 按钮会弹出一个菜单,其中包含上述前 3 个重置操作。这 '[申请]' 按钮应用当前会话的设置。这 '[应用并保存]' 按钮应用设置并保存它们以供将来的会话使用;如果 Emacs 是用以下命令启动的,则不会出现此按钮-q或者 -Q选项(请参阅初始选项)。

The ‘[Revert...]’ button drops a menu with the first 3 reset operations described above. The ‘[Apply]’ button applies the settings for the current session. The ‘[Apply and Save]’ button applies the settings and saves them for future sessions; this button does not appear if Emacs was started with the -q or -Q option (see Initial Options).

命令C-c C-c( Custom-set) 相当于使用 '[设置为当前会话]' 按钮。命令C-x C-s( Custom-save) 就像使用 '[保存以供将来的会议使用]' 按钮。

The command C-c C-c (Custom-set) is equivalent to using the ‘[Set for Current Session]’ button. The command C-x C-s (Custom-save) is like using the ‘[Save for Future Sessions]’ button.

这 '[出口]' 按钮切换出自定义缓冲区,并将缓冲区埋入缓冲区列表的底部。要使其终止自定义缓冲区,请将变量更改 custom-buffer-done-killt

The ‘[Exit]’ button switches out of the customization buffer, and buries the buffer at the bottom of the buffer list. To make it kill the customization buffer instead, change the variable custom-buffer-done-kill to t.


50.1.4 保存自定义

50.1.4 Saving Customizations

在自定义缓冲区中,您可以通过选择“保存自定义设置”为未来的会议保存'从中选择'[状态]' 按钮。C-x C-s( )命令Custom-save,或 '[应用并保存]' 自定义缓冲区顶部的按钮,将所有适用的设置保存在缓冲区中。

In the customization buffer, you can save a customization setting by choosing the ‘Save for Future Sessions’ choice from its ‘[State]’ button. The C-x C-s (Custom-save) command, or the ‘[Apply and Save]’ button at the top of the customization buffer, saves all applicable settings in the buffer.

通过将代码写入文件(通常是初始化文件)来保存工作(请参阅Emacs 初始化文件)。未来的 Emacs 会话会在启动时自动读取此文件,从而再次设置自定义。

Saving works by writing code to a file, usually your initialization file (see The Emacs Initialization File). Future Emacs sessions automatically read this file at startup, which sets up the customizations again.

您可以选择将自定义保存在初始化文件以外的位置。要实现此功能,您必须在初始化文件中添加几行代码,将变量设置 custom-file为所需文件的名称,并加载该文件。例如:

You can choose to save customizations somewhere other than your initialization file. To make this work, you must add a couple of lines of code to your initialization file, to set the variable custom-file to the name of the desired file, and to load that file. For example:

(setq 自定义文件“~/.config/emacs-custom.el”)
(加载自定义文件)
(setq custom-file "~/.config/emacs-custom.el")
(load custom-file)

您甚至可以为不同的 Emacs 版本指定不同的自定义文件,如下所示:

You can even specify different customization files for different Emacs versions, like this:

(cond ((< emacs-主要版本 28)
       ;; Emacs 27 定制。
       (setq 自定义文件“~/.config/custom-27.el”))
      ((和(= emacs-主要版本 26)
            (< emacs-次要版本 3))
       ;; Emacs 26 定制,26.3 版本之前。
       (setq 自定义文件“~/.config/custom-26.el”))
      (t
       ;; Emacs 版本 28.1 或更高版本。
       (setq 自定义文件“~/.config/emacs-custom.el”)))

(加载自定义文件)
(cond ((< emacs-major-version 28)
       ;; Emacs 27 customization.
       (setq custom-file "~/.config/custom-27.el"))
      ((and (= emacs-major-version 26)
            (< emacs-minor-version 3))
       ;; Emacs 26 customization, before version 26.3.
       (setq custom-file "~/.config/custom-26.el"))
      (t
       ;; Emacs version 28.1 or later.
       (setq custom-file "~/.config/emacs-custom.el")))

(load custom-file)

如果使用以下命令调用 Emacs-q或者--无初始化文件 选项(请参阅初始选项),它不会让您将自定义保存在初始化文件中。这是因为从此类会话中保存自定义设置会清除初始化文件中可能拥有的所有其他自定义设置。

If Emacs was invoked with the -q or --no-init-file options (see Initial Options), it will not let you save your customizations in your initialization file. This is because saving customizations from such a session would wipe out all the other customizations you might have on your initialization file.

请注意,当您终止 Emacs 时,您未选择为将来的会话保存的任何自定义设置都将丢失。如果您希望在终止时收到有关未保存自定义的提示,请将以下内容添加到您的初始化文件中:

Please note that any customizations you have not chosen to save for future sessions will be lost when you terminate Emacs. If you’d like to be prompted about unsaved customizations at termination time, add the following to your initialization file:

(添加钩子'kill-emacs-query-functions
          '自定义提示自定义未保存选项)
(add-hook 'kill-emacs-query-functions
          'custom-prompt-customize-unsaved-options)

50.1.5 自定义面

50.1.5 Customizing Faces

您可以自定义外观(请参阅文本外观),这决定了 Emacs 如何显示不同类型的文本。自定义组可以包含变量和面。

You can customize faces (see Text Faces), which determine how Emacs displays different types of text. Customization groups can contain both variables and faces.

例如,在编程语言模式中,源代码注释显示为font-lock-comment-face(请参阅字体锁定模式)。在自定义缓冲区中,单击“[显示所有属性]' 关联:

For example, in programming language modes, source code comments are shown with font-lock-comment-face (see Font Lock mode). In a customization buffer, that face appears like this, after you click on the ‘[Show All Attributes]’ link:

[隐藏]字体锁定评论面:[示例]
   [状态]:标准。
   字体锁定模式用于突出显示注释。
   [ ] 字体系列:  - 
   [ ] 字体铸造厂:--
   [ ] 宽度:  - 
   [ ] 高度:  - 
   [ ] 重量:  - 
   [ ] 倾斜:--
   [ ] 下划线:--
   [ ] 上划线:--
   [ ] 删除线:--
   [ ] 文本周围的框:--
   [ ] 反视频:--
   [X] 前景:Firebrick [选择](示例)
   [ ] 背景:  - 
   [ ] 点画:--
   [ ] 继承:--
   [隐藏未使用的属性]
[Hide] Font Lock Comment Face:[sample]
   [State] : STANDARD.
   Font Lock mode face used to highlight comments.
   [ ] Font Family: --
   [ ] Font Foundry: --
   [ ] Width: --
   [ ] Height: --
   [ ] Weight: --
   [ ] Slant: --
   [ ] Underline: --
   [ ] Overline: --
   [ ] Strike-through: --
   [ ] Box around text: --
   [ ] Inverse-video: --
   [X] Foreground: Firebrick     [Choose]  (sample)
   [ ] Background: --
   [ ] Stipple: --
   [ ] Inherit: --
   [Hide Unused Attributes]

前三行显示名称,'[状态]' 按钮,以及面部的文档。下面是面部属性列表。每个属性前面都有一个复选框。一个已填充的复选框,'[X]', 表示该面指定了该属性的值;一个空的复选框,'[ ]',意味着该面没有为该属性指定任何特殊值。您可以激活复选框来指定或取消指定其属性。

The first three lines show the name, ‘[State]’ button, and documentation for the face. Below that is a list of face attributes. In front of each attribute is a checkbox. A filled checkbox, ‘[X]’, means that the face specifies a value for this attribute; an empty checkbox, ‘[ ]’, means that the face does not specify any special value for the attribute. You can activate a checkbox to specify or unspecify its attribute.

面孔不必指定每一个属性;事实上,大多数面孔只指定了一些属性。在上面的示例中, font-lock-comment-face仅指定前景色。任何未指定的属性均取自名为 的特殊面 default,其属性均已指定。该 default面是用于显示任何没有显式指定面的文本的面;此外,其背景颜色属性作为框架的背景颜色。

A face does not have to specify every single attribute; in fact, most faces only specify a few attributes. In the above example, font-lock-comment-face only specifies the foreground color. Any unspecified attribute is taken from the special face named default, whose attributes are all specified. The default face is the face used to display any text that does not have an explicitly-assigned face; furthermore, its background color attribute serves as the background color of the frame.

这 '[隐藏未使用的属性]' 按钮位于属性列表的末尾,隐藏脸部未指定的属性。当属性被隐藏时,按钮变为“[显示所有属性]',它显示了整个属性列表。定制缓冲区可能会以隐藏的未指定属性开始,以避免界面混乱。

The ‘[Hide Unused Attributes]’ button, at the end of the attribute list, hides the unspecified attributes of the face. When attributes are being hidden, the button changes to ‘[Show All Attributes]’, which reveals the entire attribute list. The customization buffer may start out with unspecified attributes hidden, to avoid cluttering the interface.

指定属性后,您可以按照通常的方式更改其值。

When an attribute is specified, you can change its value in the usual ways.

可以使用颜色名称或 RGB 三元组指定前景色和背景色(请参阅面的颜色)。您还可以使用 '[选择]' 按钮切换到颜色名称列表;在该缓冲区中选择一种颜色,RET将颜色名称放入值字段中。

Foreground and background colors can be specified using either color names or RGB triplets (see Colors for Faces). You can also use the ‘[Choose]’ button to switch to a list of color names; select a color with RET in that buffer to put the color name in the value field.

设置、保存和重置面的工作方式与变量操作相同(请参阅更改变量)。

Setting, saving and resetting a face work like the same operations for variables (see Changing a Variable).

面可以为不同类型的显示器指定不同的外观。例如,面部可以在彩色显示器上使文本变为红色,但在单色显示器上使用粗体字体。要指定一个面的多个外观,请选择“适用于各种显示器'在您通过调用获得的菜单中'[状态]'。

A face can specify different appearances for different types of displays. For example, a face can make text red on a color display, but use a bold font on a monochrome display. To specify multiple appearances for a face, select ‘For All Kinds of Displays’ in the menu you get from invoking ‘[State]’.


50.1.6 定制特定项目

50.1.6 Customizing Specific Items

M-x customize-option RET option RET
M-x customize-option RET option RET
M-x customize-variable RET option RET
M-x customize-variable RET option RET

仅为一个用户选项option设置自定义缓冲区。

Set up a customization buffer for just one user option, option.

M-x customize-face RET face RET
M-x customize-face RET face RET

仅为一张脸( face)设置自定义缓冲区。

Set up a customization buffer for just one face, face.

M-x customize-icon RET face RET
M-x customize-icon RET face RET

仅为一个图标icon设置自定义缓冲区。

Set up a customization buffer for just one icon, icon.

M-x customize-group RET group RET
M-x customize-group RET group RET

仅为一个组group设置自定义缓冲区。

Set up a customization buffer for just one group, group.

M-x customize-apropos RET regexp RET
M-x customize-apropos RET regexp RET

为与regexp匹配的所有设置和组设置自定义缓冲区。

Set up a customization buffer for all the settings and groups that match regexp.

M-x customize-changed RET version RET
M-x customize-changed RET version RET

设置一个自定义缓冲区,其中包含自 Emacs 版本以来(或之后添加的)含义已更改的所有用户选项、面孔和

Set up a customization buffer with all the user options, faces and groups whose meaning has changed since (or been added after) Emacs version version.

M-x customize-saved
M-x customize-saved

设置自定义缓冲区,其中包含使用自定义缓冲区保存的所有设置。

Set up a customization buffer containing all settings that you have saved with customization buffers.

M-x customize-unsaved
M-x customize-unsaved

设置一个自定义缓冲区,其中包含您已设置但未保存的所有设置。

Set up a customization buffer containing all settings that you have set but not saved.

如果您想自定义特定的用户选项,请键入M-x customize-option。这会读取变量名称,并仅使用该一个用户选项设置自定义缓冲区。当将变量名称输入到迷你缓冲区时,可以使用补全功能,但仅限于已加载到 Emacs 中的变量名称。

If you want to customize a particular user option, type M-x customize-option. This reads the variable name, and sets up the customization buffer with just that one user option. When entering the variable name into the minibuffer, completion is available, but only for the names of variables that have been loaded into Emacs.

同样,您可以使用 自定义特定的面孔M-x customize-face。您可以使用 为特定自定义组设置自定义缓冲区M-x customize-group

Likewise, you can customize a specific face using M-x customize-face. You can set up a customization buffer for a specific customization group using M-x customize-group.

M-x customize-apropos提示输入搜索词(由空格分隔的一个或多个单词或正则表达式),并为所有加载的设置和具有匹配名称的组设置自定义缓冲区。这就像使用自定义缓冲区顶部的搜索字段(请参阅自定义组)。

M-x customize-apropos prompts for a search term—either one or more words separated by spaces, or a regular expression—and sets up a customization buffer for all loaded settings and groups with matching names. This is like using the search field at the top of the customization buffer (see Customization Groups).

当您升级到新的 Emacs 版本时,您可能需要考虑自定义新设置以及含义或默认值已更改的设置。为此,请使用M-x customize-changed迷你缓冲区并指定以前的 Emacs 版本号。它创建一个自定义缓冲区,显示自指定版本以来其定义已更改的所有设置和组,并在必要时加载它们。

When you upgrade to a new Emacs version, you might want to consider customizing new settings, and settings whose meanings or default values have changed. To do this, use M-x customize-changed and specify a previous Emacs version number using the minibuffer. It creates a customization buffer which shows all the settings and groups whose definitions have been changed since the specified version, loading them if necessary.

如果您更改设置,然后确定更改是错误的,则可以使用两个命令来重新访问您的更改。用于M-x customize-saved自定义您已保存的设置。用于 M-x customize-unsaved自定义您已设置但未保存的设置。

If you change settings and then decide the change was a mistake, you can use two commands to revisit your changes. Use M-x customize-saved to customize settings that you have saved. Use M-x customize-unsaved to customize settings that you have set but not saved.


50.1.7 自定义主题

50.1.7 Custom Themes

自定义主题是可以作为一个单元启用或禁用的设置的集合。您可以使用自定义主题在各种设置集合之间轻松切换,并将此类集合从一台计算机传输到另一台计算机。

Custom themes are collections of settings that can be enabled or disabled as a unit. You can use Custom themes to switch easily between various collections of settings, and to transfer such collections from one computer to another.

自定义主题存储为 Emacs Lisp 源文件。如果自定义主题的名称为name,则主题文件名为 名称-theme.el。有关主题文件的格式以及如何制作主题文件的信息, 请参阅创建自定义主题。

A Custom theme is stored as an Emacs Lisp source file. If the name of the Custom theme is name, the theme file is named name-theme.el. See Creating Custom Themes, for the format of a theme file and how to make one.

键入M-x customize-themes以切换到名为的缓冲区 *自定义主题*,其中列出了 Emacs 知道的自定义主题。默认情况下,Emacs 在两个位置查找主题文件: 变量指定的目录custom-theme-directory (默认为〜/.emacs.d/),以及一个名为 等/主题在您的 Emacs 安装中(请参阅变量 data-directory)。后者包含几个随 Emacs 一起分发的自定义主题,这些主题可以自定义 Emacs 的外观以适应各种配色方案。 (但是请注意,自定义主题不必限于此目的;它们也可以用于自定义变量。)

Type M-x customize-themes to switch to a buffer named *Custom Themes*, which lists the Custom themes that Emacs knows about. By default, Emacs looks for theme files in two locations: the directory specified by the variable custom-theme-directory (which defaults to ~/.emacs.d/), and a directory named etc/themes in your Emacs installation (see the variable data-directory). The latter contains several Custom themes distributed with Emacs that customize Emacs’s faces to fit various color schemes. (Note, however, that Custom themes need not be restricted to this purpose; they can be used to customize variables too.)

如果您希望 Emacs 在其他目录中查找自定义主题,请将该目录添加到 list 变量中 custom-theme-load-path。它的默认值是 (custom-theme-directory t);这里的符号 custom-theme-directory有变量值的特殊含义custom-theme-directory,而t代表内置主题目录等/主题。中列出的主题*自定义主题*buffer 是在 指定的目录中找到的内容custom-theme-load-path

If you want Emacs to look for Custom themes in some other directory, add the directory to the list variable custom-theme-load-path. Its default value is (custom-theme-directory t); here, the symbol custom-theme-directory has the special meaning of the value of the variable custom-theme-directory, while t stands for the built-in theme directory etc/themes. The themes listed in the *Custom Themes* buffer are those found in the directories specified by custom-theme-load-path.

在里面*自定义主题*缓冲区中,您可以激活自定义主题旁边的复选框来启用或禁用当前 Emacs 会话的主题。启用自定义主题后,其所有设置(变量和界面)都会在 Emacs 会话中生效。要将主题的选择应用到将来的 Emacs 会话,请键入C-x C-s ( custom-theme-save) 或使用 '[保存主题设置]' 按钮。

In the *Custom Themes* buffer, you can activate the checkbox next to a Custom theme to enable or disable the theme for the current Emacs session. When a Custom theme is enabled, all of its settings (variables and faces) take effect in the Emacs session. To apply the choice of theme(s) to future Emacs sessions, type C-x C-s (custom-theme-save) or use the ‘[Save Theme Settings]’ button.

当您第一次启用自定义主题时,Emacs 会显示主题文件的内容并询问您是否确实要加载它。因为加载自定义主题可以执行任意 Lisp 代码,所以只有在您知道该主题是安全的情况下才应该说“是”;在这种情况下,Emacs 会在将来记住主题是安全的(这是通过将主题文件的 SHA-256 哈希值保存到变量 来完成的 custom-safe-themes;如果您想将所有主题视为安全的,请将其值更改为t)。 Emacs 附带的主题(在 等/主题目录)不受此检查,并且始终被认为是安全的。

When you first enable a Custom theme, Emacs displays the contents of the theme file and asks if you really want to load it. Because loading a Custom theme can execute arbitrary Lisp code, you should only say yes if you know that the theme is safe; in that case, Emacs offers to remember in the future that the theme is safe (this is done by saving the theme file’s SHA-256 hash to the variable custom-safe-themes; if you want to treat all themes as safe, change its value to t). Themes that come with Emacs (in the etc/themes directory) are exempt from this check, and are always considered safe.

设置或保存自定义主题实际上是通过自定义变量来实现的custom-enabled-themes。该变量的值是自定义主题名称的列表(作为 Lisp 符号,例如tango)。而不是使用*自定义主题*buffer 来设置 custom-enabled-themes,您可以使用通常的自定义接口自定义变量,例如,使用M-x customize-option.请注意,自定义主题不允许 custom-enabled-themes自行设置。

Setting or saving Custom themes actually works by customizing the variable custom-enabled-themes. The value of this variable is a list of Custom theme names (as Lisp symbols, e.g., tango). Instead of using the *Custom Themes* buffer to set custom-enabled-themes, you can customize the variable using the usual customization interface, e.g., with M-x customize-option. Note that Custom themes are not allowed to set custom-enabled-themes themselves.

您通过自定义缓冲区进行的任何自定义都优先于主题设置。这使您可以轻松覆盖您不同意的各个主题设置。如果两个不同主题的设置重叠,则较早出现的主题 custom-enabled-themes优先。在自定义缓冲区中,如果自定义主题已更改设置的默认设置,则其“状态'显示显示'主题' 代替 '标准'。

Any customizations that you make through the customization buffer take precedence over theme settings. This lets you easily override individual theme settings that you disagree with. If settings from two different themes overlap, the theme occurring earlier in custom-enabled-themes takes precedence. In the customization buffer, if a setting has been changed from its default by a Custom theme, its ‘State’ display shows ‘THEMED’ instead of ‘STANDARD’.

您可以通过键入 来在当前 Emacs 会话中启用特定的自定义主题M-x load-theme。这会提示输入主题名称,从主题文件加载主题并启用它。如果之前已加载主题文件,您可以通过键入 来启用主题而无需加载其文件M-x enable-theme。要禁用自定义主题,请键入M-x disable-theme

You can enable a specific Custom theme in the current Emacs session by typing M-x load-theme. This prompts for a theme name, loads the theme from the theme file, and enables it. If a theme file has been loaded before, you can enable the theme without loading its file by typing M-x enable-theme. To disable a Custom theme, type M-x disable-theme.

要查看自定义主题的描述,请?在其行中键入*自定义主题*缓冲;或者M-x describe-theme 在 Emacs 中的任意位置键入并输入主题名称。

To see a description of a Custom theme, type ? on its line in the *Custom Themes* buffer; or type M-x describe-theme anywhere in Emacs and enter the theme name.

有些主题有变体(通常只有两种:浅色和深色)。您可以使用 切换到另一个变体M-x theme-choose-variant。如果当前活动主题只有一种其他变体,则会选择该变体;如果有更多变体,该命令将提示您切换到哪一种。

Some themes have variants (most often just two: light and dark). You can switch to another variant using M-x theme-choose-variant. If the currently active theme has only one other variant, it will be selected; if there are more variants, the command will prompt you which one to switch to.

请注意,theme-choose-variant仅当单个主题处于活动状态时才有效。

Note that theme-choose-variant only works if a single theme is active.


50.1.8 创建自定义主题

50.1.8 Creating Custom Themes

您可以通过键入 来使用类似于自定义缓冲区的界面来定义自定义主题M-x customize-create-theme。这会切换到名为的缓冲区*自定义主题*。它还可以将一些常见的 Emacs 界面插入到主题中(很方便,因为自定义主题通常用于自定义界面)。如果您回答“否”,则主题最初将不包含任何设置。

You can define a Custom theme using an interface similar to the customization buffer, by typing M-x customize-create-theme. This switches to a buffer named *Custom Theme*. It also offers to insert some common Emacs faces into the theme (a convenience, since Custom themes are often used to customize faces). If you answer no, the theme will initially contain no settings.

靠近顶部的*自定义主题*缓冲区中,有可编辑字段,您可以在其中输入主题的名称和描述。该名称可以是除 ' 之外的任何名称用户'。描述是当您调用M-x describe-theme主题时将显示的描述。第一行应该是一个简短的一句话总结;在 制作的缓冲区中M-x customize-themes,这句话显示在主题名称旁边。

Near the top of the *Custom Theme* buffer, there are editable fields where you can enter the theme’s name and description. The name can be anything except ‘user’. The description is the one that will be shown when you invoke M-x describe-theme for the theme. Its first line should be a brief one-sentence summary; in the buffer made by M-x customize-themes, this sentence is displayed next to the theme name.

要向主题添加新设置,请使用 '[插入附加面]' 或者 '[插入附加变量]' 纽扣。每个按钮使用迷你缓冲区读取面或变量名称并完成,并插入面或变量的自定义条目。您可以像在普通自定义缓冲区中一样编辑变量值或面属性。要从主题中删除面孔或变量,请取消选中其名称旁边的复选框。

To add a new setting to the theme, use the ‘[Insert Additional Face]’ or ‘[Insert Additional Variable]’ buttons. Each button reads a face or variable name using the minibuffer, with completion, and inserts a customization entry for the face or variable. You can edit the variable values or face attributes in the same way as in a normal customization buffer. To remove a face or variable from the theme, uncheck the checkbox next to its name.

指定自定义主题的外观和变量后,输入 C-x C-s( custom-theme-write) 或使用缓冲区的 '[保存主题]' 按钮。这将保存主题文件,名为 名称-theme.el其中name是主题名称,位于名为 的目录中custom-theme-directory

After specifying the Custom theme’s faces and variables, type C-x C-s (custom-theme-write) or use the buffer’s ‘[Save Theme]’ button. This saves the theme file, named name-theme.el where name is the theme name, in the directory named by custom-theme-directory.

来自*自定义主题*缓冲区,您可以通过激活“查看和编辑现有的自定义主题”[参观主题]' 按钮并指定主题名称。您还可以使用 ' 将另一个主题的设置添加到缓冲区中[合并主题]' 按钮。您可以使用 ' 将非主题设置导入自定义主题[合并主题]' 按钮并指定名为 ' 的特殊主题用户'。

From the *Custom Theme* buffer, you can view and edit an existing Custom theme by activating the ‘[Visit Theme]’ button and specifying the theme name. You can also add the settings of another theme into the buffer, using the ‘[Merge Theme]’ button. You can import your non-theme settings into a Custom theme by using the ‘[Merge Theme]’ button and specifying the special theme named ‘user’.

主题文件只是一个 Emacs Lisp 源文件,通过加载 Lisp 文件来加载自定义主题。因此,您可以直接编辑主题文件,而不是使用*自定义主题* 缓冲。有关详细信息,请参阅Emacs Lisp 参考手册中的自定义主题

A theme file is simply an Emacs Lisp source file, and loading the Custom theme works by loading the Lisp file. Therefore, you can edit a theme file directly instead of using the *Custom Theme* buffer. See Custom Themes in The Emacs Lisp Reference Manual, for details.


50.2 变量

50.2 Variables

变量一个具有值的 Lisp 符号。符号的名称也称为变量名称。变量名称可以包含文件中出现的任何字符,但大多数变量名称由连字符分隔的普通单词组成。

A variable is a Lisp symbol which has a value. The symbol’s name is also called the variable name. A variable name can contain any characters that can appear in a file, but most variable names consist of ordinary words separated by hyphens.

变量的名称是对其作用的简洁描述。大多数变量还有一个文档字符串,它描述了变量的用途、它应该具有什么样的值以及如何使用该值。您可以使用帮助命令C-h v( describe-variable) 查看此文档。请参阅检查和设置变量

The name of the variable serves as a compact description of its role. Most variables also have a documentation string, which describes what the variable’s purpose is, what kind of value it should have, and how the value will be used. You can view this documentation using the help command C-h v (describe-variable). See Examining and Setting Variables.

Emacs 使用许多 Lisp 变量来保存内部记录,但对于非程序员用户来说,最有趣的变量是那些供用户更改的变量 — 这些变量称为可自定义变量用户选项(请参阅轻松自定义界面)。在下面的部分中,我们将描述 Emacs 变量的其他方面,例如如何在自定义之外设置它们。

Emacs uses many Lisp variables for internal record keeping, but the most interesting variables for a non-programmer user are those meant for users to change—these are called customizable variables or user options (see Easy Customization Interface). In the following sections, we will describe other aspects of Emacs variables, such as how to set them outside Customize.

Emacs Lisp 允许任何变量(除了少数例外)具有任何类型的值。然而,许多变量只有在指定特定类型的值时才有意义。例如,只有数字才是有意义的值kill-ring-max,它指定了 Kill Ring 的最大长度(请参阅Yanking Early Kills);如果您给出 kill-ring-max一个字符串值,诸如C-y ( yank) 之类的命令将发出错误信号。另一方面,有些变量不关心类型;例如,如果一个变量对 nil值有一种影响,对非nil值有另一种影响,那么任何不是符号的值nil都会引起第二种影响,无论其类型如何(按照惯例,我们通常使用值t- 代表的符号)对于“true”——指定一个非值nil)。如果您使用自定义缓冲区设置变量,则无需担心为其指定无效类型:自定义缓冲区通常只允许您输入有意义的值。如有疑问,请使用C-h v( describe-variable) 检查变量的文档字符串以查看其所需的值类型(请参阅检查和设置变量)。

Emacs Lisp allows any variable (with a few exceptions) to have any kind of value. However, many variables are meaningful only if assigned values of a certain type. For example, only numbers are meaningful values for kill-ring-max, which specifies the maximum length of the kill ring (see Yanking Earlier Kills); if you give kill-ring-max a string value, commands such as C-y (yank) will signal an error. On the other hand, some variables don’t care about type; for instance, if a variable has one effect for nil values and another effect for non-nil values, then any value that is not the symbol nil induces the second effect, regardless of its type (by convention, we usually use the value t—a symbol which stands for “true”—to specify a non-nil value). If you set a variable using the customization buffer, you need not worry about giving it an invalid type: the customization buffer usually only allows you to enter meaningful values. When in doubt, use C-h v (describe-variable) to check the variable’s documentation string to see what kind of value it expects (see Examining and Setting Variables).


50.2.1 检查和设置变量

50.2.1 Examining and Setting Variables

C-h v var RET
C-h v var RET

显示变量var ( )的值和文档describe-variable

Display the value and documentation of variable var (describe-variable).

M-x set-variable RET var RET value RET
M-x set-variable RET var RET value RET

将变量var的值更改为value

Change the value of variable var to value.

要检查变量的值,请使用C-h v ( describe-variable)。这使用迷你缓冲区读取变量名称并完成,并显示变量的值和文档。例如,

To examine the value of a variable, use C-h v (describe-variable). This reads a variable name using the minibuffer, with completion, and displays both the value and the documentation of the variable. For example,

Ch v 填充列RET
C-h v fill-column RET

显示类似这样的内容:

displays something like this:

fill-column 是“C 源代码”中定义的变量。
它的值为70

  设置后自动变为缓冲区本地。
  如果该变量的值是文件局部变量,那么它是安全的
  满足谓词“integerp”。
  可能是在 Emacs 版本 18 或之前引入的。

文档:
超过该列应进行自动换行。
您可以交互地使用 Cx f 设置缓冲区本地值。

您可以自定义此变量。
fill-column is a variable defined in ‘C source code’.
Its value is 70

  Automatically becomes buffer-local when set.
  This variable is safe as a file local variable if its value
  satisfies the predicate ‘integerp’.
  Probably introduced at or before Emacs version 18.

Documentation:
Column beyond which automatic line-wrapping should happen.
Interactively, you can set the buffer local value using C-x f.

You can customize this variable.

一行写着‘您可以自定义变量' 表示该变量是用户选项。 C-h v不受用户选项的限制;它也允许不可定制的变量。

The line that says ‘You can customize the variable’ indicates that this variable is a user option. C-h v is not restricted to user options; it allows non-customizable variables too.

设置特定可自定义变量的最便捷方法是使用M-x set-variable。这会使用迷你缓冲区(完成)读取变量名称,然后再次使用迷你缓冲区读取新值的 Lisp 表达式(您可以将旧值插入到迷你缓冲区中以通过 进行编辑M-n)。例如,

The most convenient way to set a specific customizable variable is with M-x set-variable. This reads the variable name with the minibuffer (with completion), and then reads a Lisp expression for the new value using the minibuffer a second time (you can insert the old value into the minibuffer for editing via M-n). For example,

MX 设置变量RET填充列RET75RET
M-x set-variable RET fill-column RET 75 RET

设置fill-column为 75。

sets fill-column to 75.

M-x set-variable仅限于可自定义变量,但您可以使用 Lisp 表达式设置任何变量,如下所示:

M-x set-variable is limited to customizable variables, but you can set any variable with a Lisp expression like this:

(setq 填充第 75 列)
(setq fill-column 75)

要执行这样的表达式,请键入M-:( eval-expression) 并将表达式输入到迷你缓冲区中(请参阅评估 Emacs Lisp 表达式)。或者,转到*划痕*buffer,输入表达式,然后输入C-j(请参阅Lisp 交互缓冲区)。

To execute such an expression, type M-: (eval-expression) and enter the expression in the minibuffer (see Evaluating Emacs Lisp Expressions). Alternatively, go to the *scratch* buffer, type in the expression, and then type C-j (see Lisp Interaction Buffers).

除非另有说明,与所有自定义 Emacs 的方法一样,设置变量仅影响当前的 Emacs 会话。在将来的会话中更改变量的唯一方法是将某些内容放入初始化文件中(请参阅Emacs 初始化文件)。

Setting variables, like all means of customizing Emacs except where otherwise stated, affects only the current Emacs session. The only way to alter the variable in future sessions is to put something in your initialization file (see The Emacs Initialization File).

如果您要在初始化文件中设置可自定义变量,并且不想使用“自定义”界面,则可以使用该setopt宏。例如:

If you’re setting a customizable variable in your initialization file, and you don’t want to use the Customize interface, you can use the setopt macro. For instance:

(setopt 填充列 75)
(setopt fill-column 75)

其工作原理与 相同setq,但如果变量有任何特殊的 setter 函数,它们将在使用时自动运行 setopt。您还可以使用setopt其他不可自定义的变量,但这比使用 setq.

This works the same as setq, but if the variable has any special setter functions, they will be run automatically when using setopt. You can also use setopt on other, non-customizable variables, but this is less efficient than using setq.


50.2.2 钩子

50.2.2 Hooks

Hooks是定制 Emacs 的重要机制。钩子是一个 Lisp 变量,它保存一个函数列表,在某些明确定义的场合调用。 (这称为运行钩子。)列表中的各个函数称为钩子的钩子函数。例如,该钩子kill-emacs-hook 在退出 Emacs 之前运行(请参阅退出 Emacs)。

Hooks are an important mechanism for customizing Emacs. A hook is a Lisp variable which holds a list of functions, to be called on some well-defined occasion. (This is called running the hook.) The individual functions in the list are called the hook functions of the hook. For example, the hook kill-emacs-hook runs just before exiting Emacs (see Exiting Emacs).

大多数钩子都是普通钩子。这意味着当 Emacs 运行钩子时,它会依次调用每个钩子函数,不带任何参数。我们已尽力使大多数钩子保持正常状态,以便您可以以统一的方式使用它们。每个名称以 ' 结尾的变量-钩' 是一个普通的钩子。

Most hooks are normal hooks. This means that when Emacs runs the hook, it calls each hook function in turn, with no arguments. We have made an effort to keep most hooks normal, so that you can use them in a uniform way. Every variable whose name ends in ‘-hook’ is a normal hook.

有少数钩子是异常钩子。他们的名字以 ' 结尾-功能', 代替 '-钩' (一些旧代码也可能使用已弃用的后缀 '-钩子')。这些钩子的异常之处在于其函数的调用方式——也许它们被赋予了参数,或者它们返回的值可能以某种方式被使用。例如, find-file-not-found-functions是异常的,因为一旦一个钩子函数返回非值nil,其余的就根本不会被调用(请参阅访问文件)。每个异常钩子变量的文档都解释了它的函数是如何使用的。

A few hooks are abnormal hooks. Their names end in ‘-functions’, instead of ‘-hook’ (some old code may also use the deprecated suffix ‘-hooks’). What makes these hooks abnormal is the way its functions are called—perhaps they are given arguments, or perhaps the values they return are used in some way. For example, find-file-not-found-functions is abnormal because as soon as one hook function returns a non-nil value, the rest are not called at all (see Visiting Files). The documentation of each abnormal hook variable explains how its functions are used.

您可以像任何其他 Lisp 变量一样设置钩子变量setq,但将函数添加到钩子(正常或异常)的推荐方法是使用add-hook,如以下示例所示。有关详细信息,请参阅Emacs Lisp 参考手册中的Hooks

You can set a hook variable with setq like any other Lisp variable, but the recommended way to add a function to a hook (either normal or abnormal) is to use add-hook, as shown by the following examples. See Hooks in The Emacs Lisp Reference Manual, for details.

大多数主要模式都会运行一个或多个模式挂钩作为初始化的最后一步。模式挂钩是自定义各个模式行为的便捷方法;他们总是正常的。例如,以下是如何设置一个钩子以在文本模式和基于文本模式的其他模式下打开自动填充模式:

Most major modes run one or more mode hooks as the last step of initialization. Mode hooks are a convenient way to customize the behavior of individual modes; they are always normal. For example, here’s how to set up a hook to turn on Auto Fill mode in Text mode and other modes based on Text mode:

(添加挂钩'文本模式挂钩'自动填充模式)
(add-hook 'text-mode-hook 'auto-fill-mode)

这是通过调用 来实现的auto-fill-mode,当不提供参数时启用次要模式(请参阅次要模式)。接下来,假设您不希望在 LaTeX 模式(基于文本模式的模式之一)中打开自动填充模式。您可以使用以下附加行来执行此操作:

This works by calling auto-fill-mode, which enables the minor mode when no argument is supplied (see Minor Modes). Next, suppose you don’t want Auto Fill mode turned on in LaTeX mode, which is one of the modes based on Text mode. You can do this with the following additional line:

(add-hook 'latex-mode-hook (lambda () (自动填充模式 -1)))
(add-hook 'latex-mode-hook (lambda () (auto-fill-mode -1)))

这里我们使用特殊的宏lambda来构造一个匿名函数(请参阅《Emacs Lisp 参考手册》中的Lambda 表达式),该函数使用参数 进行调用以禁用次要模式。由于 LaTeX 模式 在运行后运行,因此结果会禁用自动填充模式。 auto-fill-mode-1latex-mode-hooktext-mode-hook

Here we have used the special macro lambda to construct an anonymous function (see Lambda Expressions in The Emacs Lisp Reference Manual), which calls auto-fill-mode with an argument of -1 to disable the minor mode. Because LaTeX mode runs latex-mode-hook after running text-mode-hook, the result leaves Auto Fill mode disabled.

下面是一个更复杂的示例,展示了如何使用钩子来自定义 C 代码的缩进:

Here is a more complex example, showing how to use a hook to customize the indentation of C code:

(setq my-c-style
  '((c-仅注释行偏移量。4)
(setq my-c-style
  '((c-comment-only-line-offset . 4)
    (c-cleanup-list .(作用域运算符
                       空 defun 大括号
                       defun-关闭-半))))
    (c-cleanup-list . (scope-operator
                       empty-defun-braces
                       defun-close-semi))))
(添加钩子'c-mode-common-hook
  (lambda () (c-add-style "my-style" my-c-style t)))
(add-hook 'c-mode-common-hook
  (lambda () (c-add-style "my-style" my-c-style t)))

主要模式挂钩也适用于从原始模式派生的其他主要模式(请参阅Emacs Lisp 参考手册中的派生模式)。例如,HTML 模式源自文本模式(请参阅SGML 和 HTML 模式);当启用 HTML 模式时,它会 在运行之前运行。这提供了一种使用单个钩子影响多个相关模式的便捷方法。特别是,如果您想将钩子函数应用于任何编程语言模式,请将其添加到; Prog 模式是一种主要模式,除了让其他主要模式继承它之外,没有什么其他作用,正是为了这个目的。 text-mode-hookhtml-mode-hookprog-mode-hook

Major mode hooks also apply to other major modes derived from the original mode (see Derived Modes in The Emacs Lisp Reference Manual). For instance, HTML mode is derived from Text mode (see SGML and HTML Modes); when HTML mode is enabled, it runs text-mode-hook before running html-mode-hook. This provides a convenient way to use a single hook to affect several related modes. In particular, if you want to apply a hook function to any programming language mode, add it to prog-mode-hook; Prog mode is a major mode that does little else than to let other major modes inherit from it, exactly for this purpose.

最好设计挂钩函数,以便它们的执行顺序无关紧要。任何对命令的依赖都是自找麻烦。然而,顺序是可以预测的:钩子函数按照它们在钩子中出现的顺序执行。

It is best to design your hook functions so that the order in which they are executed does not matter. Any dependence on the order is asking for trouble. However, the order is predictable: the hook functions are executed in the order they appear in the hook.

如果您通过一遍又一遍地调用来添加钩子函数的各种不同版本add-hook,请记住您添加的所有版本将一起保留在钩子变量中。您可以通过调用 来清除单个函数remove-hook,或者通过 do来删除所有内容。 (setq hook-variable nil)

If you play with adding various different versions of a hook function by calling add-hook over and over, remember that all the versions you added will remain in the hook variable together. You can clear out individual functions by calling remove-hook, or do (setq hook-variable nil) to remove everything.

如果钩子变量是缓冲区局部变量,则将使用缓冲区局部变量而不是全局变量。但是,如果缓冲区局部变量包含 element t,则全局钩子变量也将运行。

If the hook variable is buffer-local, the buffer-local variable will be used instead of the global variable. However, if the buffer-local variable contains the element t, the global hook variable will be run as well.


50.2.3 局部变量

50.2.3 Local Variables

M-x make-local-variable RET var RET
M-x make-local-variable RET var RET

使变量var在当前缓冲区中具有本地值。

Make variable var have a local value in the current buffer.

M-x kill-local-variable RET var RET
M-x kill-local-variable RET var RET

使变量var使用当前缓冲区中的全局值。

Make variable var use its global value in the current buffer.

M-x make-variable-buffer-local RET var RET
M-x make-variable-buffer-local RET var RET

标记变量var,以便设置它会使其成为当时当前缓冲区的本地变量。

Mark variable var so that setting it will make it local to the buffer that is current at that time.

几乎任何变量都可以成为特定 Emacs 缓冲区的本地变量。这意味着该缓冲区中的值独立于其他缓冲区中的值。每个缓冲区中都有一些变量始终是本地的。每个其他 Emacs 变量都有一个全局值,该值在所有未将该变量设为本地的缓冲区中有效。

Almost any variable can be made local to a specific Emacs buffer. This means that its value in that buffer is independent of its value in other buffers. A few variables are always local in every buffer. Every other Emacs variable has a global value which is in effect in all buffers that have not made the variable local.

M-x make-local-variable读取变量的名称并将其设置为当前缓冲区的本地变量。随后在此缓冲区中更改其值不会影响其他缓冲区,并且其全局值的更改也不会影响该缓冲区。

M-x make-local-variable reads the name of a variable and makes it local to the current buffer. Changing its value subsequently in this buffer will not affect others, and changes in its global value will not affect this buffer.

M-x make-variable-buffer-local标记一个变量,以便无论何时设置它都会自动成为本地变量。更准确地说,一旦以这种方式标记了变量,make-local-variable首先会自动执行设置变量的常用方法。我们将此类变量称为每缓冲区变量。 Emacs 中的许多变量通常是每个缓冲区的;变量的文档字符串会告诉您何时出现这种情况。每个缓冲区变量的全局值通常在任何缓冲区中都不会有效,但它仍然有意义:它是每个新缓冲区的变量的初始值。

M-x make-variable-buffer-local marks a variable so it will become local automatically whenever it is set. More precisely, once a variable has been marked in this way, the usual ways of setting the variable automatically do make-local-variable first. We call such variables per-buffer variables. Many variables in Emacs are normally per-buffer; the variable’s document string tells you when this is so. A per-buffer variable’s global value is normally never effective in any buffer, but it still has a meaning: it is the initial value of the variable for each new buffer.

主要模式(请参阅主要模式)在设置变量之前始终将变量设置为缓冲区本地变量。这就是为什么更改一个缓冲区中的主要模式不会影响其他缓冲区。次要模式也通过设置变量来工作——通常,每个次要模式都有一个控制变量,nil当该模式启用时,该控制变量是非的(请参阅次要模式)。对于许多次要模式,控制变量是每个缓冲区的,因此始终是缓冲区本地的。否则,您可以像任何其他变量一样将其设置为特定缓冲区中的本地变量。

Major modes (see Major Modes) always make variables local to the buffer before setting the variables. This is why changing major modes in one buffer has no effect on other buffers. Minor modes also work by setting variables—normally, each minor mode has one controlling variable which is non-nil when the mode is enabled (see Minor Modes). For many minor modes, the controlling variable is per buffer, and thus always buffer-local. Otherwise, you can make it local in a specific buffer like any other variable.

一些变量不能是缓冲区的本地变量,因为它们始终是每个显示器的本地变量(请参阅多个显示器)。如果您尝试将这些变量之一设置为缓冲区本地变量,您将收到一条错误消息。

A few variables cannot be local to a buffer because they are always local to each display instead (see Multiple Displays). If you try to make one of these variables buffer-local, you’ll get an error message.

M-x kill-local-variable使指定变量不再是当前缓冲区的本地变量。此后变量的全局值在此缓冲区中生效。设置主要模式会杀死缓冲区的所有局部变量,除了一些专门标记为永久局部变量的变量。

M-x kill-local-variable makes a specified variable cease to be local to the current buffer. The global value of the variable henceforth is in effect in this buffer. Setting the major mode kills all the local variables of the buffer except for a few variables specially marked as permanent locals.

要设置变量的全局值,无论该变量在当前缓冲区中是否有本地值,都可以使用 Lisp 构造setq-default。此构造的使用方式与 一样 setq,但它设置变量的全局值而不是它们的局部值(如果有)。当当前缓冲区确实有本地值时,新的全局值可能不可见,直到您切换到另一个缓冲区。这是一个例子:

To set the global value of a variable, regardless of whether the variable has a local value in the current buffer, you can use the Lisp construct setq-default. This construct is used just like setq, but it sets variables’ global values instead of their local values (if any). When the current buffer does have a local value, the new global value may not be visible until you switch to another buffer. Here is an example:

(setq-默认填充列 75)
(setq-default fill-column 75)

setq-default是设置已标记的变量的全局值的唯一方法make-variable-buffer-local

setq-default is the only way to set the global value of a variable that has been marked with make-variable-buffer-local.

Lisp 程序可以用来default-value查看变量的默认值。该函数接受一个符号作为参数并返回其默认值。对论证进行评估;通常你必须明确引用它。例如,以下是获取默认值的方法 fill-column

Lisp programs can use default-value to look at a variable’s default value. This function takes a symbol as argument and returns its default value. The argument is evaluated; usually you must quote it explicitly. For example, here’s how to obtain the default value of fill-column:

(默认值“填充列”)
(default-value 'fill-column)

50.2.4 文件中的局部变量

50.2.4 Local Variables in Files

文件可以指定使用 Emacs 编辑文件时要使用的局部变量值。访问文件或设置主要模式检查局部变量规范;它会自动使这些变量成为缓冲区的本地变量,并将它们设置为文件中指定的值。

A file can specify local variable values to use when editing the file with Emacs. Visiting the file or setting a major mode checks for local variable specifications; it automatically makes these variables local to the buffer, and sets them to the values specified in the file.

如果为文件目录指定了任何本地变量,则 文件本地变量将覆盖目录本地变量(请参阅每目录本地变量)。

File local variables override directory local variables (see Per-Directory Local Variables), if any are specified for a file’s directory.


50.2.4.1 指定文件变量

50.2.4.1 Specifying File Variables

有两种方法可以指定文件局部变量值:在第一行,或使用局部变量列表。以下是如何在第一行中指定它们:

There are two ways to specify file local variable values: in the first line, or with a local variables list. Here’s how to specify them in the first line:

-*- 模式:模式名称var; …-*-
-*- mode: modename; var: value; … -*-

您可以通过这种方式指定任意数量的变量/值对,每对都带有冒号和分号。特殊变量/值对 (如果存在)指定主要模式(不带“-mode”后缀)。值s 按字面意思使用,而不进行计算。 mode: modename;

You can specify any number of variable/value pairs in this way, each pair with a colon and semicolon. The special variable/value pair mode: modename;, if present, specifies a major mode (without the “-mode” suffix). The values are used literally, and not evaluated.

您可以使用M-x add-file-local-variable-prop-line而不是手动添加条目。此命令提示输入变量和值,并以适当的方式将它们添加到第一行。 M-x delete-file-local-variable-prop-line提示输入变量,并从行中删除其条目。该命令M-x copy-dir-locals-to-file-locals-prop-line将当前目录局部变量复制到第一行(请参阅每目录局部变量)。

You can use M-x add-file-local-variable-prop-line instead of adding entries by hand. This command prompts for a variable and value, and adds them to the first line in the appropriate way. M-x delete-file-local-variable-prop-line prompts for a variable, and deletes its entry from the line. The command M-x copy-dir-locals-to-file-locals-prop-line copies the current directory-local variables to the first line (see Per-Directory Local Variables).

下面是一个示例,第一行指定 Lisp 模式并设置两个带有数值的变量:

Here is an example first line that specifies Lisp mode and sets two variables with numeric values:

;; -*- 模式:Lisp;填充列:75;评论栏:50; -*-
;; -*- mode: Lisp; fill-column: 75; comment-column: 50; -*-

除了 之外mode,作为文件变量具有特殊含义的其他关键字还有codingunibyteeval。这些将在下面描述。

Aside from mode, other keywords that have special meanings as file variables are coding, unibyte, and eval. These are described below.

在 shell 脚本中,第一行用于标识脚本解释器,因此您不能在其中放置任何局部变量。为了适应这种情况,如果第一行指定了解释器, Emacs 将在第二行中查找局部变量规范 。对于以魔术字符串 ' 开头的手册页也是如此'\"' 指定 troff 预处理器列表(但并非全部如此)。

In shell scripts, the first line is used to identify the script interpreter, so you cannot put any local variables there. To accommodate this, Emacs looks for local variable specifications in the second line if the first line specifies an interpreter. The same is true for man pages which start with the magic string ‘'\"’ to specify a list of troff preprocessors (not all do, however).

除了使用 '-*-' 行,您可以使用文件末尾附近的局部变量列表来定义文件局部变量。局部变量列表的开头距离文件末尾不应超过 3000 个字符,如果文件分页,则必须位于最后一页。

Apart from using a ‘-*-’ line, you can define file local variables using a local variables list near the end of the file. The start of the local variables list should be no more than 3000 characters from the end of the file, and must be on the last page if the file is divided into pages.

如果文件同时具有局部变量列表和 '-*-' 行,Emacs 处理' 中的所有内容-*-' 首先行,然后 是局部变量列表中的所有内容。例外情况是主模式规范。 Emacs 首先应用它,无论它出现在哪里,因为大多数主要模式都会在初始化过程中杀死所有局部变量。

If a file has both a local variables list and a ‘-*-’ line, Emacs processes everything in the ‘-*-’ line first, and everything in the local variables list afterward. The exception to this is a major mode specification. Emacs applies this first, wherever it appears, since most major modes kill all local variables as part of their initialization.

局部变量列表以包含字符串 ' 的行开头局部变量:',并以包含字符串 ' 的行结尾结尾:'。中间是变量名称和值,每行一组,如下所示:

A local variables list starts with a line containing the string ‘Local Variables:’, and ends with a line containing the string ‘End:’. In between come the variable names and values, one set per line, like this:

/* 局部变量: */
/* 模式:c */
/* 评论栏: 0 */
/* 结尾: */
/* Local Variables:  */
/* mode: c           */
/* comment-column: 0 */
/* End:              */

在此示例中,每行以前缀 ' 开头/*' 并以后缀 ' 结尾*/'。 Emacs 通过查找魔术字符串 ' 周围的前缀和后缀来识别它们局部变量:',在列表的第一行;然后它会自动从列表的其他行中丢弃它们。使用前缀和/或后缀的通常原因是将局部变量列表嵌入注释中,这样就不会混淆该文件的其他程序。上面的示例适用于 C 编程语言,其中注释以 ' 开头/*' 并以 ' 结尾*/'。

In this example, each line starts with the prefix ‘/*’ and ends with the suffix ‘*/’. Emacs recognizes the prefix and suffix by finding them surrounding the magic string ‘Local Variables:’, on the first line of the list; it then automatically discards them from the other lines of the list. The usual reason for using a prefix and/or suffix is to embed the local variables list in a comment, so it won’t confuse other programs that the file is intended for. The example above is for the C programming language, where comments start with ‘/*’ and end with ‘*/’.

如果某些不相关的文本可能会将 Emacs 视为局部变量列表,您可以通过在该文本后插入换页符(页面分隔符,请参阅Pages)来取消这种情况。 Emacs 仅在文件的最后一页(最后一个页分隔符之后)中查找文件局部变量。

If some unrelated text might look to Emacs as a local variables list, you can countermand that by inserting a form-feed character (a page delimiter, see Pages) after that text. Emacs only looks for file-local variables in the last page of a file, after the last page delimiter.

您可以使用命令,而不是直接输入局部变量列表M-x add-file-local-variable。这会提示输入变量和值,并将它们添加到列表中,添加 '局部变量:' 根据需要添加字符串以及开始和结束标记。该命令M-x delete-file-local-variable从列表中删除一个变量。 M-x copy-dir-locals-to-file-locals将目录局部变量复制到列表中(请参阅每目录局部变量)。

Instead of typing in the local variables list directly, you can use the command M-x add-file-local-variable. This prompts for a variable and value, and adds them to the list, adding the ‘Local Variables:’ string and start and end markers as necessary. The command M-x delete-file-local-variable deletes a variable from the list. M-x copy-dir-locals-to-file-locals copies directory-local variables to the list (see Per-Directory Local Variables).

与 '-*-' 行,局部变量列表中的变量按字面意思使用,并且不会首先求值。如果你想将一个长字符串值分割到文件的多行中,你可以使用反斜杠换行符,它在 Lisp 字符串常量中被忽略;您应该在每一行上放置前缀和后缀,甚至是在字符串中开始或结束的行,因为在处理列表时它们将被删除。这是一个例子:

As with the ‘-*-’ line, the variables in a local variables list are used literally, and are not evaluated first. If you want to split a long string value across multiple lines of the file, you can use backslash-newline, which is ignored in Lisp string constants; you should put the prefix and suffix on each line, even lines that start or end within the string, as they will be stripped off when processing the list. Here is an example:

# 局部变量:
# 编译命令:“cc foo.c -Dfoo=bar -Dhack=whatever \
# -Dmumble=blaah"
# 结尾:
# Local Variables:
# compile-command: "cc foo.c -Dfoo=bar -Dhack=whatever \
#   -Dmumble=blaah"
# End:

某些名称在局部变量列表中具有特殊含义:

Some names have special meanings in a local variables list:

  • mode启用指定的主要模式。
  • mode enables the specified major mode.
  • eval计算指定的 Lisp 表达式(该表达式返回的值被忽略)。
  • eval evaluates the specified Lisp expression (the value returned by that expression is ignored).
  • coding指定该文件的字符代码转换的编码系统。请参阅编码系统
  • coding specifies the coding system for character code conversion of this file. See Coding Systems.
  • unibyte表示以单字节模式加载或编译 Emacs Lisp 文件,如果值为t.请参阅《GNU Emacs Lisp 参考手册》中的“禁用多字节字符”
  • unibyte says to load or compile a file of Emacs Lisp in unibyte mode, if the value is t. See Disabling Multibyte Characters in GNU Emacs Lisp Reference Manual.

这四个关键字并不是真正的变量;而是变量。将它们设置在任何其他上下文中没有特殊意义。

These four keywords are not really variables; setting them in any other context has no special meaning.

如果您正在跨 Emacs 版本编辑文件,并且引入了新模式来处理较新 Emacs 版本中的文件,则可以使用多个mode条目在新 Emacs 中使用新模式(称为 my-new-mode),然后回退到my-old-mode旧版 Emacs 中的旧模式(称为)。如果您在文件的第一行启用模式,可以说:

If you’re editing a file across Emacs versions, and a new mode has been introduced to handle a file in a newer Emacs version, you can use several mode entries to use the new mode (called my-new-mode) in the new Emacs, and fall back to the old mode (called my-old-mode) in older Emacs versions. If you’re enabling the modes in the first line of the file, can say:

-*- 模式:我的旧;模式:我的新-*-
-*- mode: my-old; mode: my-new -*-

Emacs 将使用它找到的最终定义模式,因此在较旧的 Emacs 版本中它将忽略my-new-mode,而在定义的 Emacs 版本中my-new-mode它将忽略my-old-mode。同样,在文件末尾的局部变量块中:

Emacs will use the final defined mode it finds, so in older Emacs versions it will ignore my-new-mode, while in Emacs versions where my-new-mode is defined, it’ll ignore my-old-mode. Similarly, in a local variable block at the end of the file:

局部变量:
模式:我的老
模式:我的新
Local variables:
mode: my-old
mode: my-new

不要将mode关键字用于次要模式。要启用或禁用局部变量列表中的次要模式,请使用eval 带有运行 mode 命令的 Lisp 表达式的关键字(请参阅次要模式)。例如,以下局部变量列表通过 不带参数调用(使用参数 1 调用它会执行相同的操作)来启用 ElDoc 模式(请参阅编程语言文档查找),并通过调用禁用字体锁定模式(请参阅字体锁定模式)参数为-1。 eldoc-modefont-lock-mode

Do not use the mode keyword for minor modes. To enable or disable a minor mode in a local variables list, use the eval keyword with a Lisp expression that runs the mode command (see Minor Modes). For example, the following local variables list enables ElDoc mode (see Programming Language Documentation Lookup) by calling eldoc-mode with no argument (calling it with an argument of 1 would do the same), and disables Font Lock mode (see Font Lock mode) by calling font-lock-mode with an argument of −1.

;;局部变量:
;; eval: (eldoc-模式)
;;评估:(字体锁定模式-1)
;;结尾:
;; Local Variables:
;; eval: (eldoc-mode)
;; eval: (font-lock-mode -1)
;; End:

但请注意,以这种方式指定次要模式通常是错误的。次要模式代表个人用户偏好,将您的偏好强加给可能编辑该文件的其他用户可能是不合适的。如果您希望根据具体情况自动启用或禁用次要模式,通常最好在主要模式挂钩中执行此操作(请参阅Hooks)。

Note, however, that it is often a mistake to specify minor modes this way. Minor modes represent individual user preferences, and it may be inappropriate to impose your preferences on another user who might edit the file. If you wish to automatically enable or disable a minor mode in a situation-dependent way, it is often better to do it in a major mode hook (see Hooks).

使用该命令M-x normal-mode根据文件名和内容重置缓冲区的局部变量和主模式,包括局部变量列表(如果有)。请参阅选择文件模式

Use the command M-x normal-mode to reset the local variables and major mode of a buffer according to the file name and contents, including the local variables list if any. See Choosing File Modes.


50.2.4.2 文件变量的安全性

50.2.4.2 Safety of File Variables

文件局部变量可能很危险;当你访问别人的文件时,你无法知道它的局部变量列表会对你的 Emacs 做什么。eval“变量”和其他变量(例如 )的不正确值load-path可能会执行您不打算运行的 Lisp 代码。

File-local variables can be dangerous; when you visit someone else’s file, there’s no telling what its local variables list could do to your Emacs. Improper values of the eval “variable”, and other variables such as load-path, could execute Lisp code you didn’t intend to run.

因此,每当 Emacs 遇到未知安全的文件局部变量值时,它都会显示文件的整个局部变量列表,并在设置它们之前要求您确认。您可以键入ySPC以使局部变量列表生效,或n忽略它。当 Emacs 以批处理模式运行时(请参阅初始选项),它无法真正询问您,因此它会假设答案n

Therefore, whenever Emacs encounters file local variable values that are not known to be safe, it displays the file’s entire local variables list, and asks you for confirmation before setting them. You can type y or SPC to put the local variables list into effect, or n to ignore it. When Emacs is run in batch mode (see Initial Options), it can’t really ask you, so it assumes the answer n.

Emacs 通常将某些变量/值对识别为安全的。例如,给出comment-columnfill-column任何整数值是安全的。如果文件仅指定已知安全的变量/值对,则 Emacs 在设置它们之前不会要求确认。否则,您可以通过!在确认提示下键入来告诉 Emacs 将所有变量/值对记录在该文件中,以保证安全。当 Emacs 随后在同一文件或其他文件中遇到这些变量/值对时,它会假设它们是安全的。

Emacs normally recognizes certain variable/value pairs as safe. For instance, it is safe to give comment-column or fill-column any integer value. If a file specifies only known-safe variable/value pairs, Emacs does not ask for confirmation before setting them. Otherwise, you can tell Emacs to record all the variable/value pairs in this file as safe, by typing ! at the confirmation prompt. When Emacs encounters these variable/value pairs subsequently, in the same file or others, it will assume they are safe.

i您还可以通过在确认提示下 键入来告诉 Emacs 永久忽略文件中的所有变量/值对- 此后这些对将在此文件和所有其他文件中被忽略。

You can also tell Emacs to permanently ignore all the variable/value pairs in the file, by typing i at the confirmation prompt – these pairs will thereafter be ignored in this file and in all other files.

有些变量,例如load-path,被认为特别危险:很少有任何理由将它们指定为局部变量,并且更改它们可能很危险。如果文件仅包含有风险的局部变量,Emacs !在确认提示时既不会提供也不接受作为输入。如果文件中的某些局部变量存在风险,而某些只是潜在不安全,则可以!在提示符下输入。它应用所有变量,但仅将无风险变量标记为未来安全。如果你确实想记录风险变量的安全值,可以直接通过自定义 '安全局部变量值'(请参阅轻松定制界面)。同样,如果您想要记录应永久忽略的风险变量的值,请自定义ignored-local-variable-values.

Some variables, such as load-path, are considered particularly risky: there is seldom any reason to specify them as local variables, and changing them can be dangerous. If a file contains only risky local variables, Emacs neither offers nor accepts ! as input at the confirmation prompt. If some of the local variables in a file are risky, and some are only potentially unsafe, you can enter ! at the prompt. It applies all the variables, but only marks the non-risky ones as safe for the future. If you really want to record safe values for risky variables, do it directly by customizing ‘safe-local-variable-values’ (see Easy Customization Interface). Similarly, if you want to record values of risky variables that should be permanently ignored, customize ignored-local-variable-values.

该变量enable-local-variables允许您更改 Emacs 处理局部变量的方式。它的默认值为t,它指定上述行为。如果是nil,Emacs 会简单地忽略所有文件局部变量。 :safe意味着仅使用安全值并忽略其余值。 :all指示 Emacs 设置所有文件局部变量,无论它们的值是否安全(我们建议不要永久使用它)。任何其他值表示向您查询具有局部变量的每个文件,而不尝试确定这些值是否已知是安全的。

The variable enable-local-variables allows you to change the way Emacs processes local variables. Its default value is t, which specifies the behavior described above. If it is nil, Emacs simply ignores all file local variables. :safe means use only the safe values and ignore the rest. :all instructs Emacs to set all file local variables regardless of whether their value is safe or not (we advise not to use this permanently). Any other value says to query you about each file that has local variables, without trying to determine whether the values are known to be safe.

变量enable-local-eval控制 Emacs 是否处理eval变量。变量值的三种可能性是tnil和其他任何值,就像 一样enable-local-variables。默认值是maybe,它既不是t也不是nil,所以通常 Emacs 确实会要求确认处理eval变量。

The variable enable-local-eval controls whether Emacs processes eval variables. The three possibilities for the variable’s value are t, nil, and anything else, just as for enable-local-variables. The default is maybe, which is neither t nor nil, so normally Emacs does ask for confirmation about processing eval variables.

作为例外, eval如果任何形式出现在变量中,Emacs 永远不会要求确认来评估该形式 safe-local-eval-forms

As an exception, Emacs never asks for confirmation to evaluate any eval form if that form occurs within the variable safe-local-eval-forms.


50.2.5 每目录局部变量

50.2.5 Per-Directory Local Variables

有时,您可能希望为某个目录及其子目录中的所有文件定义同一组局部变量,例如大型软件项目的目录树。这可以通过目录局部变量来完成。文件局部变量会覆盖目录局部变量,因此如果目录中的某些文件需要专门设置,可以在目录变量中指定该目录中大部分文件的设置,然后在少数需要特殊设置的文件中定义文件局部变量。常规设置被覆盖。

Sometimes, you may wish to define the same set of local variables to all the files in a certain directory and its subdirectories, such as the directory tree of a large software project. This can be accomplished with directory-local variables. File local variables override directory local variables, so if some of the files in a directory need specialized settings, you can specify the settings for the majority of the directory’s files in directory variables, and then define file local variables in a few files which need the general settings overridden.

定义目录局部变量的常用方法是放置一个名为.dir-locals.el24在一个目录中。每当 Emacs 访问该目录或其任何子目录中的任何文件时,它将应用在.dir-locals.el,就好像它们已被定义为该文件的文件局部变量一样(请参阅文件中的局部变量)。 Emacs 搜索.dir-locals.el从访问文件的目录开始,并沿目录树向上移动。为了避免速度变慢,远程文件将跳过此搜索。如果需要,可以通过将变量设置为enable-remote-dir-locals来扩展远程文件的搜索 t

The usual way to define directory-local variables is to put a file named .dir-locals.el24 in a directory. Whenever Emacs visits any file in that directory or any of its subdirectories, it will apply the directory-local variables specified in .dir-locals.el, as though they had been defined as file-local variables for that file (see Local Variables in Files). Emacs searches for .dir-locals.el starting in the directory of the visited file, and moving up the directory tree. To avoid slowdown, this search is skipped for remote files. If needed, the search can be extended for remote files by setting the variable enable-remote-dir-locals to t.

您还可以使用.dir-locals-2.el;如果找到,Emacs 会加载它.dir-locals.el。这在以下情况下很有用: .dir-locals.el在共享存储库中受版本控制,不能用于个人自定义。

You can also use .dir-locals-2.el; if found, Emacs loads it in addition to .dir-locals.el. This is useful when .dir-locals.el is under version control in a shared repository and can’t be used for personal customizations.

.dir-locals.el文件应该包含一个特殊构造的列表,它将主要模式名称(符号)映射到列表(请参阅Emacs Lisp 参考手册中的关联列表)。每个列表条目都包含一个变量名称和在启用指定的主要模式时分配给该变量的目录本地值。您可以指定“而不是模式名称”',表示该alist适用于任何模式;或者您可以指定一个子目录(字符串),在这种情况下,列表适用于该子目录中的所有文件。

The .dir-locals.el file should hold a specially-constructed list, which maps major mode names (symbols) to alists (see Association Lists in The Emacs Lisp Reference Manual). Each alist entry consists of a variable name and the directory-local value to assign to that variable, when the specified major mode is enabled. Instead of a mode name, you can specify ‘nil’, which means that the alist applies to any mode; or you can specify a subdirectory (a string), in which case the alist applies to all files in that subdirectory.

这是一个例子.dir-locals.el文件:

Here’s an example of a .dir-locals.el file:

((nil . ((缩进制表符模式 . t)
         (填充列 . 80)
         (模式.自动填充)))
 (c-模式 . ((c-文件样式 . "BSD")
            (子目录.nil)))
 (“src/导入”
  。 ((nil 。((更改日志默认名称
              。 “ChangeLog.local”))))))
((nil . ((indent-tabs-mode . t)
         (fill-column . 80)
         (mode . auto-fill)))
 (c-mode . ((c-file-style . "BSD")
            (subdirs . nil)))
 ("src/imported"
  . ((nil . ((change-log-default-name
              . "ChangeLog.local"))))))

这设置了变量 '缩进制表符模式' 以及fill-column 目录树中的任何文件,以及任何 C 源文件的缩进样式。特殊mode元素指定要启用的次要模式。所以指定需要启用(mode . auto-fill)次要模式。auto-fill-mode特殊 subdirs元素不是变量,而是特殊关键字,表示C模式设置仅应用于当前目录,而不应用于任何子目录。最后,它指定了一个不同的变更日志中任意文件的文件名 源代码/导入子目录。

This sets the variables ‘indent-tabs-mode’ and fill-column for any file in the directory tree, and the indentation style for any C source file. The special mode element specifies the minor mode to be enabled. So (mode . auto-fill) specifies that the minor mode auto-fill-mode needs to be enabled. The special subdirs element is not a variable, but a special keyword which indicates that the C mode settings are only to be applied in the current directory, not in any subdirectories. Finally, it specifies a different ChangeLog file name for any file in the src/imported subdirectory.

如果.dir-locals.el文件包含使用不同模式名称或目录的变量的多个不同值,这些值将按顺序应用,以便更具体模式的值优先于更通用模式。目录下指定的值具有更高的优先级。例如:

If the .dir-locals.el file contains multiple different values for a variable using different mode names or directories, the values will be applied in an order such that the values for more specific modes take priority over more generic modes. Values specified under a directory have even more priority. For example:

((零。((填充列。40)))
 (c-模式 . ((填充列 . 50)))
 (编程模式。((填充列。60)))
 ("窄文件" . ((nil . ((fill-column . 20))))))
((nil . ((fill-column . 40)))
 (c-mode . ((fill-column . 50)))
 (prog-mode . ((fill-column . 60)))
 ("narrow-files" . ((nil . ((fill-column . 20))))))

使用的文件c-mode也匹配,prog-mode因为前者继承自后者。然而,C 文件中使用的值 fill-column50因为模式名称比prog-mode.使用继承自的其他模式的文件prog-mode将使用60.目录下任意文件窄文件20 即使它们使用,也会使用该值,c-mode因为目录条目优先于模式条目。

Files that use c-mode also match prog-mode because the former inherits from the latter. The value used for fill-column in C files will however be 50 because the mode name is more specific than prog-mode. Files using other modes inheriting from prog-mode will use 60. Any file under the directory narrow-files will use the value 20 even if they use c-mode because directory entries have priority over mode entries.

您 可以mode在您的evalunibyte.dir-locals.el,它们的含义与文件局部变量中的含义相同。 coding 不能指定为目录局部变量。请参阅文件中的局部变量

You can specify the variables mode, eval, and unibyte in your .dir-locals.el, and they have the same meanings as they would have in file local variables. coding cannot be specified as a directory local variable. See Local Variables in Files.

auto-mode-alist中的特殊键.dir-locals.el允许您设置文件的主要模式。它的工作方式与变量非常相似 auto-mode-alist(请参阅选择文件模式)。例如,您可以通过以下方式告诉 Emacs:.def此目录中的源文件应为 C 模式:

The special key auto-mode-alist in a .dir-locals.el lets you set a file’s major mode. It works much like the variable auto-mode-alist (see Choosing File Modes). For example, here is how you can tell Emacs that .def source files in this directory should be in C mode:

((auto-mode-alist . (("\\.def\\'" . c-mode))))
((auto-mode-alist . (("\\.def\\'" . c-mode))))

而不是编辑.dir-locals.el手动文件,可以使用命令M-x add-dir-local-variable.这会提示输入模式或子目录、变量和值,并添加定义目录局部变量的条目。 M-x delete-dir-local-variable删除一个条目。 M-x copy-file-locals-to-dir-locals将当前文件中的文件局部变量复制到.dir-locals.el

Instead of editing the .dir-locals.el file by hand, you can use the command M-x add-dir-local-variable. This prompts for a mode or subdirectory, and for variable and value, and adds the entry defining the directory-local variable. M-x delete-dir-local-variable deletes an entry. M-x copy-file-locals-to-dir-locals copies the file-local variables in the current file into .dir-locals.el.

指定目录局部变量的另一种方法是使用以下 函数在目录类dir-locals-set-class-variables中定义一组变量/值对;然后,使用该 dir-locals-set-directory-class函数告诉 Emacs 哪些目录对应于该类。这些函数调用通常位于初始化文件中(请参阅Emacs 初始化文件)。当你不能放的时候这个方法很有用.dir-locals.el由于某种原因在目录中。例如,您可以通过以下方式将设置应用于不可写目录:

Another method of specifying directory-local variables is to define a group of variables/value pairs in a directory class, using the dir-locals-set-class-variables function; then, tell Emacs which directories correspond to the class by using the dir-locals-set-directory-class function. These function calls normally go in your initialization file (see The Emacs Initialization File). This method is useful when you can’t put .dir-locals.el in a directory for some reason. For example, you could apply settings to an unwritable directory this way:

(dir-locals-set-class-variables '不可写目录
   '((nil 。((一些有用的设置。值)))))

(dir-locals-set-directory-class
   "/usr/include/" '不可写目录)
(dir-locals-set-class-variables 'unwritable-directory
   '((nil . ((some-useful-setting . value)))))

(dir-locals-set-directory-class
   "/usr/include/" 'unwritable-directory)

如果变量同时指定了目录本地值和文件本地值,则文件本地值生效。不安全的目录局部变量的处理方式与不安全的文件局部变量的处理方式相同(请参阅文件变量的安全性)。

If a variable has both a directory-local and file-local value specified, the file-local value takes effect. Unsafe directory-local variables are handled in the same way as unsafe file-local variables (see Safety of File Variables).

目录局部变量也在某些不直接访问文件但在目录中执行工作的缓冲区中生效,例如 Dired 缓冲区(请参阅Dired,目录编辑器)。

Directory-local variables also take effect in certain buffers that do not visit a file directly but perform work within a directory, such as Dired buffers (see Dired, the Directory Editor).


50.2.6 每个连接的局部变量

50.2.6 Per-Connection Local Variables

大多数变量反映了本地机器上的情况。通常,当您在具有远程默认目录的缓冲区中进行操作时,它们必须使用不同的值。考虑调用时的行为shell- 在本地计算机上,您可能会使用 /bin/bash并依赖 termcap,但在远程计算机上,它可能是/bin/ksh和术语信息。

Most of the variables reflect the situation on the local machine. Often, they must use a different value when you operate in buffers with a remote default directory. Think about the behavior when calling shell – on your local machine, you might use /bin/bash and rely on termcap, but on a remote machine, it may be /bin/ksh and terminfo.

这可以通过连接局部变量来完成。目录和文件局部变量覆盖连接局部变量。不安全的连接局部变量的处理方式与不安全的文件局部变量的处理方式相同(请参阅文件变量的安全性)。

This can be accomplished with connection-local variables. Directory and file local variables override connection-local variables. Unsafe connection-local variables are handled in the same way as unsafe file-local variables (see Safety of File Variables).

使用 函数将连接局部变量声明为配置文件connection-local-set-profile-variables中的一组变量/值对。该函数 connection-local-set-profiles激活给定条件的配置文件,识别远程计算机:

Connection-local variables are declared as a group of variables/value pairs in a profile, using the connection-local-set-profile-variables function. The function connection-local-set-profiles activates profiles for a given criteria, identifying a remote machine:

(连接本地设置配置文件变量'远程术语信息
   '((系统使用术语信息.t)
     (comint-terminfo-terminal 。“dumb-emacs-ansi”)))

(连接本地设置配置文件变量'远程ksh
   '((shell 文件名 ."/bin/ksh")
     (shell 命令开关。“-c”)))

(连接本地设置配置文件变量'远程bash
   '((shell 文件名 ."/bin/bash")
     (shell 命令开关。“-c”)))

(连接本地设置配置文件
   '(:应用程序流浪者:机器“远程机器”)
   'remote-terminfo 'remote-ksh)
(connection-local-set-profile-variables 'remote-terminfo
   '((system-uses-terminfo . t)
     (comint-terminfo-terminal . "dumb-emacs-ansi")))

(connection-local-set-profile-variables 'remote-ksh
   '((shell-file-name . "/bin/ksh")
     (shell-command-switch . "-c")))

(connection-local-set-profile-variables 'remote-bash
   '((shell-file-name . "/bin/bash")
     (shell-command-switch . "-c")))

(connection-local-set-profiles
   '(:application tramp :machine "remotemachine")
   'remote-terminfo 'remote-ksh)

此代码声明了三个不同的配置文件remote-terminforemote-kshremote-bash。配置文件 remote-terminforemote-ksh应用于所有具有与正则表达式匹配的远程默认目录 "remotemachine"作为主机名的缓冲区。这样的标准还可以区分属性:protocol(这是 Tramp 方法)或:user(远程用户名)。该nil条件将所有缓冲区与远程默认目录相匹配。

This code declares three different profiles, remote-terminfo, remote-ksh, and remote-bash. The profiles remote-terminfo and remote-ksh are applied to all buffers which have a remote default directory matching the regexp "remotemachine" as host name. Such a criteria can also discriminate for the properties :protocol (this is the Tramp method) or :user (a remote user name). The nil criteria matches all buffers with a remote default directory.

使用同一变量声明不同的配置文件并将这些配置文件设置为可以并行匹配的条件时要小心。未指定随后使用哪个变量值。

Be careful when declaring different profiles with the same variable, and setting these profiles to criteria which could match in parallel. It is unspecified which variable value is used then.


50.3 自定义按键绑定

50.3 Customizing Key Bindings

本节介绍键绑定(将键映射到命令)和键映射(记录键绑定)。它还解释了如何自定义键绑定,这是通过编辑初始化文件来完成的(请参阅在初始化文件中重新绑定键)。

This section describes key bindings, which map keys to commands, and keymaps, which record key bindings. It also explains how to customize key bindings, which is done by editing your init file (see Rebinding Keys in Your Init File).

由于大多数模式定义了自己的键绑定,因此激活模式可能会覆盖您的自定义键绑定。少数键保留用于用户定义的绑定,并且不应由模式使用,因此使用这些键的键绑定在这方面更安全。保留的按键序列由C-c后跟字母(大写或小写)和功能键组成,不F5F9修饰符(请参阅修饰键)。

Since most modes define their own key bindings, activating a mode might override your custom key bindings. A small number of keys are reserved for user-defined bindings, and should not be used by modes, so key bindings using those keys are safer in this regard. The reserved key sequences are those consisting of C-c followed by a letter (either upper or lower case), and function keys F5 through F9 without modifiers (see Modifier Keys).


50.3.1 键盘映射

50.3.1 Keymaps

按键和命令中所述,每个 Emacs 命令都是一个 Lisp 函数,其定义提供了交互式使用。与每个 Lisp 函数一样,命令也有一个函数名称,该名称通常由小写字母和连字符组成。

As described in Keys and Commands, each Emacs command is a Lisp function whose definition provides for interactive use. Like every Lisp function, a command has a function name, which usually consists of lower-case letters and hyphens.

按键序列(简称key )是 具有作为一个单元的含义的输入事件序列。输入事件包括字符、功能键和鼠标按钮 - 您可以发送到计算机的所有输入。按键序列从其绑定中获取其含义,​​该绑定说明了它运行的命令。

A key sequence (key, for short) is a sequence of input events that have a meaning as a unit. Input events include characters, function keys, and mouse buttons—all the inputs that you can send to the computer. A key sequence gets its meaning from its binding, which says what command it runs.

键序列和命令功能之间的绑定记录在称为键映射的数据结构中。 Emacs 有很多这样的工具,每种工具都在特定的场合使用。

The bindings between key sequences and command functions are recorded in data structures called keymaps. Emacs has many of these, each used on particular occasions.

全局键盘映射是最重要的键盘映射,因为它始终有效。全局键映射定义了基本模式的键(请参阅主要模式);这些定义中的大多数对于大多数或所有主要模式都是通用的。每个主要或次要模式都可以有自己的键盘映射,该映射会覆盖某些键的全局定义。

The global keymap is the most important keymap because it is always in effect. The global keymap defines keys for Fundamental mode (see Major Modes); most of these definitions are common to most or all major modes. Each major or minor mode can have its own keymap which overrides the global definitions of some keys.

例如,诸如 之类的自插入字符g是自插入的,因为全局键盘映射将其绑定到命令 self-insert-command。标准 Emacs 编辑字符 例如 也C-a从全局键盘映射中获取其标准含义。重新绑定键的命令(例如M-x keymap-global-set)通过将新绑定存储在全局映射中的正确位置来工作(请参阅交互更改键绑定)。要查看当前的键绑定,请使用该 C-h b命令。

For example, a self-inserting character such as g is self-inserting because the global keymap binds it to the command self-insert-command. The standard Emacs editing characters such as C-a also get their standard meanings from the global keymap. Commands to rebind keys, such as M-x keymap-global-set, work by storing the new binding in the proper place in the global map (see Changing Key Bindings Interactively). To view the current key bindings, use the C-h b command.

大多数现代键盘都有功能键和字符键。功能键像字符键一样发送输入事件,并且键盘映射可以对其进行绑定。按键序列可以混合功能键和字符。例如,如果您的键盘有Home功能键,Emacs 可以识别诸如 之类的按键序列。您甚至可以将鼠标事件与键盘事件混合使用,例如 . C-x HomeS-down-mouse-1

Most modern keyboards have function keys as well as character keys. Function keys send input events just as character keys do, and keymaps can have bindings for them. Key sequences can mix function keys and characters. For example, if your keyboard has a Home function key, Emacs can recognize key sequences like C-x Home. You can even mix mouse events with keyboard events, such as S-down-mouse-1.

在文本终端上,键入功能键实际上会向计算机发送一个字符序列;序列的精确细节取决于功能键和终端类型。 (通常该序列以 开头ESC [。)如果 Emacs 正确理解您的终端类型,它会自动将此类序列处理为单个输入事件。

On text terminals, typing a function key actually sends the computer a sequence of characters; the precise details of the sequence depend on the function key and on the terminal type. (Often the sequence starts with ESC [.) If Emacs understands your terminal type properly, it automatically handles such sequences as single input events.

C-c由后跟字母(大写或小写;ASCII或非ASCII )组成的按键序列为用户保留。 Emacs 本身永远不会绑定这些按键序列,并且 Emacs 扩展应该避免绑定它们。换句话说,用户可以绑定类似C-c a或 之类的键序列C-c ç,并依赖于这些序列永远不会被其他 Emacs 绑定所遮蔽。

Key sequences that consist of C-c followed by a letter (upper or lower case; ASCII or non-ASCII) are reserved for users. Emacs itself will never bind those key sequences, and Emacs extensions should avoid binding them. In other words, users can bind key sequences like C-c a or C-c ç and rely on these never being shadowed by other Emacs bindings.


50.3.2 前缀键映射

50.3.2 Prefix Keymaps

在内部,Emacs 仅记录每个键盘映射中的单个事件。解释多个事件的键序列涉及一系列键映射:第一个键映射给出第一个事件的定义,这是另一个键映射,用于查找序列中的第二个事件,依此类推。因此,诸如C-x或 之 类的前缀键ESC有自己的键映射,它保存紧随该前缀的事件的定义。

Internally, Emacs records only single events in each keymap. Interpreting a key sequence of multiple events involves a chain of keymaps: the first keymap gives a definition for the first event, which is another keymap, which is used to look up the second event in the sequence, and so on. Thus, a prefix key such as C-x or ESC has its own keymap, which holds the definition for the event that immediately follows that prefix.

前缀键的定义通常是用于查找后续事件的键映射。定义也可以是一个 Lisp 符号,其函数定义为以下键盘映射;效果是相同的,但它提供了前缀键的命令名称,可以用作前缀键用途的描述。因此, 的绑定C-x是符号Control-X-prefix,其函数定义是命令的键盘映射C-xC-cC-xC-h、 和作为前缀键的定义 ESC出现在全局映射中,因此这些前缀键始终可用。

The definition of a prefix key is usually the keymap to use for looking up the following event. The definition can also be a Lisp symbol whose function definition is the following keymap; the effect is the same, but it provides a command name for the prefix key that can be used as a description of what the prefix key is for. Thus, the binding of C-x is the symbol Control-X-prefix, whose function definition is the keymap for C-x commands. The definitions of C-c, C-x, C-h, and ESC as prefix keys appear in the global map, so these prefix keys are always available.

除了普通的前缀键外,还有一个虚构的“前缀键”,代表菜单栏;有关菜单栏键绑定的特殊信息,请参阅Emacs Lisp 参考手册中的菜单栏。调用弹出菜单的鼠标按钮事件也是前缀键;有关更多详细信息, 请参阅 Emacs Lisp 参考手册中的菜单键映射。

Aside from ordinary prefix keys, there is a fictitious “prefix key” which represents the menu bar; see Menu Bar in The Emacs Lisp Reference Manual, for special information about menu bar key bindings. Mouse button events that invoke pop-up menus are also prefix keys; see Menu Keymaps in The Emacs Lisp Reference Manual, for more details.

一些前缀键映射存储在具有名称的变量中:

Some prefix keymaps are stored in variables with names:

  • ctl-x-map是用于后面的字符的映射的变量名称C-x
  • ctl-x-map is the variable name for the map used for characters that follow C-x.
  • help-map适用于 后面的字符C-h
  • help-map is for characters that follow C-h.
  • esc-map适用于 后面的字符ESC。因此,所有元字符实际上都是由该映射定义的。
  • esc-map is for characters that follow ESC. Thus, all Meta characters are actually defined by this map.
  • ctl-x-4-map适用于 后面的字符C-x 4
  • ctl-x-4-map is for characters that follow C-x 4.
  • mode-specific-map适用于 后面的字符C-c
  • mode-specific-map is for characters that follow C-c.
  • project-prefix-map用于后面的字符C-x p,用于与项目相关的命令(请参阅使用项目)。
  • project-prefix-map is for characters that follow C-x p, used for project-related commands (see Working with Projects).

50.3.3 本地键盘映射

50.3.3 Local Keymaps

到目前为止,我们已经解释了全球地图的来龙去脉。主要模式通过在本地键盘映射中提供自己的键绑定来自定义 Emacs 。例如,C 模式覆盖TAB使其缩进 C 代码的当前行。次要模式也可以有本地键盘映射;每当次要模式生效时,其键盘映射中的定义都会覆盖主要模式的本地键盘映射和全局键盘映射。此外,缓冲区中的文本部分可以指定自己的键盘映射,该键盘映射会覆盖所有其他键盘映射。

So far, we have explained the ins and outs of the global map. Major modes customize Emacs by providing their own key bindings in local keymaps. For example, C mode overrides TAB to make it indent the current line for C code. Minor modes can also have local keymaps; whenever a minor mode is in effect, the definitions in its keymap override both the major mode’s local keymap and the global keymap. In addition, portions of text in the buffer can specify their own keymaps, which override all other keymaps.

本地键映射可以通过将键定义为前缀键映射来将其重新定义为前缀键。如果该键也被全局定义为前缀,则其本地定义和全局定义(两个键映射)有效组合:两个定义都用于查找前缀键后面的事件。例如,如果本地键映射定义C-c为前缀键映射,并且该键映射定义C-z为命令,则这为 提供了本地含义C-c C-z。这不会影响以C-c;开头的其他序列。如果这些序列没有自己的局部绑定,则它们的全局绑定仍然有效。

A local keymap can redefine a key as a prefix key by defining it as a prefix keymap. If the key is also defined globally as a prefix, its local and global definitions (both keymaps) effectively combine: both definitions are used to look up the event that follows the prefix key. For example, if a local keymap defines C-c as a prefix keymap, and that keymap defines C-z as a command, this provides a local meaning for C-c C-z. This does not affect other sequences that start with C-c; if those sequences don’t have their own local bindings, their global bindings remain in effect.

另一种思考方式是,Emacs 通过逐个查找多个键映射来查找整个键序列的绑定,从而处理多事件键序列。首先,它检查次要模式键盘映射以查找已启用的次要模式,然后检查主要模式的键盘映射,然后检查全局键盘映射。这并不完全是键查找的工作原理,但对于理解普通情况下的结果来说已经足够了。

Another way to think of this is that Emacs handles a multi-event key sequence by looking in several keymaps, one by one, for a binding of the whole key sequence. First it checks the minor mode keymaps for minor modes that are enabled, then it checks the major mode’s keymap, and then it checks the global keymap. This is not precisely how key lookup works, but it’s good enough for understanding the results in ordinary circumstances.


50.3.4 迷你缓冲区键盘映射

50.3.4 Minibuffer Keymaps

迷你缓冲区有自己的一组本地键盘映射;它们包含各种完成和退出命令。

The minibuffer has its own set of local keymaps; they contain various completion and exit commands.

  • minibuffer-local-map用于普通输入(无补全)。
  • minibuffer-local-map is used for ordinary input (no completion).
  • minibuffer-local-ns-map类似,只不过SPC退出方式与 一样RET
  • minibuffer-local-ns-map is similar, except that SPC exits just like RET.
  • minibuffer-local-completion-map用于允许完成。
  • minibuffer-local-completion-map is for permissive completion.
  • minibuffer-local-must-match-map一是严格完成,二是谨慎完成。
  • minibuffer-local-must-match-map is for strict completion and for cautious completion.
  • minibuffer-local-filename-completion-map与前两个类似,但专门用于文件名补全。它不绑定SPC
  • minibuffer-local-filename-completion-map is like the two previous ones, but specifically for file name completion. It does not bind SPC.

默认情况下,TABSPC?在 中完成 minibuffer-local-completion-map。如果您通常完成包含带有空格或问号字符的元素的集合,则通过将其放入 init 文件中来禁用这些键上的完成可能会很方便:

By default, TAB, SPC and ? do completion in minibuffer-local-completion-map. If you commonly complete over collections that have elements with space or question mark characters in them, it may be convenient to disable completion on those keys by putting this in your init file:

(keymap-set minibuffer-local-completion-map "SPC" 'self-insert-command)
(keymap-set minibuffer-local-completion-map "?" 'self-insert-command)
(keymap-set minibuffer-local-completion-map "SPC" 'self-insert-command)
(keymap-set minibuffer-local-completion-map "?" 'self-insert-command)

50.3.5 交互更改按键绑定

50.3.5 Changing Key Bindings Interactively

重新定义 Emacs 键的方法是更改​​其在键盘映射中的条目。您可以更改全局键盘映射,在这种情况下,更改在所有主要模式中都有效(除了那些对同一键有自己的覆盖本地绑定的模式)。或者您可以更改本地键盘映射,这会影响使用相同主要模式的所有缓冲区。

The way to redefine an Emacs key is to change its entry in a keymap. You can change the global keymap, in which case the change is effective in all major modes (except those that have their own overriding local bindings for the same key). Or you can change a local keymap, which affects all buffers using the same major mode.

在本节中,我们将描述如何为当前 Emacs 会话重新绑定密钥。有关如何使键重新绑定影响未来 Emacs 会话的说明, 请参阅在初始化文件中重新绑定键。

In this section, we describe how to rebind keys for the present Emacs session. See Rebinding Keys in Your Init File, for a description of how to make key rebindings affect future Emacs sessions.

M-x keymap-global-set RET key cmd RET
M-x keymap-global-set RET key cmd RET

全局定义来运行cmd

Define key globally to run cmd.

M-x keymap-local-set RET key cmd RET
M-x keymap-local-set RET key cmd RET

在本地定义密钥(在现在生效的主要模式中)以运行 cmd

Define key locally (in the major mode now in effect) to run cmd.

M-x keymap-global-unset RET key
M-x keymap-global-unset RET key

使全局映射中的 键未定义。

Make key undefined in the global map.

M-x keymap-local-unset RET key
M-x keymap-local-unset RET key

在本地未定义密钥(在现在有效的主要模式中)。

Make key undefined locally (in the major mode now in effect).

例如,以下内容绑定C-zshell 命令(请参阅Interactive Subshel​​l),替换 的正常全局定义C-z

For example, the following binds C-z to the shell command (see Interactive Subshell), replacing the normal global definition of C-z:

Mx keymap-global-set RETCz shellRET
M-x keymap-global-set RET C-z shell RET

keymap-global-set命令读取按键后的命令名称。按下该键后,会出现如下消息,以便您确认您正在绑定所需的密钥:

The keymap-global-set command reads the command name after the key. After you press the key, a message like this appears so that you can confirm that you are binding the key you want:

将 Cz 键设置为命令:
Set key C-z to command:

您可以用同样的方式重新定义功能键和鼠标事件;当需要指定要重新绑定的键时,只需键入功能键或单击鼠标即可。

You can redefine function keys and mouse events in the same way; just type the function key or click the mouse when it’s time to specify the key to rebind.

您可以用相同的方式重新绑定包含多个事件的键。 Emacs 不断读取要重新绑定的键,直到它是一个完整的键(即不是前缀键)。因此,如果您输入C-ffor key,那就结束了;它立即进入迷你缓冲区来读取cmd。但如果你输入C-x,因为这是一个前缀,它会读取另一个字符;如果是4另一个前缀字符,它会再读取一个字符,依此类推。例如,

You can rebind a key that contains more than one event in the same way. Emacs keeps reading the key to rebind until it is a complete key (that is, not a prefix key). Thus, if you type C-f for key, that’s the end; it enters the minibuffer immediately to read cmd. But if you type C-x, since that’s a prefix, it reads another character; if that is 4, another prefix character, it reads one more character, and so on. For example,

Mx keymap-global-set RETCx 4 $ 拼写其他窗口RET
M-x keymap-global-set RET C-x 4 $ spell-other-window RET

重新定义C-x 4 $运行(虚构的)命令 spell-other-window

redefines C-x 4 $ to run the (fictitious) command spell-other-window.

您可以使用 删除键的全局定义 keymap-global-unset。这使得键未定义;如果你输入它,Emacs 只会发出蜂鸣声。同样,keymap-local-unset使当前主要模式键盘映射中的某个键未定义,这使得全局定义(或缺少全局定义)在该主要模式中重新生效。

You can remove the global definition of a key with keymap-global-unset. This makes the key undefined; if you type it, Emacs will just beep. Similarly, keymap-local-unset makes a key undefined in the current major mode keymap, which makes the global definition (or lack of one) come back into effect in that major mode.

如果您重新定义(或取消定义)了某个键,并且随后希望撤回更改,则取消定义该键将无法完成此任务 - 您需要使用其标准定义重新定义该键。要查找键的标准定义的名称,请转到新 Emacs 中的基本模式缓冲区并使用C-h c.本手册中按键的文档还列出了它们的命令名称。

If you have redefined (or undefined) a key and you subsequently wish to retract the change, undefining the key will not do the job—you need to redefine the key with its standard definition. To find the name of the standard definition of a key, go to a Fundamental mode buffer in a fresh Emacs and use C-h c. The documentation of keys in this manual also lists their command names.

如果您想防止自己错误地调用某个命令,最好禁用该命令而不是取消定义该键。当您真正想要调用时,禁用的命令可以减少调用的工作量。请参阅禁用命令

If you want to prevent yourself from invoking a command by mistake, it is better to disable the command than to undefine the key. A disabled command is less work to invoke when you really want to. See Disabling Commands.


50.3.6 重新绑定初始化文件中的键

50.3.6 Rebinding Keys in Your Init File

如果您有一组想要一直使用的键绑定,则可以通过编写 Lisp 代码在初始化文件中指定它们。有关初始化文件的说明, 请参阅Emacs 初始化文件。

If you have a set of key bindings that you like to use all the time, you can specify them in your initialization file by writing Lisp code. See The Emacs Initialization File, for a description of the initialization file.

使用 Lisp 编写按键绑定的推荐方法是使用 或keymap-global-set函数keymap-set 。例如,以下是如何绑定C-zshell全局键盘映射中的命令(请参阅Interactive Subshel​​l):

The recommended way to write a key binding using Lisp is to use either the keymap-global-set or the keymap-set functions. For example, here’s how to bind C-z to the shell command in the global keymap (see Interactive Subshell):

(键盘映射全局设置“Cz”'shell)
(keymap-global-set "C-z" 'shell)

第一个参数keymap-global-set描述按键序列。它是由一系列用空格分隔的字符组成的字符串,每个字符对应一个键。带有修饰符的键可以通过在前面添加修饰符来指定,例如 'C-' 用于控制,或 'M-'对于元。特殊键,例如 TABRET,可以在尖括号内指定,如 TABRET

The first argument to keymap-global-set describes the key sequence. It is a string made of a series of characters separated by spaces, with each character corresponding to a key. Keys with modifiers can be specified by prepending the modifier, such as ‘C-’ for Control, or ‘M-’ for Meta. Special keys, such as TAB and RET, can be specified within angle brackets as in TAB and RET.

在上面的示例中,绑定到按键序列的命令名称之前的单引号shell将其标记为常量符号而不是变量。如果省略引号,Emacs 会尝试将其shell作为变量进行计算。这可能会导致错误;这当然不是你想要的。

The single-quote before the command name that is being bound to the key sequence, shell in the above example, marks it as a constant symbol rather than a variable. If you omit the quote, Emacs would try to evaluate shell as a variable. This will probably cause an error; it certainly isn’t what you want.

以下是一些其他示例,包括绑定功能键和鼠标事件:

Here are some additional examples, including binding function keys and mouse events:

(keymap-global-set "Cc y" '剪贴板-yank)
(键盘映射全局设置“CMq”'查询替换)
(keymap-global-set "<f5>" 'flyspell-mode)
(键盘映射全局设置“C-<f5>”'显示行号模式)
(keymap-global-set "C-<right>" '正向句子)
(keymap-global-set "<mouse-2>" 'mouse-save-then-kill)
(keymap-global-set "C-c y" 'clipboard-yank)
(keymap-global-set "C-M-q" 'query-replace)
(keymap-global-set "<f5>" 'flyspell-mode)
(keymap-global-set "C-<f5>" 'display-line-numbers-mode)
(keymap-global-set "C-<right>" 'forward-sentence)
(keymap-global-set "<mouse-2>" 'mouse-save-then-kill)

语言和编码系统可能会导致非ASCII字符的键绑定问题。请参见初始化文件中的ASCII字符。

Language and coding systems may cause problems with key bindings for non-ASCII characters. See Non-ASCII Characters in Init Files.

或者,您可以使用低级函数define-keyglobal-set-key。例如,要绑定C-zshell命令(如上例所示),使用这些低级函数,请使用:

Alternatively, you can use the low level functions define-key and global-set-key. For example, to bind C-z to the shell command, as in the above example, using these low-level functions, use:

(全局设置键(kbd“Cz”)'shell)
(global-set-key (kbd "C-z") 'shell)

有多种方法可以指定按键顺序,但最简单的是使用kbd上面示例中所示的函数。 kbd接受一个字符串参数,该参数是键序列的文本表示形式,并将其转换为适合低级函数(例如global-set-key.有关使用 Lisp 绑定键的更多详细信息,请参阅Emacs Lisp 参考手册中的键映射

There are various ways to specify the key sequence but the simplest is to use the function kbd as shown in the example above. kbd takes a single string argument that is a textual representation of a key sequence, and converts it into a form suitable for low-level functions such as global-set-key. For more details about binding keys using Lisp, see Keymaps in The Emacs Lisp Reference Manual.

本地键盘映射中所述,主要模式和次要模式可以定义本地键盘映射。这些键映射是在会话中首次加载模式时构建的。该函数keymap-set 可用于更改特定的键盘映射。要删除键绑定,请使用keymap-unset.

As described in Local Keymaps, major modes and minor modes can define local keymaps. These keymaps are constructed when the mode is loaded for the first time in a session. The function keymap-set can be used to make changes in a specific keymap. To remove a key binding, use keymap-unset.

由于模式的键映射在加载后才会构建,因此您必须延迟运行修改它们的代码,例如,将其放在模式挂钩上(请参阅Hooks)。例如,Texinfo 模式运行 hook texinfo-mode-hook。以下是如何使用钩子为C-c n和添加本地绑定,并在 Texinfo 模式下 C-c p删除 for 的绑定:C-c C-x x

Since a mode’s keymaps are not constructed until it has been loaded, you must delay running code which modifies them, e.g., by putting it on a mode hook (see Hooks). For example, Texinfo mode runs the hook texinfo-mode-hook. Here’s how you can use the hook to add local bindings for C-c n and C-c p, and remove the one for C-c C-x x in Texinfo mode:

(添加钩子'texinfo-mode-hook
          (拉姆达()
            (键盘映射设置 texinfo-mode-map "Cc p"
                        '向后段落)
            (键盘映射设置 texinfo-mode-map "Cc n"
                        '前段)
            (键盘映射设置 texinfo-mode-map "Cc Cx x" nil)))
(add-hook 'texinfo-mode-hook
          (lambda ()
            (keymap-set texinfo-mode-map "C-c p"
                        'backward-paragraph)
            (keymap-set texinfo-mode-map "C-c n"
                        'forward-paragraph)
            (keymap-set texinfo-mode-map "C-c C-x x" nil)))

50.3.7 修饰键

50.3.7 Modifier Keys

Emacs 中的默认键绑定设置为修改后的字母字符不区分大小写。换句话说, C-A与 做同样的事情C-a, 和M-A做同样的事情M-a。这仅涉及字母字符,不适用于其他键的移位版本;例如,C-@与 不一样C-2

The default key bindings in Emacs are set up so that modified alphabetical characters are case-insensitive. In other words, C-A does the same thing as C-a, and M-A does the same thing as M-a. This concerns only alphabetical characters, and does not apply to shifted versions of other keys; for instance, C-@ is not the same as C-2.

- 修饰的字母字符Control通常被认为不区分大小写:Emacs 始终将C-Aas C-aC-BasC-b等视为。其原因是历史性的:在非图形环境中,这些击键之间没有区别。但是,您可以Control 在 GUI 框架中绑定移位的字母击键:

A Control-modified alphabetical character is generally considered case-insensitive: Emacs always treats C-A as C-a, C-B as C-b, and so forth. The reason for this is historical: In non-graphical environments there is no distinction between those keystrokes. However, you can bind shifted Control alphabetical keystrokes in GUI frames:

(keymap-global-set "CSn" #'前一行)
(keymap-global-set "C-S-n" #'previous-line)

对于所有其他修饰符,您可以在自定义 Emacs 时使修改的字母字符区分大小写(即使在非图形框架上)。例如,您可以创建M-aM-A 运行不同的命令。

For all other modifiers, you can make the modified alphabetical characters case-sensitive (even on non-graphical frames) when you customize Emacs. For instance, you could make M-a and M-A run different commands.

尽管通常只使用Control和修饰键,但 Emacs 还支持其他三个修饰键。Meta这些称为SuperHyperAlt。很少有终端提供使用这些修饰符的方法;大多数键盘上标记的键Alt通常发出Meta修饰符,而不是Alt。 Emacs 中的标准键绑定不包含任何带有 和 Super修饰符的字符Hyper,并且只有少数标准键绑定使用Alt。但是,您可以自定义 Emacs 来为使用这些修饰符的键绑定指定含义。修饰符位标记为 's-','H-' 和 'A-' 分别。

Although only the Control and Meta modifier keys are commonly used, Emacs supports three other modifier keys. These are called Super, Hyper, and Alt. Few terminals provide ways to use these modifiers; the key labeled Alt on most keyboards usually issues the Meta modifier, not Alt. The standard key bindings in Emacs do not include any characters with the Super and Hyper modifiers, and only a small number of standard key bindings use Alt. However, you can customize Emacs to assign meanings to key bindings that use these modifiers. The modifier bits are labeled as ‘s-’, ‘H-’ and ‘A-’ respectively.

即使您的键盘缺少这些附加修饰键,您也可以使用以下方式输入它们C-x @C-x @ h将 Hyper 标志添加到下一个字符,C-x @ s添加 Super 标志,然后 C-x @ a添加 Alt 标志。例如,C-x @ h C-a是一种输入方式Hyper-Control-a。 (不幸的是,无法通过C-x @对同一字符使用两次来添加两个修饰符,因为第一个修饰符适用于。)您可以类似地分别使用、和C-x来输入 Shift、Control 和 Meta 修饰符,尽管很少需要这样做。 C-x @ SC-x @ cC-x @ m

Even if your keyboard lacks these additional modifier keys, you can enter them using C-x @: C-x @ h adds the Hyper flag to the next character, C-x @ s adds the Super flag, and C-x @ a adds the Alt flag. For instance, C-x @ h C-a is a way to enter Hyper-Control-a. (Unfortunately, there is no way to add two modifiers by using C-x @ twice for the same character, because the first one goes to work on the C-x.) You can similarly enter the Shift, Control, and Meta modifiers by using C-x @ S, C-x @ c, and C-x @ m, respectively, although this is rarely needed.


50.3.8 重新绑定功能键

50.3.8 Rebinding Function Keys

按键序列可以包含功能键以及普通字符。正如 Lisp 字符(实际上是整数)代表键盘字符一样,Lisp 符号代表功能键。如果功能键有一个单词作为其标签,那么该单词也是相应 Lisp 符号的名称。以下是常用功能键的常规 Lisp 名称:

Key sequences can contain function keys as well as ordinary characters. Just as Lisp characters (actually integers) represent keyboard characters, Lisp symbols represent function keys. If the function key has a word as its label, then that word is also the name of the corresponding Lisp symbol. Here are the conventional Lisp names for common function keys:

left, up, right,down
left, up, right, down

光标箭头键。

Cursor arrow keys.

begin, end, home, next,prior
begin, end, home, next, prior

其他光标重新定位键。

Other cursor repositioning keys.

select, print, execute,backtab
select, print, execute, backtab
insert, undo, redo,clearline
insert, undo, redo, clearline
insertline, deleteline, insertchar,deletechar
insertline, deleteline, insertchar, deletechar

各种功能键。

Miscellaneous function keys.

f1, f2, …f35
f1, f2, … f35

编号功能键(位于键盘顶部)。

Numbered function keys (across the top of the keyboard).

kp-add, kp-subtract, kp-multiply,kp-divide
kp-add, kp-subtract, kp-multiply, kp-divide
kp-backtab, kp-space, kp-tab,kp-enter
kp-backtab, kp-space, kp-tab, kp-enter
kp-separator, kp-decimal,kp-equal
kp-separator, kp-decimal, kp-equal
kp-prior, kp-next, kp-end,kp-home
kp-prior, kp-next, kp-end, kp-home
kp-left, kp-up, kp-right,kp-down
kp-left, kp-up, kp-right, kp-down
kp-insert ,kp-delete
kp-insert , kp-delete

小键盘按键(位于常规键盘的右侧),带有名称或标点符号。

Keypad keys (to the right of the regular keyboard), with names or punctuation.

kp-0, kp-1, …kp-9
kp-0, kp-1, … kp-9

带数字的键盘按键。

Keypad keys with digits.

kp-f1, kp-f2, kp-f3,kp-f4
kp-f1, kp-f2, kp-f3, kp-f4

键盘 PF 键。

Keypad PF keys.

这些名称是约定俗成的,但某些系统(尤其是使用 X 时)可能会使用不同的名称。要确定终端上给定功能键使用什么符号,请键入C-h c后跟该键。

These names are conventional, but some systems (especially when using X) may use different names. To make certain what symbol is used for a given function key on your terminal, type C-h c followed by that key.

有关绑定功能键的示例, 请参阅在初始化文件中重新绑定键。

See Rebinding Keys in Your Init File, for examples of binding function keys.

许多键盘的右侧都有一个数字小键盘。键盘中的数字键兼作光标运动键,通过标有 ' 的键进行切换数字键盘(的第一个键'。默认情况下,Emacs 会将这些键转换为主键盘上的相应键。例如,当 '数字键盘(的第一个键' 已打开,按键标记为 '8数字键盘上会生成 ' kp-8,翻译为 8;什么时候 '数字键盘(的第一个键' 关闭,同一键产生 kp-up,被转换为UP.如果您重新绑定某个键(例如8或 )UP,它也会影响等效的键盘键。但是,如果您重新绑定 'kp-' 直接键入,这不会影响其非键盘等效项。请注意,修改后的键不会被翻译:例如,如果您Meta在按住该键的同时按 '8' 数字键盘上的键,会生成 . M-kp-8

Many keyboards have a numeric keypad on the right-hand side. The numeric keys in the keypad double up as cursor motion keys, toggled by a key labeled ‘Num Lock’. By default, Emacs translates these keys to the corresponding keys on the main keyboard. For example, when ‘Num Lock’ is on, the key labeled ‘8’ on the numeric keypad produces kp-8, which is translated to 8; when ‘Num Lock’ is off, the same key produces kp-up, which is translated to UP. If you rebind a key such as 8 or UP, it affects the equivalent keypad key too. However, if you rebind a ‘kp-’ key directly, that won’t affect its non-keypad equivalent. Note that the modified keys are not translated: for instance, if you hold down the Meta key while pressing the ‘8’ key on the numeric keypad, that generates M-kp-8.

Emacs 提供了一种使用变量keypad-setupkeypad-numlock-setupkeypad-shifted-setup和 来绑定数字小键盘按键的便捷方法keypad-numlock-shifted-setup。这些可以在“键盘' 自定义组(请参阅轻松自定义界面)。您可以重新绑定键以执行其他任务,例如发出数字前缀参数。

Emacs provides a convenient method for binding the numeric keypad keys, using the variables keypad-setup, keypad-numlock-setup, keypad-shifted-setup, and keypad-numlock-shifted-setup. These can be found in the ‘keyboard’ customization group (see Easy Customization Interface). You can rebind the keys to perform other tasks, such as issuing numeric prefix arguments.


50.3.9 命名ASCII控制字符

50.3.9 Named ASCII Control Characters

TABRETBS、 、LFDESCDEL 最初是某些ASCII控制字符的名称,使用频率很高,因此它们有自己的特殊键。例如, TAB是 的另一个名称C-i。后来,用户发现在 Emacs 中可以很方便地区分这些键和用该键键入的相应控制字符Ctrl。因此,在大多数现代终端上,它们不再相同:TAB不同于C-i

TAB, RET, BS, LFD, ESC, and DEL started out as names for certain ASCII control characters, used so often that they have special keys of their own. For instance, TAB was another name for C-i. Later, users found it convenient to distinguish in Emacs between these keys and the corresponding control characters typed with the Ctrl key. Therefore, on most modern terminals, they are no longer the same: TAB is different from C-i.

如果键盘可以区分这两种输入,Emacs 就可以区分。它将特殊键视为名为tabreturnbackspacelinefeedescape和 的 功能键delete如果这些功能键没有自己的绑定,它们会自动转换为相应的ASCII字符。因此,用户和 Lisp 程序都不需要注意这种区别,除非他们愿意。

Emacs can distinguish these two kinds of input if the keyboard does. It treats the special keys as function keys named tab, return, backspace, linefeed, escape, and delete. These function keys translate automatically into the corresponding ASCII characters if they have no bindings of their own. As a result, neither users nor Lisp programs need to pay attention to the distinction unless they care to.

如果您不想区分 (例如)TAB和 ,请仅针对ASCII字符 (八进制代码 011)C-i进行一个绑定。如果您确实想进行区分,请为该ASCII字符创建一个绑定,并为功能键创建另一个绑定。 TABtab

If you do not want to distinguish between (for example) TAB and C-i, make just one binding, for the ASCII character TAB (octal code 011). If you do want to distinguish, make one binding for this ASCII character, and another for the function key tab.

对于普通的ASCII终端,无法区分TABC-i(对于其他此类对也是如此),因为终端在这两种情况下发送相同的字符。

With an ordinary ASCII terminal, there is no way to distinguish between TAB and C-i (and likewise for other such pairs), because the terminal sends the same character in both cases.


50.3.10 重新绑定鼠标按钮

50.3.10 Rebinding Mouse Buttons

Emacs 也使用 Lisp 符号来指定鼠标按钮。 Emacs中普通的鼠标事件是点击事件;当您按下按钮并在不移动鼠标的情况下释放它时,就会发生这种情况。当您按住按钮移动鼠标时,您还可以获得拖动事件。当您最终松开按钮时,拖动事件就会发生。

Emacs uses Lisp symbols to designate mouse buttons, too. The ordinary mouse events in Emacs are click events; these happen when you press a button and release it without moving the mouse. You can also get drag events, when you move the mouse while holding the button down. Drag events happen when you finally let go of the button.

基本点击事件的符号mouse-1代表最左边的按钮,mouse-2代表下一个按钮,依此类推。以下是如何重新定义第二个鼠标按钮来分割当前窗口:

The symbols for basic click events are mouse-1 for the leftmost button, mouse-2 for the next, and so on. Here is how you can redefine the second mouse button to split the current window:

(keymap-global-set "<mouse-2>" '分割窗口下方)
(keymap-global-set "<mouse-2>" 'split-window-below)

拖动事件的符号类似,但有前缀 '拖-'在这个词之前'老鼠'。例如,拖动第一个按钮会生成一个drag-mouse-1事件。

The symbols for drag events are similar, but have the prefix ‘drag-’ before the word ‘mouse’. For example, dragging the first button generates a drag-mouse-1 event.

您还可以定义按下鼠标按钮时发生的事件的绑定。这些事件以 '向下-' 代替 '拖-'。仅当此类事件具有键绑定时才会生成。当您收到按钮按下事件时,将始终跟随相应的单击或拖动事件。

You can also define bindings for events that occur when a mouse button is pressed down. These events start with ‘down-’ instead of ‘drag-’. Such events are generated only if they have key bindings. When you get a button-down event, a corresponding click or drag event will always follow.

如果您愿意,您可以区分单击、双击和三次单击。双击是指在大致相同的位置单击鼠标按钮两次。第一次点击会生成一个普通的点击事件。第二次单击(如果发生得足够快)会生成双击事件。双击事件的事件类型以 ' 开头双倍的-': 例如,double-mouse-3

If you wish, you can distinguish single, double, and triple clicks. A double click means clicking a mouse button twice in approximately the same place. The first click generates an ordinary click event. The second click, if it comes soon enough, generates a double-click event instead. The event type for a double-click event starts with ‘double-’: for example, double-mouse-3.

这意味着您可以为同一位置的第二次单击赋予特殊含义,但它必须假设在收到第一次单击时已运行普通单击定义。

This means that you can give a special meaning to the second click at the same place, but it must act on the assumption that the ordinary single click definition has run when the first click was received.

这限制了双击可以执行的操作,但用户界面设计者表示在任何情况下都应该遵循此限制。双击应该执行与单击类似的操作,甚至更多。双击事件的命令应该执行双击的额外工作。

This constrains what you can do with double clicks, but user interface designers say that this constraint ought to be followed in any case. A double click should do something similar to the single click, only more so. The command for the double-click event should perform the extra work for the double click.

如果双击事件没有绑定,则变为相应的单击事件。因此,如果您没有专门定义特定的双击,它将执行单击命令两次。

If a double-click event has no binding, it changes to the corresponding single-click event. Thus, if you don’t define a particular double click specially, it executes the single-click command twice.

Emacs 还支持名称以 ' 开头的三次单击事件三倍-'。 Emacs 不将四次单击区分为事件类型;超过第三次的点击会生成额外的三次点击事件。然而,完整的点击次数记录在事件列表中,因此如果您了解 Emacs Lisp,您可以区分是否确实需要(请参阅Emacs Lisp 参考手册中的“点击事件”)。我们不建议超过三次的点击具有不同的含义,但有时,对于后续点击循环浏览同一组三个含义是有用的,这样四次点击相当于一次点击,五次相当于两次,六次相当于一次点击。相当于三。

Emacs also supports triple-click events whose names start with ‘triple-’. Emacs does not distinguish quadruple clicks as event types; clicks beyond the third generate additional triple-click events. However, the full number of clicks is recorded in the event list, so if you know Emacs Lisp you can distinguish if you really want to (see Click Events in The Emacs Lisp Reference Manual). We don’t recommend distinct meanings for more than three clicks, but sometimes it is useful for subsequent clicks to cycle through the same set of three meanings, so that four clicks are equivalent to one click, five are equivalent to two, and six are equivalent to three.

Emacs 还记录拖动和按钮按下事件中的多次按下。例如,当您按两次按钮,然后在按住按钮的同时移动鼠标,Emacs 会得到一个 '双击-' 事件。当你第二次按下它时,Emacs 会得到一个 '双下-' 事件(与所有按钮按下事件一样,如果没有绑定,则会被忽略)。

Emacs also records multiple presses in drag and button-down events. For example, when you press a button twice, then move the mouse while holding the button, Emacs gets a ‘double-drag-’ event. And at the moment when you press it down for the second time, Emacs gets a ‘double-down-’ event (which is ignored, like all button-down events, if it has no binding).

该变量double-click-time指定两次单击之间可以间隔多长时间,并且仍然允许将它们分组为多次单击。其值以毫秒为单位。如果值为 nil,则根本不会检测双击。如果值为 t,则没有时间限制。默认值为 500。

The variable double-click-time specifies how much time can elapse between clicks and still allow them to be grouped as a multiple click. Its value is in units of milliseconds. If the value is nil, double clicks are not detected at all. If the value is t, then there is no time limit. The default is 500.

该变量double-click-fuzz指定鼠标在单击之间可以移动的距离,并且仍然允许将它们分组为多次单击。它的值在窗口显示上以像素为单位,在文本模式终端上以字符单元的 1/8 为单位;默认值为 3。

The variable double-click-fuzz specifies how much the mouse can move between clicks and still allow them to be grouped as a multiple click. Its value is in units of pixels on windowed displays and in units of 1/8 of a character cell on text-mode terminals; the default is 3.

鼠标事件的符号还指示修饰键的状态,带有常见的前缀 'C-','M-','H-','s-','A-', 和 'S-'。这些总是先于 '双倍的-' 或者 '三倍-',总是先于 '拖-' 或者 '向下-'。

The symbols for mouse events also indicate the status of the modifier keys, with the usual prefixes ‘C-’, ‘M-’, ‘H-’, ‘s-’, ‘A-’, and ‘S-’. These always precede ‘double-’ or ‘triple-’, which always precede ‘drag-’ or ‘down-’.

框架包含不显示缓冲区中文本的区域,例如模式行和滚动条。您可以通过虚拟前缀键来判断鼠标按钮是否来自屏幕的特殊区域。例如,如果在模式行中单击鼠标,则会mode-line在普通鼠标按钮符号之前获得前缀键。因此,以下是如何定义单击模式行中的第一个按钮来运行的命令scroll-up-command

A frame includes areas that don’t show text from the buffer, such as the mode line and the scroll bar. You can tell whether a mouse button comes from a special area of the screen by means of dummy prefix keys. For example, if you click the mouse in the mode line, you get the prefix key mode-line before the ordinary mouse-button symbol. Thus, here is how to define the command for clicking the first button in a mode line to run scroll-up-command:

(keymap-global-set "<mode-line> <mouse-1>" '向上滚动命令)
(keymap-global-set "<mode-line> <mouse-1>" 'scroll-up-command)

以下是这些虚拟前缀键及其含义的完整列表:

Here is the complete list of these dummy prefix keys and their meanings:

mode-line
mode-line

鼠标位于窗口的模式行中。

The mouse was in the mode line of a window.

vertical-line
vertical-line

鼠标位于分隔并排窗口的垂直线上。 (如果您使用滚动条,它们会出现在这些垂直线的位置。)

The mouse was in the vertical line separating side-by-side windows. (If you use scroll bars, they appear in place of these vertical lines.)

vertical-scroll-bar
vertical-scroll-bar

鼠标位于垂直滚动条中。 (这是 Emacs 目前唯一支持的滚动条。)

The mouse was in a vertical scroll bar. (This is the only kind of scroll bar Emacs currently supports.)

menu-bar
menu-bar

鼠标位于菜单栏中。

The mouse was in the menu bar.

tab-bar
tab-bar

鼠标位于标签栏中。

The mouse was in a tab bar.

tab-line
tab-line

鼠标位于制表符行中。

The mouse was in a tab line.

header-line
header-line

鼠标位于标题行中。

The mouse was in a header line.

您可以在一个按键序列中放置多个鼠标按钮,但通常不这样做。

You can put more than one mouse button in a key sequence, but it isn’t usual to do so.


50.3.11 禁用命令

50.3.11 Disabling Commands

禁用命令意味着以交互方式调用它需要用户确认。禁用命令的目的是为了防止用户意外执行该命令;我们这样做是为了那些可能会让外行人感到困惑的命令。

Disabling a command means that invoking it interactively asks for confirmation from the user. The purpose of disabling a command is to prevent users from executing it by accident; we do this for commands that might be confusing to the uninitiated.

尝试在 Emacs 中交互调用禁用的命令会显示一个窗口,其中包含该命令的名称、其文档以及有关立即执行操作的一些说明;然后 Emacs 要求输入是否按照请求执行命令、启用并执行命令,或者取消。如果您决定启用该命令,则必须回答另一个问题 - 是永久执行此操作,还是仅针对当前会话执行此操作。 (通过自动编辑初始化文件来永久启用。)您还可以键入 以仅针对当前会话 !启用所有命令。

Attempting to invoke a disabled command interactively in Emacs displays a window containing the command’s name, its documentation, and some instructions on what to do immediately; then Emacs asks for input saying whether to execute the command as requested, enable it and execute it, or cancel. If you decide to enable the command, you must then answer another question—whether to do this permanently, or just for the current session. (Enabling permanently works by automatically editing your initialization file.) You can also type ! to enable all commands, for the current session only.

禁用命令的直接机制是nil disabled在该命令的 Lisp 符号上放置一个非属性。下面是执行此操作的 Lisp 程序:

The direct mechanism for disabling a command is to put a non-nil disabled property on the Lisp symbol for the command. Here is the Lisp program to do this:

(将“删除区域”禁用)
(put 'delete-region 'disabled t)

如果属性的值disabled是字符串,则该字符串将包含在使用命令时显示的消息中:

If the value of the disabled property is a string, that string is included in the message displayed when the command is used:

(将“删除区域”禁用
     “最好使用‘kill-region’来代替。\n”)
(put 'delete-region 'disabled
     "It's better to use `kill-region' instead.\n")

作为禁用命令的一种不太严厉的替代方法,您可能希望在执行命令之前被查询。例如,要在执行M->( end-of-buffer) 命令之前进行查询,您可以在 init 文件中添加类似以下内容:

As a less heavy-handed alternative to disabling commands, you may want to be queried before executing a command. For instance, to be queried before executing the M-> (end-of-buffer) command, you could put something like the following in your init file:

(命令查询
 '缓冲区结束
 “你真的想走到缓冲区的末尾吗?”)
(command-query
 'end-of-buffer
 "Do you really want to go to the end of the buffer?")

y默认情况下,您将使用/问题进行查询n,但如果您nil为第三个可选参数提供非值,则会使用yes/进行查询no

By default, you’ll be queried with a y/n question, but if you give a non-nil value to the third, optional argument, you’ll be queried with yes/no instead.

您可以通过直接编辑初始化文件或使用命令来禁用命令,M-x disable-command该命令会为您编辑初始化文件。同样,M-x enable-command编辑初始化文件以永久启用命令。请参阅Emacs 初始化文件

You can make a command disabled either by editing the initialization file directly, or with the command M-x disable-command, which edits the initialization file for you. Likewise, M-x enable-command edits the initialization file to enable a command permanently. See The Emacs Initialization File.

如果使用以下命令调用 Emacs-q或者--无初始化文件 选项(请参阅初始选项),它不会编辑您的初始化文件。这样做可能会丢失信息,因为 Emacs 尚未读取您的初始化文件。

If Emacs was invoked with the -q or --no-init-file options (see Initial Options), it will not edit your initialization file. Doing so could lose information because Emacs has not read your initialization file.

命令是否被禁用与调用它的键无关;如果使用 调用该命令,禁用也适用 M-x。然而,禁用命令对于从 Lisp 程序中将其作为函数调用没有影响。

Whether a command is disabled is independent of what key is used to invoke it; disabling also applies if the command is invoked using M-x. However, disabling a command has no effect on calling it as a function from Lisp programs.


50.4 Emacs初始化文件

50.4 The Emacs Initialization File

当 Emacs 启动时,它通常会尝试从初始化文件(简称init 文件)加载 Lisp 程序。该文件(如果存在)指定如何为您初始化 Emacs。传统上,文件〜/.emacs用作 init 文件,尽管 Emacs 也会查看〜/ .emacs.el,〜/.emacs.d/init.el, 〜/.config/emacs/init.el,或其他地点。请参阅Emacs 如何查找您的初始化文件

When Emacs is started, it normally tries to load a Lisp program from an initialization file, or init file for short. This file, if it exists, specifies how to initialize Emacs for you. Traditionally, file ~/.emacs is used as the init file, although Emacs also looks at ~/.emacs.el, ~/.emacs.d/init.el, ~/.config/emacs/init.el, or other locations. See How Emacs Finds Your Init File.

您可能会发现将所有 Emacs 配置放在一个目录中很方便,在这种情况下您应该使用〜/.emacs.d/init.el或 XDG 兼容〜/.config/emacs/init.el

You may find it convenient to have all your Emacs configuration in one directory, in which case you should use ~/.emacs.d/init.el or the XDG-compatible ~/.config/emacs/init.el.

您可以使用命令行开关'-q' 以防止加载您的初始化文件,并且 '-u' (或者 '- 用户') 来指定不同用户的初始化文件(请参阅初始选项)。

You can use the command line switch ‘-q’ to prevent loading your init file, and ‘-u’ (or ‘--user’) to specify a different user’s init file (see Initial Options).

还可以有一个默认的初始化文件,它是名为的库默认值.el,通过库的标准搜索路径找到。 Emacs 发行版不包含这样的库;您的站点可能会创建一个用于本地自定义的站点。如果此库存在,则每当您启动 Emacs 时都会加载它(除非您指定 '-q')。但是你的初始化文件(如果有的话)会首先加载;如果它设置 inhibit-default-init为非nil,那么默认未加载。

There can also be a default init file, which is the library named default.el, found via the standard search path for libraries. The Emacs distribution contains no such library; your site may create one for local customizations. If this library exists, it is loaded whenever you start Emacs (except when you specify ‘-q’). But your init file, if any, is loaded first; if it sets inhibit-default-init non-nil, then default is not loaded.

您的站点可能还有一个站点启动文件;这被命名为 站点启动.el,如果存在的话。喜欢默认值.el,Emacs 通过 Lisp 库的标准搜索路径找到该文件。 Emacs 在加载你的 init 文件之前加载这个库。要禁止加载该库,请使用选项 '--无站点文件'。请参阅初始选项。我们建议不要使用 站点启动.el一些用户可能不喜欢的更改。最好把它们放进去默认值.el,以便用户可以更轻松地覆盖它们。

Your site may also have a site startup file; this is named site-start.el, if it exists. Like default.el, Emacs finds this file via the standard search path for Lisp libraries. Emacs loads this library before it loads your init file. To inhibit loading of this library, use the option ‘--no-site-file’. See Initial Options. We recommend against using site-start.el for changes that some users may not like. It is better to put them in default.el, so that users can more easily override them.

您可以放置默认值.el站点启动.el在 Emacs 搜索 Lisp 库的任何目录中。变量 load-path(请参阅Emacs 的 Lisp 代码库)指定这些目录。许多网站将这些文件放在名为的子目录中站点 Lisp在Emacs安装目录下,比如 /usr/local/share/emacs/site-lisp

You can place default.el and site-start.el in any of the directories which Emacs searches for Lisp libraries. The variable load-path (see Libraries of Lisp Code for Emacs) specifies these directories. Many sites put these files in a subdirectory named site-lisp in the Emacs installation directory, such as /usr/local/share/emacs/site-lisp.

不建议对 init 文件进行字节编译(请参阅Emacs Lisp 参考手册中的字节编译)。它通常不会加快启动速度,并且当您忘记重新编译文件时常常会导致问题。更好的解决方案是使用 Emacs 服务器来减少启动 Emacs 的次数(请参阅使用 Emacs 作为服务器)。如果您的 init 文件定义了许多函数,请考虑将它们移动到您在 init 文件中加载的单独(字节编译)文件。

Byte-compiling your init file is not recommended (see Byte Compilation in the Emacs Lisp Reference Manual). It generally does not speed up startup very much, and often leads to problems when you forget to recompile the file. A better solution is to use the Emacs server to reduce the number of times you have to start Emacs (see Using Emacs as a Server). If your init file defines many functions, consider moving them to a separate (byte-compiled) file that you load in your init file.

如果您要编写超出小型定制范围的实际 Emacs Lisp 程序,您应该阅读Emacs Lisp 参考手册。请参阅Emacs Lisp 参考手册中的Emacs Lisp

If you are going to write actual Emacs Lisp programs that go beyond minor customization, you should read the Emacs Lisp Reference Manual. See Emacs Lisp in the Emacs Lisp Reference Manual.


50.4.1 初始化文件语法

50.4.1 Init File Syntax

init 文件包含一个或多个 Lisp 表达式。其中每个都包含一个函数名,后跟参数,所有参数都用括号括起来。例如,(setq fill-column 60)调用函数setq将变量fill-column (请参阅填充文本)设置为 60。

The init file contains one or more Lisp expressions. Each of these consists of a function name followed by arguments, all surrounded by parentheses. For example, (setq fill-column 60) calls the function setq to set the variable fill-column (see Filling Text) to 60.

您可以使用 来设置任何 Lisp 变量setq,但某些变量setq不会执行您在 init 文件中可能想要的操作。当使用setq;设置时,某些变量会自动成为缓冲区本地变量 。您想要在 init 文件中设置默认值,使用setq-default. (以下部分提供了这两种方法的示例。)

You can set any Lisp variable with setq, but with certain variables setq won’t do what you probably want in the init file. Some variables automatically become buffer-local when set with setq; what you want in the init file is to set the default value, using setq-default. (The following section has examples of both of these methods.)

一些可自定义的次要模式变量会在您使用“自定义”设置它们时执行特殊操作来启用该模式,但普通变量setq不会这样做;要在初始化文件中启用该模式,请调用次要模式命令。最后,一些可自定义的用户选项以复杂的方式初始化,并且必须通过自定义界面(请参阅自定义)或使用 customize-set-variable/ setopt(请参阅检查和设置变量)来设置这些选项。

Some customizable minor mode variables do special things to enable the mode when you set them with Customize, but ordinary setq won’t do that; to enable the mode in your init file, call the minor mode command. Finally, a few customizable user options are initialized in complex ways, and these have to be set either via the customize interface (see Customization), or by using customize-set-variable/setopt (see Examining and Setting Variables).

第二个参数setq是变量新值的表达式。这可以是常量、变量或函数调用表达式。在init文件中,大部分时候都会用到常量。他们可以:

The second argument to setq is an expression for the new value of the variable. This can be a constant, a variable, or a function call expression. In the init file, constants are used most of the time. They can be:

数字:
Numbers:

数字以十进制书写,带有可选的初始减号。

Numbers are written in decimal, with an optional initial minus sign.

字符串:
Strings:

Lisp 字符串语法与 C 字符串语法相同,但有一些额外的功能。使用双引号字符来开始和结束字符串常量。

在字符串中,您可以按字面意思包含换行符和特殊字符。但通常使用反斜杠序列会更干净:'\n'对于换行符,'\b'用于退格键,'\r' 对于回车,'\t'对于选项卡,'\F' 用于换页(control-L),'\e'为了逃避,'\\' 对于反斜杠,'\"' 用于双引号,或 '\噢噢' 对于八进制代码为ooo的字符。反斜杠和双引号是唯一强制使用反斜杠序列的字符。

'\C-' 可以用作控制字符的前缀,如 '\CS' 表示ASCII控制-S,并且 '\M-' 可以用作元字符的前缀,如 '\嘛'对于Meta-A或'\M-\Ca' 为了。 Ctrl-Meta-A

有关在初始化文件中包含非ASCII 的信息,请参阅初始化文件中的ASCII字符

Lisp string syntax is the same as C string syntax with a few extra features. Use a double-quote character to begin and end a string constant.

In a string, you can include newlines and special characters literally. But often it is cleaner to use backslash sequences for them: ‘\n’ for newline, ‘\b’ for backspace, ‘\r’ for carriage return, ‘\t’ for tab, ‘\f’ for formfeed (control-L), ‘\e’ for escape, ‘\\’ for a backslash, ‘\"’ for a double-quote, or ‘\ooo’ for the character whose octal code is ooo. Backslash and double-quote are the only characters for which backslash sequences are mandatory.

\C-’ can be used as a prefix for a control character, as in ‘\C-s’ for ASCII control-S, and ‘\M-’ can be used as a prefix for a Meta character, as in ‘\M-a’ for Meta-A or ‘\M-\C-a’ for Ctrl-Meta-A.

See Non-ASCII Characters in Init Files, for information about including non-ASCII in your init file.

人物:
Characters:

Lisp 字符常量语法由 '' 后跟一个字符或以 ' 开头的转义序列\'。例子:?x?\n?\"?\)。请注意,字符串和字符在 Lisp 中不可互换;有些上下文需要其中之一,有些上下文需要另一个。

有关将命令绑定到发送非ASCII字符的键的信息,请参阅初始化文件中的ASCII字符。

Lisp character constant syntax consists of a ‘?’ followed by either a character or an escape sequence starting with ‘\’. Examples: ?x, ?\n, ?\", ?\). Note that strings and characters are not interchangeable in Lisp; some contexts require one and some contexts require the other.

See Non-ASCII Characters in Init Files, for information about binding commands to keys which send non-ASCII characters.

真的:
True:

t代表“真实”。

t stands for “true”.

错误的:
False:

nil代表“假”。

nil stands for “false”.

其他 Lisp 对象:
Other Lisp objects:

写一个单引号 ( '),后跟您想要的 Lisp 对象。

Write a single-quote (') followed by the Lisp object you want.

有关 Emacs Lisp 语法的更多信息,请参阅Emacs Lisp 参考手册中的简介

For more information on the Emacs Lisp syntax, see Introduction in The Emacs Lisp Reference Manual.


50.4.2 初始化文件示例

50.4.2 Init File Examples

以下是使用 Lisp 表达式执行某些常见操作的一些示例:

Here are some examples of doing certain commonly desired things with Lisp expressions:

  • 将目录添加到变量中load-path。然后,您可以将 Emacs 未包含的 Lisp 库放入此目录中,并使用M-x load-library.请参阅Emacs 的 Lisp 代码库
    (添加到列表'加载路径“/path/to/lisp/libraries”)
    
  • Add a directory to the variable load-path. You can then put Lisp libraries that are not included with Emacs in this directory, and load them with M-x load-library. See Libraries of Lisp Code for Emacs.
    (add-to-list 'load-path "/path/to/lisp/libraries")
    
  • TABC 模式下,如果点位于一行的中间,则只需插入一个制表符。
    (setq c-tab-always-indent nil)
    

    这里我们有一个变量,其值通常t为“true”,而替代值则为nil“false”。

  • Make TAB in C mode just insert a tab if point is in the middle of a line.
    (setq c-tab-always-indent nil)
    

    Here we have a variable whose value is normally t for “true” and the alternative is nil for “false”.

  • 默认情况下使搜索区分大小写(在所有不覆盖此设置的缓冲区中)。
    (setq-默认大小写折叠搜索为零)
    

    这设置了默认值,该值在所有没有变量本地值的缓冲区中有效(请参阅本地变量)。设置 case-fold-searchwithsetq仅影响当前缓冲区的本地值,这可能不是您想要在 init 文件中执行的操作。

  • Make searches case sensitive by default (in all buffers that do not override this).
    (setq-default case-fold-search nil)
    

    This sets the default value, which is effective in all buffers that do not have local values for the variable (see Local Variables). Setting case-fold-search with setq affects only the current buffer’s local value, which is probably not what you want to do in an init file.

  • 如果 Emacs 无法正确识别,请指定您自己的电子邮件地址。
    (setq 用户邮件地址“cheney@torture.gov”)
    

    各种 Emacs 软件包,例如消息模式, user-mail-address当需要知道您的电子邮件地址时请查阅。请参阅邮件标头字段

  • Specify your own email address, if Emacs can’t figure it out correctly.
    (setq user-mail-address "cheney@torture.gov")
    

    Various Emacs packages, such as Message mode, consult user-mail-address when they need to know your email address. See Mail Header Fields.

  • 将文本模式设置为新缓冲区的默认模式。
    (setq-默认主要模式'文本模式)
    

    请注意,text-mode使用 是因为它是进入文本模式的命令。前面的单引号使符号成为常量;否则,text-mode将被视为变量名。

  • Make Text mode the default mode for new buffers.
    (setq-default major-mode 'text-mode)
    

    Note that text-mode is used because it is the command for entering Text mode. The single-quote before it makes the symbol a constant; otherwise, text-mode would be treated as a variable name.

  • 设置 Latin-1 字符集的默认值,该字符集支持大多数西欧语言。
    (设置语言环境“Latin-1”)
    
  • Set up defaults for the Latin-1 character set, which supports most of the languages of Western Europe.
    (set-language-environment "Latin-1")
    
  • 关闭行号模式,这是一种全局次要模式。
    (行号模式 0)
    
  • Turn off Line Number mode, a global minor mode.
    (line-number-mode 0)
    
  • 在文本模式和相关模式下自动打开自动填充模式(请参阅挂钩)。
    (添加挂钩'文本模式挂钩'自动填充模式)
    
  • Turn on Auto Fill mode automatically in Text mode and related modes (see Hooks).
    (add-hook 'text-mode-hook 'auto-fill-mode)
    
  • 更改使用剪贴板时使用的编码系统(请参阅进程间通信的编码系统)。
    (setopt 选择编码系统 'utf-8)
    
  • Change the coding system used when using the clipboard (see Coding Systems for Interprocess Communication).
    (setopt selection-coding-system 'utf-8)
    
  • 加载已安装的名为的 Lisp 库(实际上是一个文件 foo.elc或者foo.el在标准 Emacs 目录中)。
    (加载“foo”)
    

    当 的参数load是相对文件名时,不以 ' 开头/' 或者 '',load搜索目录 load-path(请参阅Emacs 的 Lisp 代码库)。

  • Load the installed Lisp library named foo (actually a file foo.elc or foo.el in a standard Emacs directory).
    (load "foo")
    

    When the argument to load is a relative file name, not starting with ‘/’ or ‘~’, load searches the directories in load-path (see Libraries of Lisp Code for Emacs).

  • 加载编译好的 Lisp 文件foo.elc从您的主目录。
    (加载“~/foo.elc”)
    

    这里使用完整的文件名,因此不进行搜索。

  • Load the compiled Lisp file foo.elc from your home directory.
    (load "~/foo.elc")
    

    Here a full file name is used, so no searching is done.

  • myfunction 告诉 Emacs通过加载名为的 Lisp 库来 查找函数的定义我的包(即一个文件 mypackage.elc或者mypackage.el):
    (autoload 'myfunction "mypackage" “照我说的做。” t)
    

    这里的字符串"Do what I say."是函数的文档字符串。您可以在autoload 定义中指定它,这样即使未加载包,它也可用于帮助命令。最后一个参数t表示该函数是交互式的;也就是说,可以通过键入或将其绑定到按键来交互调用它。如果该功能不是交互式的,请省略或使用 。 M-x myfunction RETtnil

  • Tell Emacs to find the definition for the function myfunction by loading a Lisp library named mypackage (i.e., a file mypackage.elc or mypackage.el):
    (autoload 'myfunction "mypackage" "Do what I say." t)
    

    Here the string "Do what I say." is the function’s documentation string. You specify it in the autoload definition so it will be available for help commands even when the package is not loaded. The last argument, t, indicates that this function is interactive; that is, it can be invoked interactively by typing M-x myfunction RET or by binding it to a key. If the function is not interactive, omit the t or use nil.

  • 重新绑定密钥C-x l以运行该函数make-symbolic-link (请参阅在初始化文件中重新绑定密钥)。
    (键盘映射全局设置“Cx l”'make-symbolic-link)
    

    或者

    (键盘映射设置全局映射“Cx l”'make-symbolic-link)
    

    再次注意单引号用于引用符号 make-symbolic-link而不是其作为变量的值。

  • Rebind the key C-x l to run the function make-symbolic-link (see Rebinding Keys in Your Init File).
    (keymap-global-set "C-x l" 'make-symbolic-link)
    

    or

    (keymap-set global-map "C-x l" 'make-symbolic-link)
    

    Note once again the single-quote used to refer to the symbol make-symbolic-link instead of its value as a variable.

  • 仅对 Lisp 模式执行相同的操作。
    (keymap-set lisp-mode-map "Cx l" 'make-symbolic-link)
    
  • Do the same thing for Lisp mode only.
    (keymap-set lisp-mode-map "C-x l" 'make-symbolic-link)
    
  • 重新定义现在在基本模式下运行的所有键,next-line以便它们forward-line改为运行。
    (键盘映射-替换全局映射'下一行'前行)
    
  • Redefine all keys which now run next-line in Fundamental mode so that they run forward-line instead.
    (keymap-substitute global-map 'next-line 'forward-line)
    
  • 设为C-x C-v未定义。
    (键盘映射全局未设置“Cx Cv”)
    

    取消定义键的原因之一是可以将其设为前缀。简单地定义将产生一个前缀,但必须首先摆脱其通常的非前缀定义。 C-x C-v anythingC-x C-vC-x C-v

  • Make C-x C-v undefined.
    (keymap-global-unset "C-x C-v")
    

    One reason to undefine a key is so that you can make it a prefix. Simply defining C-x C-v anything will make C-x C-v a prefix, but C-x C-v must first be freed of its usual non-prefix definition.

  • 制作 '$' 具有文本模式下标点符号的语法。请注意 ' 的字符常量的使用$'。
    (修改语法条目?\$“.”文本模式语法表)
    
  • Make ‘$’ have the syntax of punctuation in Text mode. Note the use of a character constant for ‘$’.
    (modify-syntax-entry ?\$ "." text-mode-syntax-table)
    
  • narrow-to-region无需确认 即可启用该命令。
    (将“窄区域”禁用为零)
    
  • Enable the use of the command narrow-to-region without confirmation.
    (put 'narrow-to-region 'disabled nil)
    
  • 调整配置以适应各种平台和Emacs版本。

    用户通常希望 Emacs 在所有系统上表现相同,因此相同的 init 文件适用于所有平台。但是,有时您用于自定义 Emacs 的功能在某些平台或较旧的 Emacs 版本中不可用。要处理这种情况,请将自定义放入测试函数或设施是否可用的条件中,如下所示:

    (if (fboundp '闪烁光标模式)
        (闪烁光标模式 0))
    
    (if (boundp '编码类别-utf-8)
        (设置编码优先级'(编码类别-utf-8)))
    

    如果函数未定义,您也可以简单地忽略发生的错误。

    (忽略错误(设置面背景'区域“grey75”))
    

    不存在的变量上的Asetq通常是无害的,因此不需要条件。

  • Adjusting the configuration to various platforms and Emacs versions.

    Users typically want Emacs to behave the same on all systems, so the same init file is right for all platforms. However, sometimes it happens that a function you use for customizing Emacs is not available on some platforms or in older Emacs versions. To deal with that situation, put the customization inside a conditional that tests whether the function or facility is available, like this:

    (if (fboundp 'blink-cursor-mode)
        (blink-cursor-mode 0))
    
    (if (boundp 'coding-category-utf-8)
        (set-coding-priority '(coding-category-utf-8)))
    

    You can also simply disregard the errors that occur if the function is not defined.

    (ignore-errors (set-face-background 'region "grey75"))
    

    A setq on a variable which does not exist is generally harmless, so those do not need a conditional.

  • 用于use-package自动加载和配置包。
    (使用包高锁
      : 推迟
      :init (add-hook 'some-hook 'hi-lock-mode)
      :config(使用包 my-hi-lock)
      :bind (("Mo l" .highlight-lines-matching-regexp)
             (“Mo r”.highlight-regexp)
             (“Mo w”。突出显示短语)))
    

    这将hi-lock在第一次使用它的一些命令或变量时加载,将3个键绑定到它的命令,并在加载后另外加载包 my-hi-lock(大概是进一步定制 hi-lockhi-lock。该use-package 工具在其自己的手册中有完整记录,请参阅use-package 用户手册

  • Using use-package to automatically load and configure a package.
    (use-package hi-lock
      :defer t
      :init (add-hook 'some-hook 'hi-lock-mode)
      :config (use-package my-hi-lock)
      :bind (("M-o l" . highlight-lines-matching-regexp)
             ("M-o r" . highlight-regexp)
             ("M-o w" . highlight-phrase)))
    

    This will load hi-lock when some of its commands or variables are first used, bind 3 keys to its commands, and additionally load the my-hi-lock package (presumably further customizing hi-lock) after loading hi-lock. The use-package facility is fully documented in its own manual, see use-package User manual.


50.4.3 终端特定初始化

50.4.3 Terminal-specific Initialization

每种终端类型都可以有一个 Lisp 库,当 Emacs 在该类型的终端上运行时,该库将加载到 Emacs 中。对于名为termtype 的终端类型 ,该库称为术语/术语类型。 (如果关联列表 中存在该形式的条目,Emacs 将使用 alias代替termtype。)通过照常搜索目录并尝试后缀 '来找到该库。(termtype . alias)term-file-aliasesload-path.elc' 和 '.el'。通常它出现在子目录中学期保存大多数 Emacs 库的目录。

Each terminal type can have a Lisp library to be loaded into Emacs when it is run on that type of terminal. For a terminal type named termtype, the library is called term/termtype. (If there is an entry of the form (termtype . alias) in the term-file-aliases association list, Emacs uses alias in place of termtype.) The library is found by searching the directories load-path as usual and trying the suffixes ‘.elc’ and ‘.el’. Normally it appears in the subdirectory term of the directory where most Emacs libraries are kept.

特定于终端的库的通常用途是将终端功能键使用的转义序列映射到更有意义的名称,使用input-decode-map.查看文件 术语/lk201.el有关如何完成此操作的示例。许多功能键根据Termcap数据库中的信息自动映射;特定于终端的库只需要映射 Termcap 未指定的功能键。

The usual purpose of the terminal-specific library is to map the escape sequences used by the terminal’s function keys onto more meaningful names, using input-decode-map. See the file term/lk201.el for an example of how this is done. Many function keys are mapped automatically according to the information in the Termcap data base; the terminal-specific library needs to map only the function keys that Termcap does not specify.

当终端类型包含连字符时,只有第一个连字符之前的名称部分对于选择库名称很重要。因此,终端类型 'AAA-48' 和 'AAA-30-RV' 都使用该库术语/aaa。库中的代码可用于 (getenv "TERM")查找完整的终端类型名称。

When the terminal type contains a hyphen, only the part of the name before the first hyphen is significant in choosing the library name. Thus, terminal types ‘aaa-48’ and ‘aaa-30-rv’ both use the library term/aaa. The code in the library can use (getenv "TERM") to find the full terminal type name.

库的名称是通过连接变量值term-file-prefix和终端类型来构造的。你的.emacsterm-file-prefix文件可以通过设置为来 阻止加载特定于终端的库 nil

The library’s name is constructed by concatenating the value of the variable term-file-prefix and the terminal type. Your .emacs file can prevent the loading of the terminal-specific library by setting term-file-prefix to nil.

tty-setup-hookEmacs在初始化结束时运行钩子,在你的.emacs文件和任何特定于终端的库已被读入。如果您希望覆盖任何特定于终端的库的一部分并为没有库的终端定义初始化,请将挂钩函数添加到此挂钩。请参阅钩子

Emacs runs the hook tty-setup-hook at the end of initialization, after both your .emacs file and any terminal-specific library have been read in. Add hook functions to this hook if you wish to override part of any of the terminal-specific libraries and to define initializations for terminals that do not have a library. See Hooks.


50.4.4 Emacs 如何找到你的初始化文件

50.4.4 How Emacs Finds Your Init File

Emacs 通常会在主目录25下的某个位置找到您的 init 文件。请参阅Emacs 初始化文件

Emacs normally finds your init file in a location under your home directory25. See The Emacs Initialization File.

Emacs 使用文件名查找您的 init 文件〜/ .emacs.el, 〜/.emacs, 或者〜/.emacs.d/init.el以该顺序;您可以选择使用这些名称中的任何一个。 (请注意,只有直接位于主目录中的位置的基本名称中才会有一个前导点。)

Emacs looks for your init file using the filenames ~/.emacs.el, ~/.emacs, or ~/.emacs.d/init.el in that order; you can choose to use any one of these names. (Note that only the locations directly in your home directory have a leading dot in the location’s basename.)

Emacs 还可以在 XDG 兼容位置中查找初始化程序,默认是目录〜/.config/emacs。这可以通过在您的环境中设置来覆盖XDG_CONFIG_HOME,其值替换〜/.config在默认 XDG 初始化文件的名称中。然而〜/ .emacs.d,〜/.emacs, 和 〜/ .emacs.el如果存在,则始终是首选,这意味着您必须删除或重命名它们才能使用 XDG 位置。

Emacs can also look in an XDG-compatible location for init.el, the default is the directory ~/.config/emacs. This can be overridden by setting XDG_CONFIG_HOME in your environment, its value replaces ~/.config in the name of the default XDG init file. However ~/.emacs.d, ~/.emacs, and ~/.emacs.el are always preferred if they exist, which means that you must delete or rename them in order to use the XDG location.

另请注意,如果 XDG 位置和〜/ .emacs.d 存在,那么 Emacs 将创建〜/ .emacs.d(因此在后续调用期间使用它)。

Note also that if neither the XDG location nor ~/.emacs.d exist, then Emacs will create ~/.emacs.d (and therefore use it during subsequent invocations).

Emacs 将设置user-emacs-directory为它决定使用的目录。

Emacs will set user-emacs-directory to the directory it decides to use.

尽管这与旧版 Emacs 向后兼容,但现代 POSIX 平台更喜欢将初始化文件放在 〜/.config因此,可以通过重命名该目录来解决可能由于错误的初始化文件而导致的问题,或者归档初始化文件的集合。为了帮助较旧的 Emacs 版本在其当前默认位置查找配置文件,您可以执行以下 Emacs Lisp 代码:

Although this is backward-compatible with older Emacs versions, modern POSIX platforms prefer putting your initialization files under ~/.config so that troubleshooting a problem that might be due to a bad init file, or archiving a collection of init files, can be done by renaming that directory. To help older Emacs versions find configuration files in their current default locations, you can execute the following Emacs Lisp code:

(make-symbolic-link ".config/emacs" "~/.emacs.d")
(make-symbolic-link ".config/emacs" "~/.emacs.d")

su但是,如果您从由 启动且未 在您的环境中设置的 shell 运行 Emacs XDG_CONFIG_HOME,Emacs 会尝试查找您自己的初始化文件,而不是您当前假装的用户的初始化文件。这个想法是,即使您以超级用户身份运行,您也应该获得自己的编辑器自定义。

However, if you run Emacs from a shell started by su and XDG_CONFIG_HOME is not set in your environment, Emacs tries to find your own initialization files, not that of the user you are currently pretending to be. The idea is that you should get your own editor customizations even if you are running as the super user.

更准确地说,Emacs 首先确定要使用哪个用户的 init 文件。它从环境变量中获取您的用户名LOGNAMEUSER如果两者都不存在,则使用有效的用户 ID。如果该用户名与真实用户 ID 匹配,则 Emacs 使用HOME;否则,它会在系统的用户数据库中查找与该用户名对应的主目录。

More precisely, Emacs first determines which user’s init file to use. It gets your user name from the environment variables LOGNAME and USER; if neither of those exists, it uses the effective user-ID. If that user name matches the real user-ID, then Emacs uses HOME; otherwise, it looks up the home directory corresponding to that user name in the system’s data base of users.

为简洁起见,Emacs 文档的其余部分通常仅使用当前的默认位置〜/.emacs.d/init.el对于初始化文件。

For brevity the rest of the Emacs documentation generally uses just the current default location ~/.emacs.d/init.el for the init file.


50.4.5初始化文件中的非ASCII字符

50.4.5 Non-ASCII Characters in Init Files

如果您的 init 文件在字符串或键绑定中包含非ASCII字符(例如重音字母),则 语言和编码系统可能会导致问题。

Language and coding systems may cause problems if your init file contains non-ASCII characters, such as accented letters, in strings or key bindings.

如果你想在你的初始化文件中使用非ASCII字符,你应该放一个 '-*-coding: 编码系统-*-'标记位于 init 文件的第一行,并指定支持相关字符的编码系统。请参阅识别编码系统。这是因为,当 Emacs 读取 init 文件中使用此类字符串的部分时,解码非ASCII文本的默认值可能尚未设置,可能导​​致 Emacs 错误地解码这些字符串。然后,您应该避免添加以其他方式修改编码系统的 Emacs Lisp 代码,例如调用 set-language-environment.

If you want to use non-ASCII characters in your init file, you should put a ‘-*-coding: coding-system-*- tag on the first line of the init file, and specify a coding system that supports the character(s) in question. See Recognizing Coding Systems. This is because the defaults for decoding non-ASCII text might not yet be set up by the time Emacs reads those parts of your init file which use such strings, possibly leading Emacs to decode those strings incorrectly. You should then avoid adding Emacs Lisp code that modifies the coding system in other ways, such as calls to set-language-environment.

直接使用非ASCII字符的替代方法是使用Emacs Lisp 参考手册中的通用转义语法 中描述的字符转义语法之一,因为它们允许仅使用ASCII字符指定所有 Unicode 代码点。

An alternative to using non-ASCII characters directly is to use one of the character escape syntaxes described in see General Escape Syntax in The Emacs Lisp Reference Manual, as they allow all Unicode codepoints to be specified using only ASCII characters.

要绑定非ASCII密钥,您必须使用向量(请参阅在初始化文件中重新绑定密钥)。无法使用字符串语法,因为非ASCII字符将被解释为元键。例如:

To bind non-ASCII keys, you must use a vector (see Rebinding Keys in Your Init File). The string syntax cannot be used, since the non-ASCII characters will be interpreted as meta keys. For instance:

(全局设置键 [? char ] '某些功能)
(global-set-key [?char] 'some-function)

键入C-q,后跟要绑定的键,以插入char

Type C-q, followed by the key you want to bind, to insert char.


50.4.6 早期初始化文件

50.4.6 The Early Init File

Emacs 的大多数自定义设置都应该放在普通的 init 文件中。请参阅Emacs 初始化文件。然而,有时需要在 Emacs 启动过程中早于处理正常的 init 文件使自定义生效。这样的定制可以放在早期的初始化文件中,〜/.config/emacs/early-init.el或者〜/.emacs.d/early-init.el。该文件在包系统和 GUI 初始化之前加载,因此您可以在其中自定义影响包初始化过程的变量,例如package-enable-at-startuppackage-load-listpackage-user-dir。请注意,诸如此类的变量package-archives 仅影响新软件包的安装,而不影响使已安装的软件包可用的过程,可以在常规 init 文件中进行自定义。请参阅软件包安装

Most customizations for Emacs should be put in the normal init file. See The Emacs Initialization File. However, it is sometimes necessary to have customizations take effect during Emacs startup earlier than the normal init file is processed. Such customizations can be put in the early init file, ~/.config/emacs/early-init.el or ~/.emacs.d/early-init.el. This file is loaded before the package system and GUI is initialized, so in it you can customize variables that affect the package initialization process, such as package-enable-at-startup, package-load-list, and package-user-dir. Note that variables like package-archives which only affect the installation of new packages, and not the process of making already-installed packages available, may be customized in the regular init file. See Package Installation.

我们不建议您搬入早期初始化.el 可以保留在普通初始化文件中的自定义。这是因为早期初始化文件是在 GUI 初始化之前读取的,因此与 GUI 功能相关的自定义在 早期初始化.el。相比之下,正常的初始化文件是在 GUI 初始化后读取的。如果您必须在依赖 GUI 功能的早期 init 文件中进行自定义,请让它们脱离 Emacs 启动提供的功能,例如window-setup-hooktty-setup-hook。请参阅钩子

We do not recommend that you move into early-init.el customizations that can be left in the normal init files. That is because the early init file is read before the GUI is initialized, so customizations related to GUI features will not work reliably in early-init.el. By contrast, the normal init files are read after the GUI is initialized. If you must have customizations in the early init file that rely on GUI features, make them run off hooks provided by the Emacs startup, such as window-setup-hook or tty-setup-hook. See Hooks.

有关早期 init 文件的更多信息,请参阅Emacs Lisp 参考手册中的Init File

For more information on the early init file, see Init File in The Emacs Lisp Reference Manual.


50.5 保存持久认证信息

50.5 Keeping Persistent Authentication Information

某些连接到其他服务的 Emacs 软件包需要身份验证(请参阅输入密码),例如,请参阅The Gnus Manual中的GnusThe Tramp Manual中的Tramp。因为一次又一次地提供相同的用户名和密码可能会很烦人,所以 Emacs 提供了通过 授权来源图书馆。

Some Emacs packages, which connect to other services, require authentication (see Entering passwords), e.g., see Gnus in The Gnus Manual, or Tramp in The Tramp Manual. Because it might be annoying to provide the same user name and password again and again, Emacs offers to keep this information persistent via the auth-source library.

默认情况下,认证信息是从文件中获取的 〜/.authinfo或者〜/.authinfo.gpg或者〜/.netrc。这些文件的语法与程序中已知的 netrc 文件类似 ftp,如下所示:

By default, the authentication information is taken from the file ~/.authinfo or ~/.authinfo.gpg or ~/.netrc. These files have a syntax similar to netrc files as known from the ftp program, like this:

机器mymachine登录myloginname密码mypassword端口myport
machine mymachine login myloginname password mypassword port myport

同样,授权来源库支持多种存储后端,目前要么是经典的 netrc 后端、JSON 文件、Secret Service API,要么是标准的 unix 密码管理器 pass。

Similarly, the auth-source library supports multiple storage backend, currently either the classic netrc backend, JSON files, the Secret Service API, and pass, the standard unix password manager.

所有这些替代方案都可以通过用户选项进行自定义 auth-sources,请参阅Emacs auth-source中的Emacs auth-source

All these alternatives can be customized via the user option auth-sources, see Emacs auth-source in Emacs auth-source.

当以交互方式输入密码时(无法通过配置的后端找到密码),某些后端会提供持久保存密码的功能。这可以通过自定义用户选项来更改 auth-source-save-behavior

When a password is entered interactively, which is not found via the configured backend, some of the backends offer to save it persistently. This can be changed by customizing the user option auth-source-save-behavior.


51 退出和中止

51 Quitting and Aborting

C-g
C-g
C-Break (MS-DOS only)
C-Break (MS-DOS only)

退出:取消正在运行或部分键入的命令。

Quit: cancel running or partially typed command.

C-]
C-]

中止最内层的递归编辑级别并取消调用它的命令 ( abort-recursive-edit)。

Abort innermost recursive editing level and cancel the command which invoked it (abort-recursive-edit).

ESC ESC ESC
ESC ESC ESC

要么退出,要么中止,无论哪个有意义(keyboard-escape-quit)。

Either quit or abort, whichever makes sense (keyboard-escape-quit).

M-x top-level
M-x top-level

中止当前正在执行的所有递归编辑级别。

Abort all recursive editing levels that are currently executing.

C-/
C-/
C-x u
C-x u
C-_
C-_

取消先前对缓冲区内容所做的更改 ( undo)。

Cancel a previously made change in the buffer contents (undo).

在命令完成之前取消命令有两种方法: 使用退出C-g,以及使用或 中止。退出会取消部分键入的命令或仍在运行的命令。中止将退出递归编辑级别并取消调用递归编辑的命令(请参阅递归编辑级别)。 C-]M-x top-level

There are two ways of canceling a command before it has finished: quitting with C-g, and aborting with C-] or M-x top-level. Quitting cancels a partially typed command, or one which is still running. Aborting exits a recursive editing level and cancels the command that invoked the recursive edit (see Recursive Editing Levels).

退出C-g是摆脱部分键入的命令或不需要的数字参数的方法。此外,如果您正在执行正在运行的命令,C-g请以相对安全的方式停止该命令。例如,如果您退出需要很长时间的kill命令,那么您的文本要么 仍然在缓冲区中,要么全部在kill环中,或者两者都有。如果该区域处于活动状态,C-g 则禁用标记,除非瞬态标记模式关闭(请参阅禁用瞬态标记模式)。如果您正在进行增量搜索,C-g请表现得特别;可能需要两个连续的C-g字符才能退出搜索。有关详细信息,请参阅增量搜索

Quitting with C-g is the way to get rid of a partially typed command, or a numeric argument that you don’t want. Furthermore, if you are in the middle of a command that is running, C-g stops the command in a relatively safe way. For example, if you quit out of a kill command that is taking a long time, either your text will all still be in the buffer, or it will all be in the kill ring, or maybe both. If the region is active, C-g deactivates the mark, unless Transient Mark mode is off (see Disabling Transient Mark Mode). If you are in the middle of an incremental search, C-g behaves specially; it may take two successive C-g characters to get out of a search. See Incremental Search, for details.

如果您输入C-g迷你缓冲区,则会退出打开该迷你缓冲区的命令,并将其关闭。如果该迷你缓冲区不是最近打开的缓冲区(当 minibuffer-follows-selected-frame是时可能会发生这种情况nil(请参阅使用迷你缓冲区)),C-g在要求您确认后,也会关闭最近打开的缓冲区,退出其关联的命令。

If you type C-g in a minibuffer, this quits the command that opened that minibuffer, closing it. If that minibuffer is not the most recently opened one (which can happen when minibuffer-follows-selected-frame is nil (see Using the Minibuffer)), C-g also closes the more recently opened ones, quitting their associated commands, after asking you for confirmation.

在 MS-DOS 上,该字符用作退出字符,如。原因是在 MS-DOS 上,在命令运行时、与用户交互之间进行识别是不可行的。相比之下,任何时候都可以识别 。请参阅MS-DOS 上的键盘使用C-BreakC-gC-gC-Break

On MS-DOS, the character C-Break serves as a quit character like C-g. The reason is that it is not feasible, on MS-DOS, to recognize C-g while a command is running, between interactions with the user. By contrast, it is feasible to recognize C-Break at all times. See Keyboard Usage on MS-DOS.

C-g通过将变量设置quit-flag为键入的t 瞬间来工作; C-gEmacs Lisp 经常检查这个变量,如果它不是 则退出nilC-g仅当您在 Emacs 等待输入时键入命令时,它才会真正作为命令执行。在这种情况下,它运行的命令是keyboard-quit.

C-g works by setting the variable quit-flag to t the instant C-g is typed; Emacs Lisp checks this variable frequently, and quits if it is non-nil. C-g is only actually executed as a command if you type it while Emacs is waiting for input. In that case, the command it runs is keyboard-quit.

C-g在文本终端上,如果在识别第一次之前第二次退出C-g,则会激活紧急逃生功能并返回 shell。参见紧急逃生

On a text terminal, if you quit with C-g a second time before the first C-g is recognized, you activate the emergency-escape feature and return to the shell. See Emergency Escape.

在某些情况下,您无法退出。当 Emacs 等待操作系统执行某些操作时,退出是不可能的,除非对 Emacs 中发生等待的特定系统调用付出了特殊的努力。我们已经为用户可能想要退出的系统调用执行了此操作,但您可能会遇到未处理的情况。在一种非常常见的情况下(使用 NFS 等待文件输入或输出),Emacs 本身知道如何退出,但许多 NFS 实现根本不允许用户程序在 NFS 服务器挂起时停止等待 NFS。

There are some situations where you cannot quit. When Emacs is waiting for the operating system to do something, quitting is impossible unless special pains are taken for the particular system call within Emacs where the waiting occurs. We have done this for the system calls that users are likely to want to quit from, but it’s possible you will encounter a case not handled. In one very common case—waiting for file input or output using NFS—Emacs itself knows how to quit, but many NFS implementations simply do not allow user programs to stop waiting for NFS when the NFS server is hung.

使用C-]( abort-recursive-edit) 中止用于退出递归编辑级别并取消调用它的命令。退出 withC-g不会执行此操作,也无法执行此操作,因为它用于取消递归编辑级别部分键入的命令。这两种操作都很有用。例如,如果您处于递归编辑中并键入C-u 8输入数字参数,则可以使用 取消该参数C-g并保留在递归编辑中。

Aborting with C-] (abort-recursive-edit) is used to get out of a recursive editing level and cancel the command which invoked it. Quitting with C-g does not do this, and could not do this, because it is used to cancel a partially typed command within the recursive editing level. Both operations are useful. For example, if you are in a recursive edit and type C-u 8 to enter a numeric argument, you can cancel that argument with C-g and remain in the recursive edit.

序列ESC ESC ESC ( keyboard-escape-quit) 可以退出或中止。 (我们这样定义它是因为ESC在许多 PC 程序中意味着“退出”。)它可以取消前缀参数、清除选定区域或退出查询替换,例如C-g.它可以脱离迷你缓冲区或递归编辑,例如C-].它还可以摆脱将框架分割成多个窗口的问题,就像C-x 1.然而,它不能做的一件事是停止正在运行的命令。这是因为它作为普通命令执行,并且 Emacs 在准备好执行下一个命令之前不会注意到它。

The sequence ESC ESC ESC (keyboard-escape-quit) can either quit or abort. (We defined it this way because ESC means “get out” in many PC programs.) It can cancel a prefix argument, clear a selected region, or get out of a Query Replace, like C-g. It can get out of the minibuffer or a recursive edit, like C-]. It can also get out of splitting the frame into multiple windows, as with C-x 1. One thing it cannot do, however, is stop a command that is running. That’s because it executes as an ordinary command, and Emacs doesn’t notice it until it is ready for the next command.

该命令M-x top-level相当于足够多的 C-]命令,可以让您摆脱当前所处的所有级别的递归编辑;如果它处于活动状态,它也会退出迷你缓冲区。 C-]一次让你退出一个级别,但M-x top-level 同时退出所有级别。C-]和与M-x top-level 所有其他命令一样,但与 不同的是C-g,它们仅在 Emacs 准备好命令时才会生效。 C-]是一个普通键,仅由于它在键盘映射中的绑定而具有其意义。请参阅递归编辑级别

The command M-x top-level is equivalent to enough C-] commands to get you out of all the levels of recursive edits that you are in; it also exits the minibuffer if it is active. C-] gets you out one level at a time, but M-x top-level goes out all levels at once. Both C-] and M-x top-level are like all other commands, and unlike C-g, in that they take effect only when Emacs is ready for a command. C-] is an ordinary key and has its meaning only because of its binding in the keymap. See Recursive Editing Levels.

C-/( undo) 严格来说并不是取消命令的一种方式,但您可以将其视为取消已经执行完毕的命令。有关撤消功能的更多信息, 请参阅撤消。

C-/ (undo) is not strictly speaking a way of canceling a command, but you can think of it as canceling a command that already finished executing. See Undo, for more information about the undo facility.


52 处理 Emacs 问题

52 Dealing with Emacs Trouble

本节介绍如何识别和处理 Emacs 无法按预期工作的情况,例如键盘代码混淆、显示乱码、内存不足以及崩溃和挂起。

This section describes how to recognize and deal with situations in which Emacs does not work as you expect, such as keyboard code mixups, garbled displays, running out of memory, and crashes and hangs.

请参阅报告错误,了解当您认为在 Emacs 中发现错误时该怎么做。

See Reporting Bugs, for what to do when you think you have found a bug in Emacs.


52.1 递归编辑级别

52.1 Recursive Editing Levels

递归编辑级别是 Emacs 重要且有用的功能,但如果您不了解它们,它们可能会出现故障。

Recursive editing levels are important and useful features of Emacs, but they can seem like malfunctions if you do not understand them.

如果模式行有方括号 '[…]' 在包含主要模式和次要模式名称的括号内,您已进入递归编辑级别。如果您不是故意这样做的,或者您不明白这意味着什么,那么您应该退出递归编辑级别。为此,请键入M-x top-level.请参阅递归编辑级别

If the mode line has square brackets ‘[…]’ around the parentheses that contain the names of the major and minor modes, you have entered a recursive editing level. If you did not do this on purpose, or if you don’t understand what that means, you should just get out of the recursive editing level. To do so, type M-x top-level. See Recursive Editing Levels.


52.2 屏幕上的垃圾

52.2 Garbage on the Screen

如果文本终端上的文本看起来有误,首先要做的是查看缓冲区中的文本是否有误。键入C-l ( recenter-top-bottom) 以重新显示整个屏幕。如果此后屏幕显示正确,则问题完全出在之前的屏幕更新中。 (否则,请参阅以下部分。)

If the text on a text terminal looks wrong, the first thing to do is see whether it is wrong in the buffer. Type C-l (recenter-top-bottom) to redisplay the entire screen. If the screen appears correct after this, the problem was entirely in the previous screen update. (Otherwise, see the following section.)

显示更新问题通常是由于您所使用的终端的 terminfo 条目不正确而导致的。文件等/条款Emacs 发行版中给出了此类已知问题的修复。 安装其中一节包含针对这些问题的一般建议。如果您似乎使用了正确的 terminfo 条目,则 terminfo 条目中可能存在错误,或者 Emacs 中针对某些终端类型出现错误。

Display updating problems often result from an incorrect terminfo entry for the terminal you are using. The file etc/TERMS in the Emacs distribution gives the fixes for known problems of this sort. INSTALL contains general advice for these problems in one of its sections. If you seem to be using the right terminfo entry, it is possible that there is a bug in the terminfo entry, or a bug in Emacs that appears for certain terminal types.


52.3 文本中的垃圾

52.3 Garbage in the Text

如果C-l显示文本错误,请首先键入C-h l ( view-lossage) 以查看您键入了哪些命令来产生观察到的结果。然后尝试使用C-x u( )逐步撤消更改 undo,直到恢复到您认为正确的状态。

If C-l shows that the text is wrong, first type C-h l (view-lossage) to see what commands you typed to produce the observed results. Then try undoing the changes step by step using C-x u (undo), until it gets back to a state you consider correct.

如果缓冲区的开头或结尾处似乎缺少大部分文本,请检查单词“狭窄的' 在模式行中。如果出现,则您看不到的文本可能仍然存在,但暂时不受限制。要使其再次可访问,请键入C-x n w( widen)。请参阅缩小范围

If a large portion of text appears to be missing at the beginning or end of the buffer, check for the word ‘Narrow’ in the mode line. If it appears, the text you don’t see is probably still present, but temporarily off-limits. To make it accessible again, type C-x n w (widen). See Narrowing.


52.4 内存不足

52.4 Running out of Memory

如果您收到错误消息'虚拟内存超出C-x s',用( )保存修改后的缓冲区save-some-buffers。这种保存方法对额外内存的需求最小。 Emacs 会保留一定的内存,以便在发生此错误时可用;这应该足以C-x s完成其工作。当储备金被使用后,'!内存已满!' 出现在模式行的开头,表示没有更多的保留。

If you get the error message ‘Virtual memory exceeded’, save your modified buffers with C-x s (save-some-buffers). This method of saving them has the smallest need for additional memory. Emacs keeps a reserve of memory which it makes available when this error happens; that should be enough to enable C-x s to complete its work. When the reserve has been used, ‘!MEM FULL!’ appears at the beginning of the mode line, indicating there is no more reserve.

保存修改的缓冲区后,您可以退出此 Emacs 会话并启动另一个会话,也可以用于M-x kill-some-buffers 释放当前 Emacs 作业中的空间。如果这释放了足够的空间,Emacs 将重新填充其内存储备,并且 '!内存已满!'将从模式行中消失。这意味着您可以在同一个 Emacs 会话中安全地继续编辑。

Once you have saved your modified buffers, you can exit this Emacs session and start another, or you can use M-x kill-some-buffers to free space in the current Emacs job. If this frees up sufficient space, Emacs will refill its memory reserve, and ‘!MEM FULL!’ will disappear from the mode line. That means you can safely go on editing in the same Emacs session.

M-x buffer-menu当内存不足时, 不要使用保存或终止缓冲区,因为缓冲区菜单本身需要相当数量的内存,而储备供应可能不够。

Do not use M-x buffer-menu to save or kill buffers when you run out of memory, because the Buffer Menu needs a fair amount of memory itself, and the reserve supply may not be enough.

在 GNU/Linux 系统上,Emacs 通常不会收到有关内存不足情况的通知;相反,操作系统可以在内存不足时终止 Emacs 进程。此功能称为 内存不足杀手OOM杀手。当此行为生效时,Emacs 无法及时检测到内存不足的情况,并且无法让您如上所述保存缓冲区。但是,可以关闭操作系统的这种行为,从而使 Emacs 有机会在被终止之前以更有用的方式处理内存不足的情况。为此,请成为超级用户,编辑文件以包含下面所示的行,然后从 shell 提示符 /etc/sysctl.conf调用命令 :sysctl -p

On GNU/Linux systems, Emacs does not normally get notified about out-of-memory situations; instead, the OS can kill the Emacs process when it runs out of memory. This feature is known as the out-of-memory killer, or OOM killer. When this behavior is in effect, Emacs is unable to detect the out-of-memory situation in time, and won’t be able to let you save your buffer as described above. However, it is possible to turn off this behavior of the OS, and thus allow Emacs a chance to handle the out-of-memory situation in a more useful manner, before it is killed. To do that, become the super user, edit the file /etc/sysctl.conf to contain the lines shown below, and then invoke the command sysctl -p from the shell prompt:

vm.overcommit_memory=2
vm.overcommit_ratio=0
vm.overcommit_memory=2
vm.overcommit_ratio=0

请注意,上述设置会影响系统上的所有进程,并且通常会影响系统在内存压力下的行为,而不仅仅是 Emacs 进程。

Please note that the above setting affects all the processes on the system, and in general the behavior of the system under memory pressure, not just the Emacs process alone.


52.5 当 Emacs 崩溃时

52.5 When Emacs Crashes

Emacs 不应该崩溃,但如果崩溃了,它会 在退出之前生成一个崩溃报告。崩溃报告被打印到标准错误流。如果 Emacs 是从 GNU 或 Unix 系统上的图形桌面启动的,则标准错误流通常会重定向到以下文件:~/.xsession-errors,因此您可以在那里查找崩溃报告。在 MS-Windows 上,崩溃报告被写入名为emacs_backtrace.txt在 Emacs 进程的当前目录中,除了标准错误流之外。

Emacs is not supposed to crash, but if it does, it produces a crash report prior to exiting. The crash report is printed to the standard error stream. If Emacs was started from a graphical desktop on a GNU or Unix system, the standard error stream is commonly redirected to a file such as ~/.xsession-errors, so you can look for the crash report there. On MS-Windows, the crash report is written to a file named emacs_backtrace.txt in the current directory of the Emacs process, in addition to the standard error stream.

崩溃报告的格式取决于平台。在某些平台上,例如使用 GNU C 库的平台,崩溃报告包括描述崩溃之前的执行状态的回溯,可用于帮助调试崩溃。以下是 GNU 系统的示例:

The format of the crash report depends on the platform. On some platforms, such as those using the GNU C Library, the crash report includes a backtrace describing the execution state prior to crashing, which can be used to help debug the crash. Here is an example for a GNU system:

致命错误11:分段错误
回溯:
emacs[0x5094e4]
emacs[0x4ed3e6]
emacs[0x4ed504]
/lib64/libpthread.so.0[0x375220efe0]
/lib64/libpthread.so.0(读+0xe)[0x375220e08e]
emacs[0x509af6]
emacs[0x5acc26]
……
Fatal error 11: Segmentation fault
Backtrace:
emacs[0x5094e4]
emacs[0x4ed3e6]
emacs[0x4ed504]
/lib64/libpthread.so.0[0x375220efe0]
/lib64/libpthread.so.0(read+0xe)[0x375220e08e]
emacs[0x509af6]
emacs[0x5acc26]
…

号码 '11' 是与崩溃相对应的系统信号号——在本例中是分段错误。十六进制数字是程序地址,可以使用调试工具将其与源代码行关联起来。例如,GDB 命令'列表*0x509af6' 打印对应于 ' 的源代码行emacs[0x509af6]' 入口。如果您的系统有 addr2line该实用程序,则以下 shell 命令会输出带有源代码行号的回溯:

The number ‘11’ is the system signal number corresponding to the crash—in this case a segmentation fault. The hexadecimal numbers are program addresses, which can be associated with source code lines using a debugging tool. For example, the GDB command ‘list *0x509af6’ prints the source-code lines corresponding to the ‘emacs[0x509af6]’ entry. If your system has the addr2line utility, the following shell command outputs a backtrace with source-code line numbers:

sed -n 's/.*\[\(.*\)]$/\1/p'回溯|
  addr2line -C -f -i -p -e bindir / emacs-binary
sed -n 's/.*\[\(.*\)]$/\1/p' backtrace |
  addr2line -C -f -i -p -e bindir/emacs-binary

在 MS-Windows 上,回溯看起来有些不同,例如:

On MS-Windows, the backtrace looks somewhat differently, for example:

回溯:
00007ff61166a12e
00007ff611538be1
00007ff611559601
00007ff6116ce84a
00007ff9b7977ff0
……
Backtrace:
00007ff61166a12e
00007ff611538be1
00007ff611559601
00007ff6116ce84a
00007ff9b7977ff0
…

sed因此,不需要 过滤via ,显示源代码行号的命令是

Therefore, the filtering via sed is not required, and the command to show the source-code line number is

addr2line -C -f -i -p -e bindir / emacs-binary <回溯
 addr2line -C -f -i -p -e bindir/emacs-binary < backtrace

这里,backtrace是包含 backtrace 副本的文本文件的名称(在 MS-Windows 上,emacs_backtrace.txt(在 Emacs 启动的目录中),bindir是包含 Emacs 可执行文件的目录的名称,emacs-binary 是 Emacs 可执行文件的名称,通常emacs在 GNU 和 Unix 系统上以及emacs.exe在 MS-Windows 和 MS-DOS 上。省略-p如果您的版本addr2line太旧而无法使用,则可以选择。

Here, backtrace is the name of a text file containing a copy of the backtrace (on MS-Windows, emacs_backtrace.txt in the directory where Emacs was started), bindir is the name of the directory that contains the Emacs executable, and emacs-binary is the name of the Emacs executable file, normally emacs on GNU and Unix systems and emacs.exe on MS-Windows and MS-DOS. Omit the -p option if your version of addr2line is too old to have it.

或者,Emacs 可以在支持核心文件的系统上崩溃时生成核心转储。核心转储是一个文件,其中包含有关崩溃之前程序状态的大量数据,通常通过将其加载到 GDB 等调试器中来进行检查。在许多平台上,默认情况下禁用核心转储,您必须通过运行 shell 命令“显式启用它们”ulimit -c 无限'(例如,在您的 shell 启动脚本中)。

Optionally, Emacs can generate a core dump when it crashes, on systems that support core files. A core dump is a file containing voluminous data about the state of the program prior to the crash, usually examined by loading it into a debugger such as GDB. On many platforms, core dumps are disabled by default, and you must explicitly enable them by running the shell command ‘ulimit -c unlimited’ (e.g., in your shell startup script).


52.6 崩溃后的恢复

52.6 Recovery After a Crash

如果 Emacs 或计算机崩溃,您可以从自动保存文件中恢复崩溃时正在编辑的文件。为此,请再次启动 Emacs 并输入命令M-x recover-session

If Emacs or the computer crashes, you can recover the files you were editing at the time of the crash from their auto-save files. To do this, start Emacs again and type the command M-x recover-session.

此命令最初显示一个缓冲区,其中列出了中断的会话文件,每个文件都有其日期。您必须选择要从哪个会话中恢复。通常,您想要的就是最新的。将光标移至您选择的位置,然后键入C-c C-c

This command initially displays a buffer which lists interrupted session files, each with its date. You must choose which session to recover from. Typically the one you want is the most recent one. Move point to the one you choose, and type C-c C-c.

然后recover-session考虑您在该会话期间编辑的每个文件;对于每个这样的文件,它会询问是否恢复该文件。如果您回答y某个文件,它会显示该文件及其自动保存文件的日期,然后再次询问是否恢复该文件。对于第二个问题,您必须用 确认yes。如果这样做,Emacs 会访问该文件,但会从自动保存文件中获取文本。

Then recover-session considers each of the files that you were editing during that session; for each such file, it asks whether to recover that file. If you answer y for a file, it shows the dates of that file and its auto-save file, then asks once again whether to recover that file. For the second question, you must confirm with yes. If you do, Emacs visits the file but gets the text from the auto-save file.

完成后recover-session,您选择恢复的文件将出现在 Emacs 缓冲区中。然后你应该保存它们。只有这样——保存它们——才能更新文件本身。

When recover-session is done, the files you’ve chosen to recover are present in Emacs buffers. You should then save them. Only this—saving them—updates the files themselves.

作为最后的手段,如果您的缓冲区中的内容与任何文件都没有关联,或者自动保存的时间不够新,不足以记录重要的更改,则可以使用 等/emacs-buffer.gdb使用 GDB(GNU 调试器)编写脚本从核心转储中检索它们 — 前提是保存了核心转储,并且 Emacs 可执行文件没有删除其调试符号。

As a last resort, if you had buffers with content which were not associated with any files, or if the autosave was not recent enough to have recorded important changes, you can use the etc/emacs-buffer.gdb script with GDB (the GNU Debugger) to retrieve them from a core dump—provided that a core dump was saved, and that the Emacs executable was not stripped of its debugging symbols.

获得核心转储后,将其重命名为另一个名称,例如 core.emacs,这样下次崩溃就不会覆盖它。

As soon as you get the core dump, rename it to another name such as core.emacs, so that another crash won’t overwrite it.

要使用此脚本,gdb请使用 Emacs 可执行文件的文件名和核心转储的文件名运行,例如,'gdb /usr/bin/emacs core.emacs'。在(gdb)提示符下,加载恢复脚本:'源 /usr/src/emacs/etc/emacs-buffer.gdb'。然后键入命令ybuffer-list以查看哪些缓冲区可用。对于每个缓冲区,它列出了一个缓冲区编号。要保存缓冲区,请使用ysave-buffer;您指定缓冲区编号以及要写入该缓冲区的文件名。您应该使用尚不存在的文件名;如果该文件确实存在,则脚本不会备份其旧内容。

To use this script, run gdb with the file name of your Emacs executable and the file name of the core dump, e.g., ‘gdb /usr/bin/emacs core.emacs’. At the (gdb) prompt, load the recovery script: ‘source /usr/src/emacs/etc/emacs-buffer.gdb’. Then type the command ybuffer-list to see which buffers are available. For each buffer, it lists a buffer number. To save a buffer, use ysave-buffer; you specify the buffer number, and the file name to write that buffer into. You should use a file name which does not already exist; if the file does exist, the script does not make a backup of its old contents.


52.7 紧急逃生

52.7 Emergency Escape

在文本终端上,如果您在 Emacs 实际通过退出来响应第一次输入之前输入第二次,紧急退出功能会立即暂停 Emacs 。C-g这样您就可以随时退出 GNU Emacs,无论它挂起的情况有多严重。当一切正常时,Emacs 会C-g快速识别并处理第一个事件,而第二个事件不会触发紧急逃生。但是,如果某些问题阻止 Emacs 正确处理第一个问题C-g,那么第二个问题将使您返回 shell。

On text terminals, the emergency escape feature suspends Emacs immediately if you type C-g a second time before Emacs can actually respond to the first one by quitting. This is so you can always get out of GNU Emacs no matter how badly it might be hung. When things are working properly, Emacs recognizes and handles the first C-g so fast that the second one won’t trigger emergency escape. However, if some problem prevents Emacs from handling the first C-g properly, then the second one will get you back to the shell.

当您在因紧急逃生而暂停后恢复 Emacs 时,它会报告恢复情况并在返回到之前执行的操作之前询问一两个问题:

When you resume Emacs after a suspension caused by emergency escape, it reports the resumption and asks a question or two before going back to what it had been doing:

Emacs 在紧急逃生后正在恢复。
自动保存? (y 或 n)
中止(并转储核心)? (y 或 n)
Emacs is resuming after an emergency escape.
Auto-save? (y or n)
Abort (and dump core)? (y or n)

回答每个问题,其后带有y或。 nRET

Answer each question with y or n followed by RET.

说着y自动保存?' 导致立即自动保存所有已修改的缓冲区,其中启用了自动保存。说n 跳过这个。如果 Emacs 处于无法安全地进行自动保存的状态,则可以忽略此问题。

Saying y to ‘Auto-save?’ causes immediate auto-saving of all modified buffers in which auto-saving is enabled. Saying n skips this. This question is omitted if Emacs is in a state where auto-saving cannot be done safely.

说着y中止(并转储核心)?' 导致 Emacs 崩溃,转储核心。这是为了让向导能够找出 Emacs 无法退出的原因。核心转储后不会继续执行。

Saying y to ‘Abort (and dump core)?’ causes Emacs to crash, dumping core. This is to enable a wizard to figure out why Emacs was failing to quit in the first place. Execution does not continue after a core dump.

如果您回答这个问题n,Emacs 将继续执行。幸运的话,Emacs 最终会执行所请求的退出。如果没有,后续的每个C-g操作都会再次调用紧急逃生。

If you answer this question n, Emacs execution resumes. With luck, Emacs will ultimately do the requested quit. If not, each subsequent C-g invokes emergency escape again.

如果 Emacs 并不是真正挂起,只是速度缓慢,您可能会 C-g无意中调用双重功能。然后继续回答n这两个问题,你就会回到之前的状态。你所要求的退出将会逐渐发生。

If Emacs is not really hung, just slow, you may invoke the double C-g feature without really meaning to. Then just resume and answer n to both questions, and you will get back to the former state. The quit you requested will happen by and by.

紧急逃生仅对文本终端有效。在图形显示上,您可以使用鼠标来终止 Emacs 或切换到另一个程序。

Emergency escape is active only for text terminals. On graphical displays, you can use the mouse to kill Emacs or switch to another program.

在 MS-DOS 上,您必须键入(两次)才能实现紧急逃生,但在某些情况下它不起作用,例如系统调用挂起或 Emacs 陷入 C 代码的紧密循环中。 C-Break

On MS-DOS, you must type C-Break (twice) to cause emergency escape—but there are cases where it won’t work, when a system call hangs or when Emacs is stuck in a tight loop in C code.


52.8 如果DEL删除失败

52.8 If DEL Fails to Delete

每个键盘都有一个大键,通常标记为BACKSPACE,通常用于删除您键入的最后一个字符。在 Emacs 中,该键应该等同于DEL.

Every keyboard has a large key, usually labeled BACKSPACE, which is ordinarily used to erase the last character that you typed. In Emacs, this key is supposed to be equivalent to DEL.

当 Emacs 在图形显示器上启动时,它会自动确定哪个键应该是DEL。在某些异常情况下,Emacs 从系统获取错误信息,BACKSPACE 最终会向前删除而不是向后删除。

When Emacs starts up on a graphical display, it determines automatically which key should be DEL. In some unusual cases, Emacs gets the wrong information from the system, and BACKSPACE ends up deleting forwards instead of backwards.

有些键盘还有一个Delete键,通常用于删除前进。如果这个键在 Emacs 中向后删除,那也表明 Emacs 得到了错误的信息——但意义相反。

Some keyboards also have a Delete key, which is ordinarily used to delete forwards. If this key deletes backward in Emacs, that too suggests Emacs got the wrong information—but in the opposite sense.

在文本终端上,如果您发现BACKSPACE提示输入帮助命令,例如Control-h,而不是删除字符,则意味着该键实际上正在发送 '学士' 特点。 Emacs 应该将BS其视为DEL,但事实并非如此。

On a text terminal, if you find that BACKSPACE prompts for a Help command, like Control-h, instead of deleting a character, it means that key is actually sending the ‘BS’ character. Emacs ought to be treating BS as DEL, but it isn’t.

在所有这些情况下,立即的补救措施都是相同的:使用命令M-x normal-erase-is-backspace-mode。这会在 Emacs 支持的两种处理模式之间切换DEL,因此如果 Emacs 以错误的模式启动,则应切换到正确的模式。在文本终端上,如果您想在BS 被视为时寻求帮助DEL,请使用;F1代替 如果发送字符代码 127,也可能有效。 C-hC-?

In all of those cases, the immediate remedy is the same: use the command M-x normal-erase-is-backspace-mode. This toggles between the two modes that Emacs supports for handling DEL, so if Emacs starts in the wrong mode, this should switch to the right mode. On a text terminal, if you want to ask for help when BS is treated as DEL, use F1 instead of C-h; C-? may also work, if it sends character code 127.

要修复每个 Emacs 会话中的问题,请将以下行之一放入初始化文件中(请参阅Emacs 初始化文件)。对于上面的第一种情况,BACKSPACE向前删除而不是向后删除,请使用此行使行为BACKSPACE如下DEL

To fix the problem in every Emacs session, put one of the following lines into your initialization file (see The Emacs Initialization File). For the first case above, where BACKSPACE deletes forwards instead of backwards, use this line to make BACKSPACE act as DEL:

(正常擦除是退格模式 0)
(normal-erase-is-backspace-mode 0)

对于其他两种情况,请使用以下行:

For the other two cases, use this line:

(正常擦除是退格模式 1)
(normal-erase-is-backspace-mode 1)

解决每个 Emacs 会话问题的另一种方法是自定义变量normal-erase-is-backspace:值 t指定模式,其中BSorBACKSPACEDEL,并nil指定其他模式。请参阅简易定制界面

Another way to fix the problem for every Emacs session is to customize the variable normal-erase-is-backspace: the value t specifies the mode where BS or BACKSPACE is DEL, and nil specifies the other mode. See Easy Customization Interface.


53 报告错误

53 Reporting Bugs

如果您认为您发现了 Emacs 中的错误,请报告它。我们不能承诺修复它,或者总是同意它是一个错误,但我们当然想听到它。这同样适用于您希望添加的新功能。本节将帮助您确定是否发现了错误,如果是,则构建有效的错误报告。

If you think you have found a bug in Emacs, please report it. We cannot promise to fix it, or always to agree that it is a bug, but we certainly want to hear about it. The same applies for new features you would like to see added. This section will help you to determine whether you found a bug, and if so, construct an effective bug report.

当您发现可能存在错误的内容时,一般过程如下:

The general procedure when you find something that could be a bug is as follows:

  • 查看您发现的是否是已知问题或已报告和/或修复的错误。请参阅阅读现有错误报告和已知问题,您将在其中找到如何查找已知问题和错误。
  • See if what you found is a known problem or a bug that was already reported and/or fixed. See Reading Existing Bug Reports and Known Problems, where you will find how to look for known problems and bugs.
  • 如果您不确定所看到的行为是否是错误,请参阅何时存在错误,它告诉我们在 Emacs 中什么是明显的错误。
  • If you are unsure whether the behavior you see is a bug, see When Is There a Bug, which tells what we consider as clear bugs in Emacs.
  • 一旦您确定发现了错误,请参阅了解错误报告,这可以帮助您以最有效的方式描述您所看到的内容,使我们能够更轻松地重现问题并调查问题。
  • Once you decide you found a bug, see Understanding Bug Reporting, which helps you in describing what you see in the most efficient manner, making our job of reproducing the issue and investigating it easier.
  • 接下来,请参阅错误报告清单,我们在其中详细描述了如何提交错误报告以及其中应包含哪些信息。简而言之,您可以使用 Emacs 命令通过电子邮件提交错误报告report-emacs-bug,该命令可以帮助您完成此操作。提交错误报告会启动调查和修复错误的过程,您将收到讨论该错误的电子邮件副本,我们可能会要求您提供更多信息、测试可能的修复等。
  • Next, see Checklist for Bug Reports, where we describe in detail how to submit a bug report and what information to include in it. In a nutshell, you submit a bug report via electronic mail using the Emacs command report-emacs-bug, which assists you in doing so. Submitting a bug report starts the process of investigating and fixing the bug, where you will receive copies of email messages discussing the bug, in which we might ask you to provide more information, test possible fixes, etc.
  • 最后,如果您想对 Emacs 提出具体更改,无论是修复错误、添加新功能还是改进我们的文档,请参阅 发送 GNU Emacs 补丁,了解有关提交此类更改的详细信息。
  • Finally, if you want to propose specific changes to Emacs, whether to fix a bug, add a new feature, or improve our documentation, please see Sending Patches for GNU Emacs, for details about submitting such changes.

53.1 阅读现有的错误报告和已知问题

53.1 Reading Existing Bug Reports and Known Problems

在报告错误之前,如果可能的话,请检查我们是否已经了解该错误。事实上,它可能已经在 Emacs 的后续版本或开发版本中得到修复。以下是您可以阅读有关已知问题的主要位置的列表:

Before reporting a bug, if at all possible, please check to see if we already know about it. Indeed, it may already have been fixed in a later release of Emacs, or in the development version. Here is a list of the main places you can read about known issues:

  • 等/问题文件;键入C-h C-p以阅读它。该文件包含在编译、安装和运行 Emacs 时遇到的特别众所周知的问题的列表,特别强调由其他软件引起的在 Emacs 中无法轻松解决的问题。通常,您会发现有关解决方法和解决方案的建议。
  • The etc/PROBLEMS file; type C-h C-p to read it. This file contains a list of particularly well-known issues that have been encountered in compiling, installing and running Emacs, with special emphasis on issues caused by other software that cannot be easily solved in Emacs. Often, you will find there suggestions for workarounds and solutions.
  • GNU Bug Tracker 位于https://debbugs.gnu.org。 Emacs 错误和问题归档在跟踪器中的“emacs' 包裹。跟踪器记录有关每个错误的状态、初始错误报告以及错误报告者和参与讨论和修复错误的 Emacs 开发人员的后续消息。您可以按主题、严重性和其他条件搜索错误。对于更复杂的搜索条件,请使用 https://debbugs.gnu.org/cgi/search.cgi

    您可以使用包从 Emacs 中浏览它,而不是作为网页浏览 bug 跟踪器,debbugs该包可以通过包菜单下载(请参阅Emacs Lisp 包)。该包提供了M-x debbugs-gnu列出错误并M-x debbugs-gnu-search搜索特定错误的命令。由 Emacs 维护者应用的用户标签由 表示M-x debbugs-gnu-usertags

  • The GNU Bug Tracker at https://debbugs.gnu.org. Emacs bugs and issues are filed in the tracker under the ‘emacs’ package. The tracker records information about the status of each bug, the initial bug report, and the follow-up messages by the bug reporter and Emacs developers who participate in discussing and fixing the bug. You can search for bugs by subject, severity, and other criteria. For more complex search criteria, use https://debbugs.gnu.org/cgi/search.cgi.

    Instead of browsing the bug tracker as a web page, you can browse it from Emacs using the debbugs package, which can be downloaded via the Package Menu (see Emacs Lisp Packages). This package provides the command M-x debbugs-gnu to list bugs, and M-x debbugs-gnu-search to search for a specific bug. User tags, applied by the Emacs maintainers, are shown by M-x debbugs-gnu-usertags.

  • 这 'bug-gnu-emacs' 邮件列表(也可用作新闻组 'gnu.emacs 错误')。您可以在https://lists.gnu.org/mailman/listinfo/bug-gnu-emacs阅读列表档案 。该列表充当 Emacs 错误报告和发送到错误跟踪器的后续消息的镜像。它还包含 bug 跟踪器引入之前(2008 年初)的旧 bug 报告。

    如果您愿意,可以订阅该列表。请注意,其目的是为 Emacs 维护人员提供有关错误和功能请求的信息,因此报告可能包含相当大量的数据;观众不应该对此抱怨。

  • The ‘bug-gnu-emacs’ mailing list (also available as the newsgroup ‘gnu.emacs.bug’). You can read the list archives at https://lists.gnu.org/mailman/listinfo/bug-gnu-emacs. This list works as a mirror of the Emacs bug reports and follow-up messages which are sent to the bug tracker. It also contains old bug reports from before the bug tracker was introduced (in early 2008).

    If you like, you can subscribe to the list. Be aware that its purpose is to provide the Emacs maintainers with information about bugs and feature requests, so reports may contain fairly large amounts of data; spectators should not complain about this.

  • 这 'emacs 预测试错误' 邮件列表。该列表已不再使用,主要具有历史意义。曾经,它被用于 Emacs 开发(即尚未发布)版本中的错误报告。您可以在https://lists.gnu.org/r/emacs-pretest-bug/上阅读 2003 年至 2007 年中期的档案 。如今,发送到此列表的电子邮件将被重定向到“bug-gnu-emacs'。
  • The ‘emacs-pretest-bug’ mailing list. This list is no longer used, and is mainly of historical interest. At one time, it was used for bug reports in development (i.e., not yet released) versions of Emacs. You can read the archives for 2003 to mid 2007 at https://lists.gnu.org/r/emacs-pretest-bug/. Nowadays, email messages sent to this list are redirected to ‘bug-gnu-emacs’.
  • 这 'emacs 开发' 邮件列表。有时人们会向此邮件列表报告错误。然而,这不是该列表的主要目的,最好将错误报告发送到错误列表。在报告错误之前,您不应该觉得有必要阅读此列表。
  • The ‘emacs-devel’ mailing list. Sometimes people report bugs to this mailing list. This is not the main purpose of the list, however, and it is much better to send bug reports to the bug list. You should not feel obliged to read this list before reporting a bug.

53.2 什么时候有Bug

53.2 When Is There a Bug

如果 Emacs 访问无效的内存位置(也称为“分段错误”)或退出时显示操作系统错误消息,表明程序存在问题(而不是“磁盘已满”),那么它肯定是一个错误。

If Emacs accesses an invalid memory location (a.k.a. “segmentation fault”) or exits with an operating system error message that indicates a problem in the program (as opposed to something like “disk full”), then it is certainly a bug.

如果 Emacs 显示与缓冲区的内容不正确对应,则这是一个错误。但是您应该检查诸如缓冲区缩小(请参阅缩小)之类的功能,这些功能可以隐藏部分缓冲区或更改其显示方式,这些功能不负责。

If the Emacs display does not correspond properly to the contents of the buffer, then it is a bug. But you should check that features like buffer narrowing (see Narrowing), which can hide parts of the buffer or change how it is displayed, are not responsible.

花费很长时间才能完成一个命令可能是一个错误,但您必须确保这确实是 Emacs 的错误。有些命令只是需要很长时间。输入C-g(在 MS-DOS 上),然后 查看 Emacs 收到的输入是否是您想要输入的内容;如果您知道输入应该被快速处理,请报告错误。如果您不知道该命令是否需要花费很长时间,请查看手册或寻求帮助来找出答案。 C-BreakC-h l

Taking forever to complete a command can be a bug, but you must make sure that it is really Emacs’s fault. Some commands simply take a long time. Type C-g (C-Break on MS-DOS) and then C-h l to see whether the input Emacs received was what you intended to type; if the input was such that you know it should have been processed quickly, report a bug. If you don’t know whether the command should take a long time, find out by looking in the manual or by asking for assistance.

如果您熟悉的命令在其通常定义应该合理的情况下导致 Emacs 错误消息,那么它可能是一个错误。

If a command you are familiar with causes an Emacs error message in a case where its usual definition ought to be reasonable, it is probably a bug.

如果一个命令做了错误的事情,那就是一个错误。但请确保您确切地知道它应该做什么。如果您不熟悉该命令,它实际上可能工作正常。如果有疑问,请阅读命令的文档(请参阅命令或变量名称的帮助)。

If a command does the wrong thing, that is a bug. But be sure you know for certain what it ought to have done. If you aren’t familiar with the command, it might actually be working right. If in doubt, read the command’s documentation (see Help by Command or Variable Name).

命令的预期定义可能不是用于编辑的最佳定义。这是一个非常重要的问题,但也是一个判断问题。而且,由于对某些现有特征的无知,很容易得出这样的结论。最好不要抱怨这样的问题,直到您以通常的方式检查了文档,确信自己理解了它,并且确定您想要的东西不可用。也请询问其他 Emacs 用户。如果您在仔细阅读手册后不确定该命令的用途,请检查索引和术语表中是否有任何不清楚的术语。

A command’s intended definition may not be the best possible definition for editing with. This is a very important sort of problem, but it is also a matter of judgment. Also, it is easy to come to such a conclusion out of ignorance of some of the existing features. It is probably best not to complain about such a problem until you have checked the documentation in the usual ways, feel confident that you understand it, and know for certain that what you want is not available. Ask other Emacs users, too. If you are not sure what the command is supposed to do after a careful reading of the manual, check the index and glossary for any terms that may be unclear.

如果仔细重读手册后您仍然不明白该命令应该做什么,则表明手册中存在错误,您应该报告该错误。本手册的作用是让非 Emacs 专家(包括您)明白所有内容。报告文档错误与报告程序错误同样重要。

If after careful rereading of the manual you still do not understand what the command should do, that indicates a bug in the manual, which you should report. The manual’s job is to make everything clear to people who are not Emacs experts—including you. It is just as important to report documentation bugs as program bugs.

如果函数或变量的内置文档与手册不一致,则其中之一一定是错误的;这是一个错误。

If the built-in documentation for a function or variable disagrees with the manual, one of them must be wrong; that is a bug.

对于不属于 Emacs 的包的问题,​​最好首先向包开发人员报告它们。

For problems with packages that are not part of Emacs, it is better to begin by reporting them to the package developers.


53.3 理解错误报告

53.3 Understanding Bug Reporting

当您确定存在错误时,报告它并以有用的方式报告它很重要。最有用的是对您键入的命令的准确描述,从运行 Emacs 的 shell 命令开始,直到问题发生,以及键入这些命令所产生的效果。

When you decide that there is a bug, it is important to report it, and to report it in a way which is useful. What is most useful is an exact description of what commands you type, starting with the shell command to run Emacs, until the problem happens, and the effects produced by typing those commands.

报告错误最重要的原则是报告 事实。假设和口头描述不能替代详细的原始数据。报道事实很简单,但许多人却竭力提出解释并报道,而不是报道事实。如果这些解释是基于对 Emacs 如何实现的猜测,那么它们可能没有用;同时,由于缺乏事实,我们将无法获得有关该错误的真实信息。如果您想实际调试问题,并报告不仅仅是猜测的解释,这很有用,但也请包括原始事实。

The most important principle in reporting a bug is to report facts. Hypotheses and verbal descriptions are no substitute for the detailed raw data. Reporting the facts is straightforward, but many people strain to posit explanations and report them instead of the facts. If the explanations are based on guesses about how Emacs is implemented, they might not be useful; meanwhile, lacking the facts, we will have no real information about the bug. If you want to actually debug the problem, and report explanations that are more than guesses, that is useful—but please include the raw facts as well.

例如,假设您输入,访问一个(您知道的)恰好相当大的文件,并且 Emacs 显示 'C-x C-f /glorp/baz.ugh RET我今天感觉很漂亮'。错误报告需要提供所有这些信息。您不应该假设问题是由于文件的大小造成的,并说:“我访问了一个大文件,Emacs 显示了 '我今天感觉很漂亮'。”这就是我们所说的“猜测解释”。问题可能是由于存在 'z' 在文件名中。如果是这样,那么当我们收到您的报告时,我们会尝试使用一些大文件来解决该问题,可能没有“z' 在它的名字中,并没有看到任何问题。我们不可能猜测我们应该尝试访问带有 ' 的文件z' 在它的名字中。

For example, suppose that you type C-x C-f /glorp/baz.ugh RET, visiting a file which (you know) happens to be rather large, and Emacs displays ‘I feel pretty today’. The bug report would need to provide all that information. You should not assume that the problem is due to the size of the file and say, “I visited a large file, and Emacs displayed ‘I feel pretty today’.” This is what we mean by “guessing explanations”. The problem might be due to the fact that there is a ‘z’ in the file name. If this is so, then when we got your report, we would try out the problem with some large file, probably with no ‘z’ in its name, and not see any problem. There is no way we could guess that we should try visiting a file with a ‘z’ in its name.

您甚至不应该说“访问文件”而不是C-x C-f。这是因为一个文件可以通过多种方式访问​​,并且不能确定所有这些方式都会重现该问题。同样,不要说“如果我一行中有三个字符”,而是说“在我输入之后”,如果这是您输入文本的方式,也就是说,请告诉我们在您的情况下产生问题的文本。 RET A B C RET C-p

You should not even say “visit a file” instead of C-x C-f. That’s because a file can be visited in more than one way, and there’s no certainty that all of them reproduce the problem. Similarly, rather than saying “if I have three characters on the line”, say “after I type RET A B C RET C-p”, if that is the way you entered the text—that is, tell us about the text which in your case produced the problem.

emacs -Q如果可能,请尝试通过调用 Emacs (以便 Emacs 启动时不进行初始自定义;请参阅初始选项)来快速重现该错误 ,并重复触发该错误所采取的步骤。如果您可以通过这种方式重现错误,则可以排除您个人自定义中的错误,并使错误更容易重现。然后,您的错误报告应该首先说明您使用 启动 Emacs emacs -Q,然后是重现该错误的确切步骤顺序。如果可能,请告知我们重现错误所需的任何文件的确切内容。

If possible, try quickly to reproduce the bug by invoking Emacs with emacs -Q (so that Emacs starts with no initial customizations; see Initial Options), and repeating the steps that you took to trigger the bug. If you can reproduce the bug this way, that rules out bugs in your personal customizations and makes the bug much easier to reproduce. Then your bug report should begin by stating that you started Emacs with emacs -Q, followed by the exact sequence of steps for reproducing the bug. If possible, inform us of the exact contents of any file that is needed to reproduce the bug.

有些错误无法重现emacs -Q;有些根本不容易重现。在这种情况下,您应该报告您所拥有的内容,但是,像以前一样,请坚持有关您第一次触发错误的操作的原始事实。

Some bugs are not reproducible from emacs -Q; some are not easily reproducible at all. In that case, you should report what you have—but, as before, please stick to the raw facts about what you did to trigger the bug the first time.

如果您想要报告多个问题,请为每个问题单独提交错误报告。

If you have multiple issues that you want to report, please make a separate bug report for each.


53.4 错误报告清单

53.4 Checklist for Bug Reports

在报告错误之前,首先尝试查看问题是否已报告(请参阅阅读现有错误报告和已知问题)。

Before reporting a bug, first try to see if the problem has already been reported (see Reading Existing Bug Reports and Known Problems).

如果可以,请尝试最新版本的 Emacs,看看问题是否已得到解决。更好的是尝试最新的开发版本。我们认识到这对某些人来说并不容易,因此不要认为您在举报之前绝对必须这样做。

If you are able to, try the latest release of Emacs to see if the problem has already been fixed. Even better is to try the latest development version. We recognize that this is not easy for some people, so do not feel that you absolutely must do this before making a report.

为 Emacs 编写错误报告的最佳方法是使用命令 M-x report-emacs-bug。这会设置一个邮件缓冲区(请参阅发送邮件)并自动插入一些基本信息。然而,它无法提供所有必要的信息;您仍应阅读并遵循以下指南,以便您可以在发送消息之前手动输入其他重要信息。您可能会觉得插入的某些信息 M-x report-emacs-bug不相关,但除非您绝对确定,否则最好保留它,以便开发人员自行决定。

The best way to write a bug report for Emacs is to use the command M-x report-emacs-bug. This sets up a mail buffer (see Sending Mail) and automatically inserts some of the essential information. However, it cannot supply all the necessary information; you should still read and follow the guidelines below, so you can enter the other crucial information by hand before you send the message. You may feel that some of the information inserted by M-x report-emacs-bug is not relevant, but unless you are absolutely sure, it is best to leave it, so that the developers can decide for themselves.

当您写完报告后,请输入报告C-c C-c,然后将其发送给位于 bug-gnu-emacs的 Emacs 维护人员。如果您无法从 Emacs 内部发送邮件,您可以将报告文本复制到普通邮件客户端(如果您的系统支持,您可以键入C-c M-i让 Emacs 为您执行此操作)并将其发送到该地址。或者,您可以简单地向该地址发送一封电子邮件来描述问题,包括下面提到的必要信息。

When you have finished writing your report, type C-c C-c and it will be sent to the Emacs maintainers at bug-gnu-emacs. If you cannot send mail from inside Emacs, you can copy the text of your report to your normal mail client (if your system supports it, you can type C-c M-i to have Emacs do this for you) and send it to that address. Or you can simply send an email to that address describing the problem, including the necessary information mentioned below.

如果您想向 Emacs 提交代码(以解决问题或实现新功能),最简单的方法是将补丁发送到 Emacs 问题跟踪器。使用该M-x submit-emacs-patch命令,其工作方式与报告错误时非常相似;请参阅发送 GNU Emacs 补丁

If you want to submit code to Emacs (to fix a problem or implement a new feature), the easiest way to do this is to send a patch to the Emacs issue tracker. Use the M-x submit-emacs-patch command for that, which works much the same as when reporting bugs; see Sending Patches for GNU Emacs.

无论如何,您的报告将发送至“bug-gnu-emacs' 邮件列表,并存储在 GNU Bug Tracker 中,网址为 https://debbugs.gnu.org。请附上有效的回复电子邮件地址,以便我们需要向您询问有关报告的更多信息。提交内容会经过审核,因此您的报告实际显示在跟踪器上可能会有延迟。

In any case, your report will be sent to the ‘bug-gnu-emacs’ mailing list, and stored in the GNU Bug Tracker at https://debbugs.gnu.org. Please include a valid reply email address, in case we need to ask you for more information about your report. Submissions are moderated, so there may be a delay before your report actually appears on the tracker.

您无需了解 GNU Bug Tracker 的工作原理即可报告 bug,但如果您愿意,您可以阅读跟踪器的 在线文档以查看可以使用的各种功能。

You do not need to know how the GNU Bug Tracker works in order to report a bug, but if you want to, you can read the tracker’s online documentation to see the various features you can use.

所有邮件发送至 'bug-gnu-emacs' 邮件列表也通过网关访问 'gnu.emacs 错误' 新闻组。反之亦然,但我们要求您不要通过新闻组发布错误报告(或回复)。如果我们需要获取更多信息,它可能会让联系您变得更加困难,并且它不能与错误跟踪器很好地集成。

All mail sent to the ‘bug-gnu-emacs’ mailing list is also gatewayed to the ‘gnu.emacs.bug’ newsgroup. The reverse is also true, but we ask you not to post bug reports (or replies) via the newsgroup. It can make it much harder to contact you if we need to ask for more information, and it does not integrate well with the bug tracker.

如果您的数据超过500,000字节,请不要直接将其包含在错误报告中;相反,可以根据要求提供发送信息,或者在线提供并说明地址。大附件最好压缩发送。

If your data is more than 500,000 bytes, please don’t include it directly in the bug report; instead, offer to send it on request, or make it available online and say where. Large attachments are best sent compressed.

GNU Bug Tracker 将为您的报告分配一个 Bug 编号;请在下面的讨论中使用它,将Bug地址保留在收件人列表中,以便Bug讨论被跟踪器记录。错误地址将类似于“nnnnn @debbugs.gnu.org',其中nnnnn是错误编号。

The GNU Bug Tracker will assign a bug number to your report; please use it in the following discussions, keeping the bug address in the list of recipients, so that the bug discussion is recorded by the tracker. The bug address will look like ‘nnnnn@debbugs.gnu.org’, where nnnnn is the bug number.

为了使维护人员能够调查错误,您的报告应包含以下所有内容:

To enable maintainers to investigate a bug, your report should include all these things:

  • 描述您观察到的您认为不正确的行为。例如,“Emacs 进程收到致命信号”,或者“结果文本如下,我认为这是错误的”。

    当然,如果错误是 Emacs 收到致命信号,那么就不能错过它。但如果错误是不正确的文本,维护者可能无法注意到问题所在。为什么要听凭机遇呢?

    即使你遇到的问题是一个致命的信号,你仍然应该明确地说出来。假设发生了一些奇怪的情况,例如,您的源代码副本不同步,或者您在系统上的 C 库中遇到了错误。 (这已经发生了!)您的副本可能会崩溃,而此处的副本可能不会。如果你预计会崩溃,那么当这里的 Emacs 未能崩溃时,我们就会知道该错误没有发生。如果您不说预计会发生崩溃,那么我们将不知道该错误是否正在发生 - 我们将无法从我们的观察中得出任何结论。

    通常,对行为和重现问题的方式的描述需要指定以下一个或多个方面:

    • 重现错误所需的任何文件的完整文本。

      如果您能告诉我们在不访问任何文件的情况下导致问题的方法,请告诉我们。这使得调试变得更加容易。如果您确实需要文件,请确保安排我们查看其确切内容。例如,行尾是否有空格,或者缓冲区中最后一行之后是否有换行符可能很重要(没有什么应该关心最后一行是否终止,但尝试告诉错误)。

    • 我们需要输入精确的命令来重现错误。如果可能的话,给出以 ' 开头的 Emacs 的完整配方-Q' 选项(参见初始选项)。这会绕过您的个人定制。

      精确记录 Emacs 输入的一种方法是编写一个 dribble 文件。要启动该文件,请使用命令。从那时起,Emacs 会将您的所有输入复制到指定的 dribble 文件中,直到 Emacs 进程被终止。请注意,敏感信息(例如密码)最终可能会记录在运球文件中。 M-x open-dribble-file

    • 如果错误是 Emacs 手册或 Emacs Lisp 参考手册未能描述 Emacs 的实际行为,或者文本令人困惑,请从手册中复制您认为有问题的文本。如果节很小,只需节名称就足够了。
    • 如果错误的表现是 Emacs 错误消息,则报告错误消息的精确文本以及显示 Emacs 中的 Lisp 程序如何到达错误的回溯非常重要。

      要准确获取错误消息文本,请从 *留言*缓冲到错误报告中。复制全部,而不是部分。

    • 检查您加载到 Lisp 世界中的任何程序(包括初始化文件)是否设置了可能影响 Emacs 功能的任何变量。另外,看看问题是否发生在新启动的 Emacs 中,而没有加载初始化文件(使用开关启动 Emacs-Q以防止加载初始化文件)。如果问题没有发生,则必须报告必须加载到 Lisp 世界中才能导致问题发生的任何程序的准确内容。
    • 如果问题确实取决于 init 文件或其他不属于标准 Emacs 系统的 Lisp 程序,那么您应该首先向其维护者投诉,以确保这不是这些程序中的错误。在他们验证他们正在以预期的方式使用 Emacs 后,他们应该报告该错误。
    • 如果您想提及 GNU Emacs 源代码中的某些内容,请显示该代码行以及几行上下文。不要只给出行号。

      开发源代码中的行号与您的源代码中的行号不匹配。维护人员需要做额外的工作才能确定您的版本中给定行号的代码,而且我们无法确定。

    • 对于文本模式终端上可能出现的显示错误,终端类型(环境变量的值TERM)、终端的完整 termcap 条目来自/etc/termcap(因为该文件在所有机器上并不相同),以及 Emacs 实际发送到终端的输出。

      收集终端输出的方法是 M-x open-termscript在启动 Emacs 后立即调用该命令;它会提示您输入记录所有终端输出的文件名,直到 Emacs 进程被终止。如果问题发生在 Emacs 启动时,请将 Lisp 表达式

      (开放术语脚本“~/termscript”)
      

      到 Emacs 初始化文件中,以便 Emacs 第一次显示屏幕时打开 termscript 文件。

      请注意:如果不访问引发错误的终端类型,修复与终端相关的错误通常很困难,有时甚至是不可能的。

  • A description of what behavior you observe that you believe is incorrect. For example, “The Emacs process gets a fatal signal”, or, “The resulting text is as follows, which I think is wrong.”

    Of course, if the bug is that Emacs gets a fatal signal, then one can’t miss it. But if the bug is incorrect text, the maintainer might fail to notice what is wrong. Why leave it to chance?

    Even if the problem you experience is a fatal signal, you should still say so explicitly. Suppose something strange is going on, such as, your copy of the source is out of sync, or you have encountered a bug in the C library on your system. (This has happened!) Your copy might crash and the copy here might not. If you said to expect a crash, then when Emacs here fails to crash, we would know that the bug was not happening. If you don’t say to expect a crash, then we would not know whether the bug was happening—we would not be able to draw any conclusion from our observations.

    Usually, description of the behavior and of the way to reproduce the problem needs to specify one or more of the following aspects:

    • The complete text of any files needed to reproduce the bug.

      If you can tell us a way to cause the problem without visiting any files, please do so. This makes it much easier to debug. If you do need files, make sure you arrange for us to see their exact contents. For example, it can matter whether there are spaces at the ends of lines, or a newline after the last line in the buffer (nothing ought to care whether the last line is terminated, but try telling the bugs that).

    • The precise commands we need to type to reproduce the bug. If at all possible, give a full recipe for an Emacs started with the ‘-Q’ option (see Initial Options). This bypasses your personal customizations.

      One way to record the input to Emacs precisely is to write a dribble file. To start the file, use the command M-x open-dribble-file. From then on, Emacs copies all your input to the specified dribble file until the Emacs process is killed. Be aware that sensitive information (such as passwords) may end up recorded in the dribble file.

    • If the bug is that the Emacs Manual or the Emacs Lisp Reference Manual fails to describe the actual behavior of Emacs, or that the text is confusing, copy in the text from the manual which you think is at fault. If the section is small, just the section name is enough.
    • If the manifestation of the bug is an Emacs error message, it is important to report the precise text of the error message, and a backtrace showing how the Lisp program in Emacs arrived at the error.

      To get the error message text accurately, copy it from the *Messages* buffer into the bug report. Copy all of it, not just part.

    • Check whether any programs you have loaded into the Lisp world, including your initialization file, set any variables that may affect the functioning of Emacs. Also, see whether the problem happens in a freshly started Emacs without loading your initialization file (start Emacs with the -Q switch to prevent loading the init files). If the problem does not occur then, you must report the precise contents of any programs that you must load into the Lisp world in order to cause the problem to occur.
    • If the problem does depend on an init file or other Lisp programs that are not part of the standard Emacs system, then you should make sure it is not a bug in those programs by complaining to their maintainers first. After they verify that they are using Emacs in a way that is supposed to work, they should report the bug.
    • If you wish to mention something in the GNU Emacs source, show the line of code with a few lines of context. Don’t just give a line number.

      The line numbers in the development sources don’t match those in your sources. It would take extra work for the maintainers to determine what code is in your version at a given line number, and we could not be certain.

    • For possible display bugs on text-mode terminals, the terminal type (the value of environment variable TERM), the complete termcap entry for the terminal from /etc/termcap (since that file is not identical on all machines), and the output that Emacs actually sent to the terminal.

      The way to collect the terminal output is to invoke the command M-x open-termscript just after starting Emacs; it will prompt you for the name of the file where to record all terminal output until the Emacs process is killed. If the problem happens when Emacs starts up, put the Lisp expression

      (open-termscript "~/termscript")
      

      into your Emacs initialization file so that the termscript file will be open when Emacs displays the screen for the first time.

      Be warned: it is often difficult, and sometimes impossible, to fix a terminal-dependent bug without access to a terminal of the type that stimulates the bug.

  • Emacs 的版本号。如果没有这个,我们就不知道在当前版本的 GNU Emacs 中寻找 bug 是否有任何意义。

    M-x report-emacs-bug自动包含此信息,但如果您没有在报告中使用该命令,则可以通过键入 来获取版本号。如果该命令不起作用,您可能拥有 GNU Emacs 之外的其他东西,因此您必须在其他地方报告该错误。 M-x emacs-version RET

  • The version number of Emacs. Without this, we won’t know whether there is any point in looking for the bug in the current version of GNU Emacs.

    M-x report-emacs-bug includes this information automatically, but if you are not using that command for your report you can get the version number by typing M-x emacs-version RET. If that command does not work, you probably have something other than GNU Emacs, so you will have to report the bug somewhere else.

  • 您正在使用的计算机类型,以及操作系统名称和版本号(同样,自动包含在 中)。 也提供此信息。复制其输出M-x report-emacs-bugM-x emacs-version RET*留言* buffer,这样就可以全部获取并且准确获取,或者使用 将版本信息插入到当前缓冲区中。 C-u M-x emacs-version RET
  • The type of machine you are using, and the operating system name and version number (again, automatically included by M-x report-emacs-bug). M-x emacs-version RET provides this information too. Copy its output from the *Messages* buffer, so that you get it all and get it accurately, or use C-u M-x emacs-version RET to insert the version information into the current buffer.
  • configure构建 Emacs 时为命令提供的命令行参数(自动包含在 中M-x report-emacs-bug)。
  • The command-line arguments given to the configure command when Emacs was built (automatically included by M-x report-emacs-bug).
  • 您对 Emacs 源代码所做的任何修改的完整列表。 (我们可能没有时间调查该错误,除非它发生在未经修改的 Emacs 中。但如果您进行了修改但没有告诉我们,那么您就让我们白费力气了。)

    准确地了解这些变化。仅用英语进行描述是不够的,请为它们发送统一的上下文差异。

    添加您自己的文件,或移植到另一台机器,都是对源代码的修改。

  • A complete list of any modifications you have made to the Emacs source. (We may not have time to investigate the bug unless it happens in an unmodified Emacs. But if you’ve made modifications and you don’t tell us, you are sending us on a wild goose chase.)

    Be precise about these changes. A description in English is not enough—send a unified context diff for them.

    Adding files of your own, or porting to another machine, is a modification of the source.

  • 与安装 GNU Emacs 标准过程的任何其他偏差的详细信息。
  • Details of any other deviations from the standard procedure for installing GNU Emacs.
  • 如果非ASCII文本或国际化相关,则为启动 Emacs 时的当前语言环境。这会自动包含在M-x report-emacs-bug;或者,在 GNU/Linux 和 Unix 系统上,或者如果您使用 POSIX 风格的 shell(例如 Bash),则可以使用此 shell 命令来查看相关值:
    回声 LC_ALL=$LC_ALL LC_COLLATE=$LC_COLLATE LC_CTYPE=$LC_CTYPE \
      LC_MESSAGES=$LC_MESSAGES LC_TIME=$LC_TIME LANG=$LANG
    

    locale如果您的系统有该命令, 您还可以使用该命令来显示您的区域设置。

  • If non-ASCII text or internationalization is relevant, the locale that was current when you started Emacs. This is automatically included by M-x report-emacs-bug; alternatively, on GNU/Linux and Unix systems, or if you use a POSIX-style shell such as Bash, you can use this shell command to view the relevant values:
    echo LC_ALL=$LC_ALL LC_COLLATE=$LC_COLLATE LC_CTYPE=$LC_CTYPE \
      LC_MESSAGES=$LC_MESSAGES LC_TIME=$LC_TIME LANG=$LANG
    

    You can also use the locale command, if your system has it, to display your locale settings.

以下是错误报告中不必要的一些内容:

Here are some things that are not necessary in a bug report:

  • 对错误包络的描述——对于可重现的错误来说,这不是必需的。

    遇到错误的人通常会花费大量时间来调查输入文件的哪些更改将使错误消失以及哪些更改不会影响它。

    这通常很耗时而且不太有用,因为我们找到错误的方法是在调试器下使用断点运行单个示例,而不是通过一系列示例的纯粹推导。您不妨不搜索其他示例来节省时间。最好立即发送错误报告,然后返回编辑,然后找到另一个错误来报告。

    当然,如果你能找到一个更简单的例子来代替原来的例子来报告,那就方便了。输出中的错误将更容易发现,在调试器下运行将花费更少的时间,等等。

    然而,简化并不重要。如果您无法执行此操作或没有时间尝试,请使用原始测试用例报告该错误。

  • A description of the envelope of the bug—this is not necessary for a reproducible bug.

    Often people who encounter a bug spend a lot of time investigating which changes to the input file will make the bug go away and which changes will not affect it.

    This is often time-consuming and not very useful, because the way we will find the bug is by running a single example under the debugger with breakpoints, not by pure deduction from a series of examples. You might as well save time by not searching for additional examples. It is better to send the bug report right away, go back to editing, and find another bug to report.

    Of course, if you can find a simpler example to report instead of the original one, that is a convenience. Errors in the output will be easier to spot, running under the debugger will take less time, etc.

    However, simplification is not vital; if you can’t do this or don’t have time to try, please report the bug with your original test case.

  • 核心转储文件。

    调试核心转储可能很有用,但只能在您的计算机上使用 Emacs 可执行文件来完成。因此,将核心转储文件发送给 Emacs 维护人员是没有用的。最重要的是,不要在电子邮件错误报告中包含核心文件!如此大的消息可能会非常不方便。

  • A core dump file.

    Debugging the core dump might be useful, but it can only be done on your machine, with your Emacs executable. Therefore, sending the core dump file to the Emacs maintainers won’t be useful. Above all, don’t include the core file in an email bug report! Such a large message can be extremely inconvenient.

  • Emacs 执行的系统调用跟踪。

    系统调用跟踪对于某些特殊类型的调试非常有用,但在大多数情况下,它们提供的有用信息很少。因此,奇怪的是,许多人似乎认为报告崩溃信息的方法是发送系统调用跟踪也许这是由于调试没有源代码或调试符号的程序的经验而形成的习惯。

    在大多数程序中,回溯通常比系统调用跟踪提供更多信息。即使在 Emacs 中,简单的回溯通常也能提供更多信息,但为了提供完整的信息,您应该通过显示变量值并将其打印为 Lisp 对象来补充回溯pr(见上文)。

  • A system-call trace of Emacs execution.

    System-call traces are very useful for certain special kinds of debugging, but in most cases they give little useful information. It is therefore strange that many people seem to think that the way to report information about a crash is to send a system-call trace. Perhaps this is a habit formed from experience debugging programs that don’t have source code or debugging symbols.

    In most programs, a backtrace is normally far, far more informative than a system-call trace. Even in Emacs, a simple backtrace is generally more informative, though to give full information you should supplement the backtrace by displaying variable values and printing them as Lisp objects with pr (see above).

  • 该错误的补丁。

    如果 bug 的补丁是好的,那么它是有用的。但不要忽略错误报告所需的其他信息,例如测试用例,假设补丁就足够了。我们可能会发现您的补丁存在问题,并决定以其他方式解决该问题,或者我们可能根本不理解它。如果我们无法理解您要修复的错误,或者为什么您的补丁应该有所改进,我们就不能安装它。请参阅发送 GNU Emacs 补丁,了解如何让我们轻松理解和安装您的补丁的指南。

  • A patch for the bug.

    A patch for the bug is useful if it is a good one. But don’t omit the other information that a bug report needs, such as the test case, on the assumption that a patch is sufficient. We might see problems with your patch and decide to fix the problem another way, or we might not understand it at all. And if we can’t understand what bug you are trying to fix, or why your patch should be an improvement, we mustn’t install it. See Sending Patches for GNU Emacs, for guidelines on how to make it easy for us to understand and install your patches.

  • 猜测 bug 是什么或者它依赖什么。

    这样的猜测通常是错误的。如果不首先使用调试器找到事实,即使是专家也无法正确猜测此类事情。

  • A guess about what the bug is or what it depends on.

    Such guesses are usually wrong. Even experts can’t guess right about such things without first using the debugger to find the facts.

如果您愿意调试 Emacs 并提供有关该错误的其他信息,这里有一些有用的建议:

If you are willing to debug Emacs and provide additional information about the bug, here is some useful advice:

  • 如果错误表现为错误消息,请尝试为该错误提供 Lisp 回溯。要对错误进行回溯,请 M-x toggle-debug-on-error在错误发生之前使用(也就是说,您必须发出该命令,然后使错误发生)。这会导致启动 Lisp 调试器时出错,并显示回溯。将调试器回溯的文本复制到错误报告中。 (如果加载相关的 Lisp,回溯会更详细 *.el触发错误之前的源文件,所以如果您知道如何查找和加载这些文件,请这样做。)

    要调试错误,我们建议使用 Edebug。有关使用 Edebug 包调试 Emacs Lisp 程序的信息, 请参阅Emacs Lisp 参考手册中的Edebug 。

    仅当您知道如何使错误再次发生时,才可以使用调试器。如果您无法再次发生这种情况,至少复制整个错误消息。

  • If the bug manifests itself as an error message, try providing a Lisp backtrace for the error. To make a backtrace for the error, use M-x toggle-debug-on-error before the error happens (that is to say, you must give that command and then make the bug happen). This causes the error to start the Lisp debugger, which shows you a backtrace. Copy the text of the debugger’s backtrace into the bug report. (The backtrace is more detailed if you load the relevant Lisp *.el source files before triggering the error, so do that if you know how to find and load those files.)

    To debug the error, we suggest using Edebug. See Edebug in the Emacs Lisp Reference Manual, for information on debugging Emacs Lisp programs with the Edebug package.

    This use of the debugger is possible only if you know how to make the bug happen again. If you can’t make it happen again, at least copy the whole error message.

  • 如果 Emacs 似乎陷入无限循环或很长的操作中,则输入C-g变量debug-on-quit non-nil将启动 Lisp 调试器并显示回溯。此回溯对于调试如此长的循环非常有用,因此如果您可以生成它,请将其复制到错误报告中。

    如果您无法让 Emacs 响应C-g(例如,因为 inhibit-quit已设置),那么您可以尝试从 Emacs 外部发送由(默认 SIGUSR2)指定的信号debug-on-event,使其进入调试器。

  • If Emacs appears to be stuck in an infinite loop or in a very long operation, typing C-g with the variable debug-on-quit non-nil will start the Lisp debugger and show a backtrace. This backtrace is useful for debugging such long loops, so if you can produce it, copy it into the bug report.

    If you cannot get Emacs to respond to C-g (e.g., because inhibit-quit is set), then you can try sending the signal specified by debug-on-event (default SIGUSR2) from outside Emacs to cause it to enter the debugger.

  • 来自 C 调试器(例如 GDB)的附加信息可能使某人能够在他没有的机器上发现问题。如果你不知道如何使用GDB,请阅读GDB手册——它不是很长,使用GDB很容易。您可以找到 GDB 发行版,包括在线形式的 GDB 手册,在大多数相同的地方您可以找到 Emacs 发行版。要在 GDB 下运行 Emacs,您应该切换到源代码编译 Emacs 的子目录,然后输入gdb ./emacs.对于目录来说很重要源代码是最新的,以便 GDB 能够读取.gdbinit该目录下的文件。 (您还可以通过键入 告诉 GDB 从 GDB 内部读取该文件source ./.gdbinit。)

    但是,当您收集附加信息时,您需要考虑是否希望它显示导致错误的原因。

    例如,许多人只发送 C 级回溯,但这本身并不是很有用。带有参数的简单回溯通常无法传达 GNU Emacs 内部发生的情况,因为回溯中列出的大多数参数都是指向 Lisp 对象的指针。这些指针的数值没有任何意义;重要的是它们指向的对象的内容(大多数内容本身就是指针)。

    为了提供有用的信息,您需要以 Lisp 表示法显示 Lisp 对象的值。对靠近堆栈底部的几个堆栈帧中的每个 Lisp 对象变量执行此操作。查看源代码以查看哪些变量是 Lisp 对象,因为调试器将它们视为整数。

    要以 Lisp 语法显示变量的值,请首先打印其值,然后使用用户定义的 GDB 命令pr以 Lisp 语法打印 Lisp 对象。 (如果必须使用另一个调试器,请使用 debug_print该对象作为参数来调用该函数。)该pr 命令由文件定义.gdbinit,并且仅当您正在调试正在运行的进程(而不是使用核心转储)时它才有效。

    要使 Lisp 错误停止 Emacs 并返回到 GDB,请在 处放置一个断点 Fsignal

    要对正在运行的 Lisp 函数进行回溯,请输入 GDB 命令 xbacktrace

    文件.gdbinit定义了其他几个对于检查 Lisp 对象的数据类型和内容有用的命令。他们的名字以 ' 开头X'。这些命令的工作级别低于 pr,并且不太方便,但即使在 pr不工作的情况下它们也可能工作,例如在调试核心转储时或 Emacs 出现致命信号时。

    文件中提供了更详细的建议和其他有用的调试 Emacs 的技术等/调试在 Emacs 发行版中。该文件还包括调查 Emacs 停止响应问题的说明(许多人认为 Emacs 被“挂起”,而实际上它可能处于无限循环中)。

    找到该文件等/调试在您的 Emacs 安装中,使用存储在变量 中的目录名称data-directory

  • Additional information from a C debugger such as GDB might enable someone to find a problem on a machine which he does not have available. If you don’t know how to use GDB, please read the GDB manual—it is not very long, and using GDB is easy. You can find the GDB distribution, including the GDB manual in online form, in most of the same places you can find the Emacs distribution. To run Emacs under GDB, you should switch to the src subdirectory in which Emacs was compiled, then type gdb ./emacs. It is important for the directory src to be current so that GDB will read the .gdbinit file in this directory. (You can also tell GDB to read that file from inside GDB, by typing source ./.gdbinit.)

    However, you need to think when you collect the additional information if you want it to show what causes the bug.

    For example, many people send just a C-level backtrace, but that is not very useful by itself. A simple backtrace with arguments often conveys little about what is happening inside GNU Emacs, because most of the arguments listed in the backtrace are pointers to Lisp objects. The numeric values of these pointers have no significance whatever; all that matters is the contents of the objects they point to (and most of the contents are themselves pointers).

    To provide useful information, you need to show the values of Lisp objects in Lisp notation. Do this for each variable which is a Lisp object, in several stack frames near the bottom of the stack. Look at the source to see which variables are Lisp objects, because the debugger thinks of them as integers.

    To show a variable’s value in Lisp syntax, first print its value, then use the user-defined GDB command pr to print the Lisp object in Lisp syntax. (If you must use another debugger, call the function debug_print with the object as an argument.) The pr command is defined by the file .gdbinit, and it works only if you are debugging a running process (not with a core dump).

    To make Lisp errors stop Emacs and return to GDB, put a breakpoint at Fsignal.

    For a backtrace of Lisp functions running, type the GDB command xbacktrace.

    The file .gdbinit defines several other commands that are useful for examining the data types and contents of Lisp objects. Their names begin with ‘x’. These commands work at a lower level than pr, and are less convenient, but they may work even when pr does not, such as when debugging a core dump or when Emacs has had a fatal signal.

    More detailed advice and other useful techniques for debugging Emacs are available in the file etc/DEBUG in the Emacs distribution. That file also includes instructions for investigating problems whereby Emacs stops responding (many people assume that Emacs is “hung”, whereas in fact it might be in an infinite loop).

    To find the file etc/DEBUG in your Emacs installation, use the directory name stored in the variable data-directory.


53.5 发送 GNU Emacs 补丁

53.5 Sending Patches for GNU Emacs

如果您想为 GNU Emacs 编写错误修复或改进,这非常有帮助。当您发送更改时,请遵循这些指南,以便维护人员轻松使用它们。如果您不遵循这些准则,您的信息可能仍然有用,但使用它需要额外的工作。即使在最好的情况下,维护 GNU Emacs 也是一项艰巨的工作,除非您尽力提供帮助,否则我们无法跟上。

If you would like to write bug fixes or improvements for GNU Emacs, that is very helpful. When you send your changes, please follow these guidelines to make it easy for the maintainers to use them. If you don’t follow these guidelines, your information might still be useful, but using it will take extra work. Maintaining GNU Emacs is a lot of work in the best of circumstances, and we can’t keep up unless you do your best to help.

每个补丁都必须有几条信息,然后我们才能正确评估它。它们的描述如下。

Every patch must have several pieces of information before we can properly evaluate it. They are described below.

当您拥有所有这些部分后,请使用M-x submit-emacs-patch 命令发送补丁。该命令将提示您输入补丁的主题和补丁文件。然后,它将创建并显示一个消息模式缓冲区,并将补丁文件作为附件,显示该缓冲区,并让您解释有关补丁的更多信息,并根据下面的要求添加任何其他信息。完成后,键入 C-c C-c以通过电子邮件将补丁发送给开发人员。它将发送到 GNU Bug Tracker(网址为https://debbugs.gnu.org ) 。跟踪器将为您的提交分配一个编号,就像错误报告一样。开发人员通常会回复,可能会要求您提供更多详细信息或任何其他信息,因此请务必包含有效的回复电子邮件地址。

When you have all these pieces, use the M-x submit-emacs-patch command to send the patch. The command will prompt you for the Subject of the patch and a patch file. It will then create and display a Message mode buffer with the patch file as an attachment, display the buffer, and let you explain more about the patch and add any other information as requested below. When you are done, type C-c C-c to send the patch via email to the developers. It will be sent to the GNU Bug Tracker at https://debbugs.gnu.org. The tracker will assign a number to your submission, just like it does with bug reports. The developers will usually respond, perhaps asking you for more details or any additional information, so be sure to include a valid reply email address.

以下是我们要求您在提交补丁时提供的内容:

Here’s what we ask you to provide as part of your patch submissions:

  • 解释您正在修复什么问题或补丁将带来什么改进:
    • 对于现有错误的修复,最好回复“bug-gnu-emacs' 列表,或位于https://debbugs.gnu.org的 GNU Bug Tracker 中的 bug 条目 。解释为什么您的更改修复了该错误。
    • 对于新功能,请包含该功能的描述和您的实现。
    • 对于新错误,请针对您认为已修复的问题提供适当的错误报告;请参阅错误报告清单。在安装之前,我们需要说服自己更改是正确的。即使它是正确的,如果我们没有办法重现它试图解决的问题,我们也可能很难理解它。
  • An explanation of what problem you are fixing or what improvement will the patches bring about:
    • For a fix for an existing bug, it is best to reply to the relevant discussion on the ‘bug-gnu-emacs’ list, or the bug entry in the GNU Bug Tracker at https://debbugs.gnu.org. Explain why your change fixes the bug.
    • For a new feature, include a description of the feature and your implementation.
    • For a new bug, include a proper bug report for the problem you think you have fixed; see Checklist for Bug Reports. We need to convince ourselves that the change is right before installing it. Even if it is correct, we might have trouble understanding it if we don’t have a way to reproduce the problem it tries to fix.
  • 在代码更改中包含所有适合帮助将来阅读源代码的人理解为什么需要此更改的注释。
  • Include in your code changes all the comments that are appropriate to help people reading the source in the future understand why this change was needed.
  • 不要将出于不同原因所做的更改混在一起。单独发送。

    如果您出于不同的原因进行了两项更改,那么我们可能不想同时安装它们。我们可能只想安装一个,或者在不同版本的 Emacs 中安装每一个。如果您将它们全部混杂地发送到一组差异中,我们必须做额外的工作来理清它们 - 找出更改的哪些部分服务于哪个目的。如果我们没有时间这样做,我们可能不得不推迟很长时间包含您的补丁。

    如果您在写完每个更改后立即发送它,并附上自己的解释,那么两个更改就永远不会纠缠在一起,我们可以正确考虑每个更改,而无需任何额外的工作来理清它们。

  • Don’t mix together changes made for different reasons. Send them individually.

    If you make two changes for separate reasons, then we might not want to install them both. We might want to install just one, or install each one in a different versions of Emacs. If you send them all jumbled together in a single set of diffs, we have to do extra work to disentangle them—to figure out which parts of the change serve which purpose. If we don’t have time for this, we might have to postpone inclusion of your patches for a long time.

    If you send each change as soon as you have written it, with its own explanation, then two changes never get tangled up, and we can consider each one properly without any extra work to disentangle them.

  • 更改完成后立即发送该更改。有时,人们认为他们通过积累许多变化并将其全部发送到一起来帮助我们。如上所述,这绝对是您能做的最糟糕的事情。

    由于您应该单独发送每个更改,因此您最好立即发送。如果重要的话,我们可以选择立即安装它。

  • Send each change as soon as that change is finished. Sometimes people think they are helping us by accumulating many changes to send them all together. As explained above, this is absolutely the worst thing you could do.

    Since you should send each change separately, you might as well send it right away. That gives us the option of installing it immediately if it is important.

  • 补丁本身。这可以通过以下方式之一生成:
    • 如果您使用 Emacs 存储库,请确保您的副本是最新的(例如,带有git pull)。您可以将更改提交到私有分支,并使用 来从主版本生成补丁git format-patch master。 (这是首选方法,因为它使我们应用补丁的工作变得更容易。)或者您可以不提交更改并使用git diff,如下所述。
    • 用于diff -u进行差异。如果您有 GNU diff,请 在对 C 代码进行 diff 时使用。这显示了每次更改发生的函数的名称。 diff -u -F'^[_a-zA-Z0-9$]\+ *('

      生成差异时,避免任何关于哪个是旧版本、哪个是新版本的歧义。请将旧版本作为 diff 的第一个参数,将新版本作为第二个参数。请为其中一个版本起一个名称,以表明它是旧版本还是新更改的版本。

  • The patch itself. This can be produced in one of the following ways:
    • If you are using the Emacs repository, make sure your copy is up-to-date (e.g., with git pull). You can commit your changes to a private branch and generate a patch from the master version by using git format-patch master. (This is the preferred method, as it makes our job of applying the patch easier.) Or you can leave your changes uncommitted and use git diff, as described below.
    • Use diff -u to make your diffs. If you have GNU diff, use diff -u -F'^[_a-zA-Z0-9$]\+ *(' when making diffs of C code. This shows the name of the function that each change occurs in.

      When producing the diffs, avoid any ambiguity as to which is the old version and which is the new. Please make the old version the first argument to diff, and the new version the second argument. And please give one version or the other a name that indicates whether it is the old version or your new changed one.

  • 写入您的更改的提交日志条目。这既可以节省我们编写它们的额外工作,也可以帮助解释您的更改,以便我们能够理解它们。

    提交日志的目的是解释更改的基本原理、修改后的代码解决补丁试图修复的任何问题的方式,并向人们展示在哪里可以找到更改的内容。因此,您需要具体说明更改了哪些功能以及原因。有关我们的风格和良好提交日志消息要求的详细信息,请参阅文件的“提交消息”部分 贡献在 Emacs 源代码树中。

    另请查看最近提交的提交日志条目,以了解要放入哪些类型的信息,并了解我们使用的样式。请注意,与其他一些项目不同,我们确实需要文档的提交日志,即 Texinfo 文件。请参阅更改日志,请参阅 https://www.gnu.org/prep/standards/html_node/Change-Log-Concepts.html,请参阅GNU 编码标准中的更改日志概念

  • Write the commit log entries for your changes. This is both to save us the extra work of writing them, and to help explain your changes so we can understand them.

    The purpose of the commit log is to explain the rationale of the changes, the way the modified code solves whatever problems your patch is trying to fix, and also show people where to find what was changed. So you need to be specific about what functions you changed and why. For the details about our style and requirements for good commit log messages, please see the “Commit messages” section of the file CONTRIBUTE in the Emacs source tree.

    Please also look at the commit log entries of recent commits to see what sorts of information to put in, and to learn the style that we use. Note that, unlike some other projects, we do require commit logs for documentation, i.e., Texinfo files. See Change Logs, see https://www.gnu.org/prep/standards/html_node/Change-Log-Concepts.html, See Change Log Concepts in GNU Coding Standards.

  • 当您编写修复程序时,请记住,我们无法安装会破坏其他系统的更改。请考虑如果在其他类型的系统上编译和/或使用您的更改会产生什么影响。

    有时,人们发送的修复程序可能总体上有所改进,但很难确定这一点。实施此类更改很困难,因为我们必须非常仔细地研究它们。当然,对您认为更改正确的推理进行良好的解释可以帮助说服我们。

    最安全的更改是对仅用于特定机器或特定系统的文件或文件部分进行更改。它们是安全的,因为它们不会在其他机器或系统上产生新的错误。

    请以明显可以安全安装的形式设计补丁,帮助我们跟上工作量。

  • When you write the fix, keep in mind that we can’t install a change that would break other systems. Please think about what effect your change will have if compiled and/or used on another type of system.

    Sometimes people send fixes that might be an improvement in general—but it is hard to be sure of this. It’s hard to install such changes because we have to study them very carefully. Of course, a good explanation of the reasoning by which you concluded the change was correct can help convince us.

    The safest changes are changes to the files or portions of files that are only used for a particular machine or a particular system. These are safe because they can’t create new bugs on other machines or systems.

    Please help us keep up with the workload by designing the patch in a form that is clearly safe to install.


54 为 Emacs 开发做出贡献

54 Contributing to Emacs Development

Emacs 是一个协作项目,我们鼓励任何人做出贡献。

Emacs is a collaborative project and we encourage contributions from anyone and everyone.

为 Emacs 做出贡献的方法有很多种:

There are many ways to contribute to Emacs:

如果您想致力于改进 Emacs,请联系 emacs-devel 邮件列表中的维护者。您可以询问建议的项目或提出您自己的想法。

If you would like to work on improving Emacs, please contact the maintainers at the emacs-devel mailing list. You can ask for suggested projects or suggest your own ideas.

如果您有功能请求或关于如何改进 Emacs 的建议,最好将其发送到 bug-gnu-emacs 。请尽可能清楚地解释您希望看到哪些更改,以及您认为它将如何改进 Emacs 的原因和方式。

If you have a feature request or a suggestion for how to improve Emacs, the best place to send it is to bug-gnu-emacs . Please explain as clearly as possible what change you would like to see, and why and how you think it would improve Emacs.

如果您已经编写了改进,请告诉我们。如果您还没有开始工作,那么 在开始之前联系emacs-devel会很有用;也许可以提出一些建议,使您的扩展更好地适应 Emacs 的其余部分。

If you have already written an improvement, please tell us about it. If you have not yet started work, it is useful to contact emacs-devel before you start; it might be possible to suggest ways to make your extension fit in better with the rest of Emacs.

实现功能时,请遵循Emacs编码标准;请参阅编码标准。此外,实质性贡献需要向 FSF 转让版权;请参阅版权转让

When implementing a feature, please follow the Emacs coding standards; see Coding Standards. In addition, substantial contributions require a copyright assignment to the FSF; see Copyright Assignment.

Emacs 的开发版本可以从存储库下载,该存储库由一组开发人员积极维护。有关访问详细信息, 请参阅 Emacs 项目页面 https://savannah.gnu.org/projects/emacs/ 。

The development version of Emacs can be downloaded from the repository where it is actively maintained by a group of developers. See the Emacs project page https://savannah.gnu.org/projects/emacs/ for access details.

根据当前工作版本编写补丁非常重要。如果您从旧版本开始,您的补丁可能已经过时(因此维护人员将很难应用它),或者 Emacs 中的更改可能使您的补丁变得不必要。下载存储库源代码后,您应该阅读该文件 安装.repo用于构建指令(它们在某种程度上与正常构建不同)。

It is important to write your patches based on the current working version. If you start from an older version, your patch may be outdated (so that maintainers will have a hard time applying it), or changes in Emacs may have made your patch unnecessary. After you have downloaded the repository source, you should read the file INSTALL.REPO for build instructions (they differ to some extent from a normal build).

如果您想做出更广泛的贡献,请参阅 贡献Emacs 源代码树中的文件以获取有关如何成为 Emacs 开发人员的信息。该文件作为每个已发布的 Emacs 版本的源 tarball 的一部分进行分发,也可以在Emacs 在线源存储库中在线找到。如果您克隆了 Emacs 存储库,按照https://savannah.gnu.org/projects/emacs/中的说明,您将在源 Emacs 树的顶级目录中找到此文件。

If you would like to make more extensive contributions, see the CONTRIBUTE file in the Emacs source tree for information on how to be an Emacs developer. That file is distributed as part of the source tarball of every released Emacs version, and can also be found on-line in the Emacs on-line source repository. If you cloned the Emacs repository, per the instructions in https://savannah.gnu.org/projects/emacs/, you will find this file in the top directory of the source Emacs tree.

有关 Emacs 的文档(以了解如何实现所需的更改),请参阅:

For documentation on Emacs (to understand how to implement your desired change), refer to:


54.1 编码标准

54.1 Coding Standards

贡献的代码应遵循 GNU 编码标准 https://www.gnu.org/prep/standards/。您的系统信息中也可能提供此信息。

Contributed code should follow the GNU Coding Standards https://www.gnu.org/prep/standards/. This may also be available in info on your system.

如果没有,我们需要找人修复代码才能使用它。

If it doesn’t, we’ll need to find someone to fix the code before we can use it.

Emacs 有额外的样式和编码约定:

Emacs has additional style and coding conventions:


55 如何获取 GNU Emacs 帮助

55 How To Get Help with GNU Emacs

如果您在安装、使用或更改 GNU Emacs 方面需要帮助,可以通过两种方式找到它:

If you need help installing, using or changing GNU Emacs, there are two ways to find it:

  • 向help-gnu-emacs 邮件列表发送消息 ,或在新闻组上发布您的请求gnu.emacs.help。 (此邮件列表和新闻组相互连接,因此使用哪一个并不重要。)
  • Send a message to the help-gnu-emacs mailing list, or post your request on newsgroup gnu.emacs.help. (This mailing list and newsgroup interconnect, so it does not matter which one you use.)
  • 在服务目录中查找可能为您提供付费帮助的人员。
  • Look in the service directory for someone who might help you for a fee.

附录 A GNU 通用公共许可证

Appendix A GNU GENERAL PUBLIC LICENSE

第 3 版,2007 年 6 月 29 日
版权所有 © 2007 自由软件基金会。https ://fsf.org/

任何人都可以复制和分发本文件的逐字副本
许可文件,但不允许更改。
Copyright © 2007 Free Software Foundation, Inc. https://fsf.org/

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.

前言

Preamble

GNU 通用公共许可证是针对软件和其他类型作品的免费、copyleft 许可证。

The GNU General Public License is a free, copyleft license for software and other kinds of works.

大多数软件和其他实际作品的许可证旨在剥夺您共享和更改作品的自由。相比之下,GNU 通用公共许可证旨在保证您可以自由地共享和更改程序的所有版本,以确保该程序对于所有用户来说仍然是免费软件。我们,自由软件基金会,对我们的大部分软件使用 GNU 通用公共许可证;它也适用于其作者以这种方式发布的任何其他作品。您也可以将其应用到您的程序中。

The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program—to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.

当我们谈论自由软件时,我们指的是自由,而不是价格。我们的通用公共许可证旨在确保您可以自由分发免费软件的副本(如果您愿意,可以对其进行收费),您可以收到源代码或可以在需要时获取它,您可以更改软件或者在新的免费程序中使用它的一部分,并且您知道您可以做这些事情。

When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.

为了保护您的权利,我们需要防止其他人否认您的这些权利或要求您放弃这些权利。因此,如果您分发该软件的副本或对其进行修改,您就承担一定的责任:尊重他人自由的责任。

To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.

例如,如果您分发此类程序的副本,无论是免费还是收费,您都必须向接收者传递您所获得的相同自由。您必须确保他们也收到或可以获得源代码。您必须向他们展示这些条款,以便他们了解自己的权利。

For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.

使用 GNU GPL 的开发人员通过两个步骤保护您的权利:(1) 主张软件的版权,(2) 向您提供此许可证,授予您复制、分发和/或修改该软件的合法许可。

Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.

为了保护开发者和作者,GPL 明确说明对本免费软件不提供任何保证。为了用户和作者的利益,GPL 要求修改后的版本被标记为已更改,这样他们的问题就不会被错误地归咎于先前版本的作者。

For the developers’ and authors’ protection, the GPL clearly explains that there is no warranty for this free software. For both users’ and authors’ sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.

有些设备被设计为拒绝用户安装或运行其内部软件的修改版本,尽管制造商可以这样做。这与保护用户更改软件自由的目的根本不相容。这种系统性的滥用行为发生在个人使用的产品领域,而这恰恰是最不可接受的地方。因此,我们设计了这个版本的GPL来禁止这些产品的做法。如果此类问题在其他领域大量出现,我们随时准备在未来版本的 GPL 中将此规定扩展到这些领域,以保护用户的自由。

Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users’ freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.

最后,每个程序都不断受到软件专利的威胁。各国不应允许专利限制通用计算机上软件的开发和使用,但在允许的情况下,我们希望避免应用到自由程序的专利可能使其实际上成为专有的特殊危险。为了防止这种情况发生,GPL 确保专利不能被用来使程序变得不自由。

Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.

复制、分发和修改的具体条款和条件如下。

The precise terms and conditions for copying, distribution and modification follow.

条款和条件

TERMS AND CONDITIONS

  1. 定义。

    “本许可证”是指 GNU 通用公共许可证的第 3 版。

    “版权”还指适用于其他类型作品(例如半导体掩模)的类似版权的法律。

    “程序”是指根据本许可证许可的任何受版权保护的作品。每个被许可人都被称为“您”。 “被许可方”和“接收方”可以是个人或组织。

    “修改”作品是指以需要版权许可的方式复制或改编作品的全部或部分,而不是制作精确的副本。由此产生的作品被称为早期作品的“修改版本”或“基于”早期作品的作品。

    “涵盖的作品”是指未经修改的程序或基于该程序的作品。

    “传播”作品是指在未经许可的情况下对其进行任何可能使您根据适用的版权法直接或间接承担侵权责任的行为,但在计算机上执行该作品或修改私人副本除外。传播包括复制、分发(无论是否修改)、向公众提供,以及在某些国家还包括其他活动。

    “传播”作品是指使其他方能够制作或接收副本的任何形式的传播。仅仅通过计算机网络与用户交互,而不传输副本,并不是传达。

    交互式用户界面显示“适当的法律声明”,其范围包括方便且显眼的功能,该功能 (1) 显示适当的版权声明,以及 (2) 告诉用户该作品不存在任何保证(除非在提供保证的范围内),被许可人可以根据本许可证转让作品,以及如何查看本许可证的副本。如果界面呈现用户命令或选项的列表(例如菜单),则列表中的突出项目满足此标准。

  2. Definitions.

    “This License” refers to version 3 of the GNU General Public License.

    “Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.

    “The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.

    To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.

    A “covered work” means either the unmodified Program or a work based on the Program.

    To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.

    To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.

    An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.

  3. 源代码。

    作品的“源代码”是指对其进行修改的作品的首选形式。 “目标代码”是指作品的任何非源形式。

    “标准接口”是指由公认的标准机构定义的官方标准,或者对于为特定编程语言指定的接口,是指在使用该语言的开发人员中广泛使用的接口。

    可执行作品的“系统库”包括除整个作品之外的任何内容,(a) 包含在打包主要组件的正常形式中,但不是该主要组件的一部分,并且 (b)仅用于启用该主要组件的工作,或实现标准接口,其实现以源代码形式向公众提供。在这种情况下,“主要组件”是指运行可执行工作的特定操作系统(如果有)的主要基本组件(内核、窗口系统等),或用于生成该工作的编译器,或用于运行它的目标代码解释器。

    目标代码形式的作品的“相应源代码”是指生成、安装和(对于可执行作品)运行目标代码以及修改作品所需的所有源代码,包括控制这些活动的脚本。但是,它不包括作品的系统库,或通用工具或普遍可用的免费程序,这些程序在执行这些活动时未经修改而使用,但不属于作品的一部分。例如,对应源包括与作品源文件关联的接口定义文件,以及作品专门设计需要的共享库和动态链接子程序的源代码,例如通过这些子程序之间的密切数据通信或控制流和工作的其他部分。

    对应源不需要包含用户可以从对应源的其他部分自动重新生成的任何内容。

    源代码形式的作品的对应源代码是同一作品。

  4. Source Code.

    The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.

    A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.

    The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.

    The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work’s System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.

    The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.

    The Corresponding Source for a work in source code form is that same work.

  5. 基本权限。

    根据本许可证授予的所有权利均在程序的版权期限内授予,并且在满足规定条件的情况下不可撤销。本许可证明确确认您拥有运行未经修改的程序的无限权限。仅当输出(给定其内容)构成涵盖作品时,运行涵盖作品的输出才受本许可证的保护。本许可证承认您的合理使用权或版权法规定的其他同等权利。

    只要您的许可证仍然有效,您就可以无条件地制作、运行和传播您未传播的涵盖作品。您可以将涵盖的作品转让给其他人,其唯一目的是让他们专门为您进行修改,或者为您提供运行这些作品的设施,前提是您在转让您无法控制的所有材料时遵守本许可证的条款版权。那些为您制作或运行受保护作品的人必须在您的指导和控制下专门代表您这样做,并遵守禁止他们在与您的关系之外制作您受版权保护的材料的任何副本的条款。

    仅在满足下述条件的情况下才允许在任何其他情况下进行输送。不允许再许可;第 10 节使其变得不必要。

  6. Basic Permissions.

    All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.

    You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.

    Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.

  7. 反规避法保护用户合法权益。

    根据履行 1996 年 12 月 20 日通过的 WIPO 版权条约第 11 条规定的义务的任何适用法律,或禁止或限制规避此类措施的类似法律,任何涵盖的作品均不得被视为有效技术措施的一部分。

    当您转让涵盖的作品时,您放弃任何禁止规避技术措施的法律权力,只要此类规避是通过行使本许可证下与涵盖的作品相关的权利而实现的,并且您不打算限制该作品的操作或修改。作品作为针对作品用户强制执行您或第三方禁止规避技术措施的合法权利的手段。

  8. Protecting Users’ Legal Rights From Anti-Circumvention Law.

    No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.

    When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work’s users, your or third parties’ legal rights to forbid circumvention of technological measures.

  9. 逐字传送副本。

    您可以在收到本程序源代码时通过任何媒介传送该程序源代码的逐字副本,前提是您在每个副本上显着且适当地发布适当的版权声明;完整保留所有说明本许可证和根据第 7 节添加的任何非许可条款适用于代码的声明;完整保留所有不存在任何保证的通知;并向所有接收者提供本许可证的副本以及程序。

    您可以对您传送的每个副本收取任何价格或免费,并且您可以付费提供支持或保修保护。

  10. Conveying Verbatim Copies.

    You may convey verbatim copies of the Program’s source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.

    You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.

  11. 传送修改后的源版本。

    您可以根据第 4 节的条款以源代码的形式传达基于本程序的作品,或根据本程序生成该作品的修改,前提是您还满足所有这些条件:

    1. 该作品必须带有显着的通知,说明您对其进行了修改,并给出了相关日期。
    2. 该作品必须带有显着的通知,表明它是根据本许可证以及根据第 7 节添加的任何条件发布的。此要求修改了第 4 节中的要求,以“保持所有通知完整”。
    3. 您必须根据本许可证将整个作品作为一个整体许可给拥有副本的任何人。因此,本许可连同任何适用的第 7 条附加条款将适用于整个作品及其所有部分,无论它们如何打包。本许可证不授予以任何其他方式许可该作品的许可,但如果您单独收到该许可,则不会使该许可无效。
    4. 如果作品具有交互式用户界面,则每个界面都必须显示适当的法律声明;但是,如果该程序具有不显示适当法律声明的交互界面,则您的工作不需要让它们这样做。

    涵盖的作品与其他单独和独立的作品的汇编,这些作品本质上不是涵盖的作品的扩展,并且不会与其组合以形成更大的程序,在存储或分发的卷中或卷上如果汇编及其产生的版权不用于限制汇编用户超出单个作品允许的访问或合法权利,则称为“集合”。将涵盖的作品包含在集合中并不导致本许可证适用于集合的其他部分。

  12. Conveying Modified Source Versions.

    You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:

    1. The work must carry prominent notices stating that you modified it, and giving a relevant date.
    2. The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
    3. You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
    4. If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.

    A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation’s users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.

  13. 传达非来源形式。

    您可以根据第 4 节和第 5 节的条款以目标代码形式传达涵盖的作品,前提是您还根据本许可的条款通过以下方式之一传达机器可读的对应源代码:

    1. 在物理产品(包括物理分发介质)中传送或体现在物理产品中的目标代码,并附有固定在通常用于软件交换的耐用物理介质上的相应源。
    2. 在实体产品(包括物流介质)中传达或体现的目标代码,并附有书面报价,有效期至少三年,并且只要您为该产品型号提供备件或客户支持,该报价就有效,向拥有目标代码的任何人提供 (1) 本许可证涵盖的产品中所有软件的相应源代码的副本,位于通常用于软件交换的耐用物理介质上,价格不超过您实际执行此源传送的合理费用,或 (2) 免费从网络服务器复制相应源。
    3. 传达目标代码的单独副本以及书面报价的副本,以提供相应的源代码。这种替代方案仅偶尔且非商业性地允许,并且仅当您根据第 6b 款收到带有此类要约的目标代码时。
    4. 通过提供从指定地点(免费或收费)的访问来传送目标代码,并通过同一地点以相同的方式提供对相应源的等效访问,无需额外付费。您不需要要求接收者将相应源代码与目标代码一起复制。如果复制目标代码的位置是网络服务器,则对应的源可能位于支持等效复制设施的不同服务器(由您或第三方操作)上,前提是您在目标代码旁边保留明确的指示,说明在哪里复制找到相应的来源。无论哪个服务器托管相应源,您都有义务确保它在满足这些要求所需的时间内可用。
    5. 使用点对点传输来传达目标代码,前提是您告知其他同行,在哪里根据第 6d 款免费向公众提供作品的目标代码和相应源代码。

    目标代码的可分离部分(其源代码作为系统库从相应源中排除)不需要包含在传送目标代码工作中。

    “用户产品”是指 (1) “消费品”,即通常用于个人、家庭或家居目的的任何有形个人财产,或 (2) 为纳入住宅而设计或出售的任何物品。在确定产品是否为消费品时,应解决有疑问的情况以支持承保。对于特定用户收到的特定产品,“正常使用”是指该类产品的典型或常见使用,无论特定用户的状态或特定用户实际使用、期望或的方式如何。预计会使用该产品。产品是消费品,无论该产品是否具有实质性商业、工业或非消费者用途,除非这些用途代表该产品的唯一重要使用方式。

    用户产品的“安装信息”是指从其相应源的修改版本安装和执行该用户产品中所涵盖作品的修改版本所需的任何方法、过程、授权密钥或其他信息。该信息必须足以确保修改后的目标代码的继续运行在任何情况下都不会仅仅因为进行了修改而被阻止或干扰。

    如果您根据本节在用户产品中、或与用户产品一起、或专门用于用户产品中传送目标代码作品,并且该传送作为交易的一部分发生,在该交易中,用户产品的占有和使用权转让给永久或固定期限的接收者(无论交易的特征如何),根据本节传送的对应源必须附有安装信息。但如果您或任何第三方均不保留在用户产品上安装修改后的目标代码的能力(例如,作品已安装在 ROM 中),则此要求不适用。

    提供安装信息的要求不包括继续为已由接收者修改或安装的作品或已修改或安装的用户产品提供支持服务、保修或更新的要求。当修改本身对网络的运行产生重大不利影响或违反网络通信的规则和协议时,对网络的访问可能会被拒绝。

    根据本节传达的相应源代码和提供的安装信息必须采用公开记录的格式(并且以源代码形式向公众提供实现),并且必须不需要特殊的密码或密钥来解包、读取或复制。

  14. Conveying Non-Source Forms.

    You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:

    1. Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
    2. Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
    3. Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
    4. Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
    5. Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.

    A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.

    A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.

    “Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.

    If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).

    The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.

    Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.

  15. 附加条款。

    “附加许可”是通过排除其中一项或多项条件来补充本许可条款的条款。适用于整个程序的附加权限应被视为包含在本许可证中,只要它们根据适用法律有效。如果附加权限仅适用于本程序的一部分,则该部分可以在这些权限下单独使用,但整个程序仍受本许可证管辖,而不考虑附加权限。

    当您传送所涵盖作品的副本时,您可以选择删除该副本或其任何部分的任何附加权限。 (在某些情况下,当您修改作品时,可能会写入附加权限,要求自行删除。)您可以对由您添加到涵盖作品中的材料设置附加权限,您已经或可以为其授予适当的版权许可。

    尽管本许可证有任何其他规定,对于您添加到涵盖作品中的材料,您可以(如果得到该材料的版权所有者授权)用以下条款补充本许可证的条款:

    1. 与本许可第 15 条和第 16 条的条款不同的免责保证或限制责任;或者
    2. 要求在该材料或包含该材料的作品所显示的适当法律声明中保留指定的合理法律声明或作者归属;或者
    3. 禁止歪曲该材料的来源,或要求以合理的方式将此类材料的修改版本标记为与原始版本不同;或者
    4. 限制出于宣传目的使用材料的许可方或作者姓名;或者
    5. 拒绝根据商标法授予使用某些商号、商标或服务标志的权利;或者
    6. 要求任何传送该材料(或其修改版本)的人对该材料的许可方和作者进行赔偿,并对接收者承担合同假设,以免这些合同假设直接强加给这些许可方和作者的任何责任。

    所有其他非许可性附加条款均被视为第 10 节含义内的“进一步限制”。如果您收到的程序或其任何部分包含声明其受本许可证管辖的通知以及以下条款:是进一步的限制,您可以删除该术语。如果许可文档包含进一步的限制,但允许根据本许可进行再许可或转让,则您可以添加到受该许可文档的条款管辖的涵盖工作材料中,前提是进一步的限制在此类再许可或转让后不再有效。

    如果您根据本节向涵盖的作品添加条款,则必须在相关源文件中放置适用于这些文件的附加条款的声明,或指示在哪里可以找到适用条款的通知。

    附加条款,无论是许可的还是非许可的,都可以以单独书面许可的形式说明,或作为例外情况说明;上述要求无论哪种方式均适用。

  16. Additional Terms.

    “Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.

    When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.

    Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:

    1. Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
    2. Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
    3. Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
    4. Limiting the use for publicity purposes of names of licensors or authors of the material; or
    5. Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
    6. Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.

    All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.

    If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.

    Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.

  17. 终止。

    除非本许可证明确规定,否则您不得传播或修改涵盖的作品。任何以其他方式传播或修改本许可的尝试均无效,并将自动终止您在本许可下的权利(包括根据第 11 条第三段授予的任何专利许可)。

    但是,如果您停止一切违反本许可的行为,则特定版权所有者向您授予的许可将被恢复 (a) 临时恢复,除非版权所有者明确并最终终止您的许可,以及 (b) 如果版权所有者未能终止您的许可,则永久恢复在停止后 60 天内通过某种合理方式通知您违规行为。

    此外,如果版权所有者通过某种合理方式通知您违规行为,则您从特定版权所有者获得的许可证将被永久恢复,这是您第一次收到该版权所有者违反本许可证(针对任何作品)的通知,并且您在收到通知后 30 天内纠正了违规行为。

    终止您在本节下的权利不会终止已收到您根据本许可提供的副本或权利的各方的许可。如果您的权利已被终止且未永久恢复,则您没有资格根据第 10 条获得相同材料的新许可。

  18. Termination.

    You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).

    However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.

    Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.

    Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.

  19. 拥有副本无需接受。

    您无需接受本许可证即可接收或运行本程序的副本。仅由于使用点对点传输接收副本而发生的所涵盖作品的辅助传播同样不需要接受。但是,除了本许可证之外,没有任何其他内容授予您传播或修改任何涵盖的作品的权限。如果您不接受本许可,这些行为就会侵犯版权。因此,通过修改或传播涵盖的作品,即表示您接受本许可证。

  20. Acceptance Not Required for Having Copies.

    You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.

  21. 下游接收者的自动许可。

    每次您传送涵盖的作品时,接收者都会自动从原始许可人处收到许可证,以根据本许可证运行、修改和传播该作品。您不负责强制第三方遵守本许可证。

    “实体交易”是指转让一个组织的控制权或一个组织的几乎所有资产、或细分一个组织、或合并组织的交易。如果涵盖的作品的传播是由实体交易产生的,则收到该作品副本的该交易的每一方也将收到该方的前任根据前一段已经或可能给予的任何作品许可,以及占有权感兴趣的前任作品的相应来源,如果前任拥有或可以通过合理的努力获得它。

    您不得对本许可证授予或确认的权利的行使施加任何进一步的限制。例如,您不得因行使本许可证授予的权利而征收许可费、特许权使用费或其他费用,并且您不得提起诉讼(包括诉讼中的交叉索赔或反索赔),指控任何专利主张受到侵犯。通过制作、使用、销售、许诺销售或导入本程序或其任何部分。

  22. Automatic Licensing of Downstream Recipients.

    Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.

    An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party’s predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.

    You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.

  23. 专利。

    “贡献者”是指根据本许可授权使用程序或程序所基于的作品的版权所有者。由此获得许可的作品称为贡献者的“贡献者版本”。

    贡献者的“基本专利声明”是贡献者拥有或控制的所有专利声明,无论是已经获得的还是以后获得的,在本许可证允许的情况下,制作、使用或销售其贡献者版本都会受到某种方式的侵犯,但是不包括仅因进一步修改贡献者版本而受到侵权的声明。就本定义而言,“控制”包括以符合本许可要求的方式授予专利分许可的权利。

    每个贡献者根据贡献者的基本专利声明授予您非排他性、全球性、免版税的专利许可,以制作、使用、销售、要约销售、导入和以其他方式运行、修改和传播其贡献者版本的内容。

    在以下三段中,“专利许可”是指不执行专利的任何明确协议或承诺,无论其名称如何(例如明确许可实施专利或不起诉专利侵权的契约)。向一方“授予”此类专利许可意味着做出不针对该方执行专利的协议或承诺。

    如果您故意依赖专利许可来传达涵盖的作品,并且任何人都无法根据本许可条款通过公开网络服务器或其他易于访问的方式免费复制该作品的相应源代码意味着,那么您必须 (1) 使相应源如此可用,或 (2) 安排剥夺您自己从该特定作品的专利许可中获得的利益,或 (3) 以与根据本许可证的要求,将专利许可证扩展到下游接收者。 “故意依赖”是指您实际知道,如果没有专利许可,您在某个国家/地区传送所涵盖的作品,或者您的接收者在某个国家/地区对所涵盖的作品的使用,将侵犯您在该国家/地区的一项或多项可识别的专利。有理由相信是有效的。

    如果根据单一交易或安排或与之相关,您转让或通过促成转让来传播所涵盖的作品,并向某些接收所涵盖作品的各方授予专利许可,授权他们使用、传播、修改或传达所涵盖作品的特定副本,则您授予的专利许可将自动扩展到所涵盖作品和基于该作品的所有接收者。

    如果专利许可不包括其覆盖范围、禁止行使或以不行使根据本许可特别授予的一项或多项权利为条件,则该专利许可具有“歧视性”。如果您是与从事软件分发业务的第三方达成协议的一方,您不得转让涵盖的作品,根据该协议,您根据您转让作品的活动范围向第三方付款,并且根据该协议,第三方向将从您处接收所涵盖作品的任何一方授予歧视性专利许可 (a) 与您所传送的所涵盖作品的副本(或由这些副本制作的副本)有关,或( b) 主要用于包含所涵盖作品的特定产品或汇编并与其相关,除非您在 2007 年 3 月 28 日之前达成该安排或授予专利许可。

    本许可中的任何内容均不得解释为排除或限制您根据适用专利法可能获得的任何默示许可或其他侵权辩护。

  24. Patents.

    A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor’s “contributor version”.

    A contributor’s “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.

    Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor’s essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.

    In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.

    If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient’s use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.

    If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.

    A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.

    Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.

  25. 不放弃他人的自由。

    如果向您强加的条件(无论是通过法院命令、协议还是其他方式)与本许可证的条件相抵触,它们并不能免除您遵守本许可证的条件。如果您无法转让涵盖的作品以同时满足您在本许可下的义务和任何其他相关义务,那么您可能根本无法转让它。例如,如果您同意条款规定您有义务向您向其传送程序的对象收取进一步传送使用费,那么您满足这些条款和本许可的唯一方法就是完全避免传送程序。

  26. No Surrender of Others’ Freedom.

    If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.

  27. 与 GNU Affero 通用公共许可证一起使用。

    尽管本许可证有任何其他规定,您仍有权将任何涵盖的作品与根据 GNU Affero 通用公共许可证第 3 版许可的作品链接或组合成单个组合作品,并传达最终的作品。本许可证的条款将继续适用于所涵盖的作品部分,但 GNU Affero 通用公共许可证第 13 节中有关通过网络交互的特殊要求将适用于此类组合。

  28. Use with the GNU Affero General Public License.

    Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.

  29. 本许可证的修订版本。

    自由软件基金会可能会不时发布 GNU 通用公共许可证的修订版和/或新版本。此类新版本在精神上与当前版本相似,但在解决新问题或疑虑方面可能在细节上有所不同。

    每一个版本都有不同的版本号。如果程序指定 GNU 通用公共许可证“或任何更高版本”的某个编号版本适用于它,您可以选择遵循自由软件发布的该编号版本或任何更高版本的条款和条件基础。如果本程序未指定 GNU 通用公共许可证的版本号,您可以选择自由软件基金会曾经发布的任何版本。

    如果本程序指定代理可以决定可以使用哪些 GNU 通用公共许可证的未来版本,则该代理接受版本的公开声明将永久授权您为本程序选择该版本。

    更高版本的许可证可能会为您提供额外或不同的权限。但是,任何作者或版权所有者不会因您选择遵循更高版本而承担任何额外义务。

  30. Revised Versions of this License.

    The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.

    Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.

    If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy’s public statement of acceptance of a version permanently authorizes you to choose that version for the Program.

    Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.

  31. 免责声明。

    在适用法律允许的范围内,对本程序不提供任何保证。除非另有书面说明,版权所有者和/或其他方“按原样”提供程序,不提供任何明示或默示的保证,包括但不限于适销性和特定用途适用性的默示保证。本计划的质量和性能的全部风险由您承担。如果该程序被证明有缺陷,您将承担所有必要的维修、修理或纠正的费用。

  32. Disclaimer of Warranty.

    THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

  33. 责任限制。

    在任何情况下,除非适用法律要求或书面同意,否则任何版权持有者或修改和/或传送上述允许的程序的任何其他方均不对您的损害承担责任,包括任何一般、特殊、附带或后果性损害因使用或无法使用本程序而造成的损害(包括但不限于数据丢失或数据不准确或由您或第三方承受的损失或本程序无法与任何其他程序一起运行),即使该持有人或其他方已被告知发生此类损害的可能性。

  34. Limitation of Liability.

    IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

  35. 第 15 条和第 16 条的解释。

    如果上述免责声明和责任限制不能根据其条款在当地具有法律效力,则复审法院应适用最接近绝对放弃与本计划有关的所有民事责任的当地法律,除非有保证或假设责任书附有该计划的副本,但需付费。

  36. Interpretation of Sections 15 and 16.

    If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.

条款和条件结束

END OF TERMS AND CONDITIONS

如何将这些条款应用于您的新计划

How to Apply These Terms to Your New Programs

如果您开发一个新程序,并且希望它对公众有最大的用途,那么实现这一目标的最佳方法是使其成为免费软件,每个人都可以根据这些条款重新分发和更改。

If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.

为此,请将以下通知附加到程序中。最安全的做法是将它们附加到每个源文件的开头,以最有效地声明保修的排除;每个文件至少应该有“版权”行和一个指向完整通知位置的指针。

To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.

一行给出程序的名称和其功能的简要说明。
版权 (C)作者姓名 

该程序是免费软件:您可以重新分发它和/或修改
它遵循 GNU 通用公共许可证的条款,由
自由软件基金会,许可证的版本 3,或(位于
您的选择)任何更高版本。

发布此程序是希望它有用,但是
无任何保证;甚至没有默示保证
适销性或特定用途的适用性。参见 GNU
通用公共许可证了解更多详细信息。

您应该已收到 GNU 通用公共许可证的副本
与这个程序一起。如果没有,请参阅https://www.gnu.org/licenses/
one line to give the program's name and a brief idea of what it does.
Copyright (C) year name of author

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see https://www.gnu.org/licenses/.

另请添加有关如何通过电子邮件和纸质邮件与您联系的信息。

Also add information on how to contact you by electronic and paper mail.

如果程序进行终端交互,请使其在以交互模式启动时输出如下简短通知:

If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:

程序版权 (C)作者姓名年份 
本程序不附带任何保证;有关详细信息,请输入 '显示w'。
这是免费软件,欢迎您重新分发它
在某些条件下;类型 '显示c' 了解详情。
program Copyright (C) year name of author
This program comes with ABSOLUTELY NO WARRANTY; for details type ‘show w’.
This is free software, and you are welcome to redistribute it
under certain conditions; type ‘show c’ for details.

假设的命令'显示w' 和 '显示c' 应显示通用公共许可证的相应部分。当然,您的程序的命令可能会有所不同;对于 GUI 界面,您可以使用“关于框”。

The hypothetical commands ‘show w’ and ‘show c’ should show the appropriate parts of the General Public License. Of course, your program’s commands might be different; for a GUI interface, you would use an “about box”.

如有必要,您还应该让您的雇主(如果您是程序员)或学校(如果有)签署该程序的“版权免责声明”。有关此内容以及如何应用和遵循 GNU GPL 的更多信息,请参阅 https://www.gnu.org/licenses/

You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see https://www.gnu.org/licenses/.

GNU 通用公共许可证不允许将您的程序合并到专有程序中。如果您的程序是子例程库,您可能会认为允许将专有应用程序与该库链接更有用。如果您想要这样做,请使用 GNU Lesser General Public License 而不是本许可证。但首先,请阅读https://www.gnu.org/licenses/why-not-lgpl.html

The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read https://www.gnu.org/licenses/why-not-lgpl.html.


附录 B GNU 自由文档许可证

Appendix B GNU Free Documentation License

版本 1.3,2008 年 11 月 3 日
版权所有 © 2000、2001、2002、2007、2008 自由软件基金会
https://fsf.org/

任何人都可以复制和分发逐字副本
该许可文件的内容,但不允许更改。
Copyright © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
https://fsf.org/

Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
  1. 前言

    本许可证的目的是使手册、教科书或其他功能性和有用的文档在自由意义上免费:确保每个人都有复制和重新分发它的有效自由,无论是否修改它,无论是商业还是非商业。其次,该许可证为作者和出版商保留了一种获得其作品荣誉的方式,同时不被认为对他人所做的修改负责。

    该许可证是一种“copyleft”,这意味着该文档的衍生作品本身必须在相同意义上是免费的。它补充了 GNU 通用公共许可证,这是专为自由软件设计的 Copyleft 许可证。

    我们设计此许可证是为了将其用作自由软件的手册,因为自由软件需要自由文档:自由程序应该附带提供与软件相同自由的手册。但本许可不限于软件手册;它可用于任何文本作品,无论主题如何或是否以印刷书籍形式出版。我们主要推荐此许可证用于以指导或参考为目的的作品。

  2. PREAMBLE

    The purpose of this License is to make a manual, textbook, or other functional and useful document free in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others.

    This License is a kind of “copyleft”, which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software.

    We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference.

  3. 适用性和定义

    本许可证适用于任何媒介中的任何手册或其他作品,其中包含版权所有者发布的声明,表明可以根据本许可证的条款进行分发。此类通知授予在全球范围内、无期限、免版税的许可,以便在此处规定的条件下使用该作品。下面的“文档”指任何此类手册或作品。任何公众成员都是被许可人,并被称为“您”。如果您按照版权法要求许可的方式复制、修改或分发该作品,则您接受该许可。

    本文档的“修改版本”是指包含本文档或其一部分的任何作品,无论是逐字复制还是经过修改和/或翻译成另一种语言。

    “次要部分”是文档的指定附录或前言部分,专门处理文档的出版商或作者与文档的整体主题(或相关事项)的关系,并且不包含任何可能直接涉及的内容在整个主题内。 (因此,如果该文档的一部分是数学教科书,则第二部分可能不会解释任何数学。)这种关系可能是与主题或相关事项的历史联系,或者是法律、商业、哲学、伦理的历史联系。或关于他们的政治立场。

    “不变部分”是某些次要部分,其标题被指定为不变部分的标题,在声明根据本许可证发布文档的通知中。如果一个部分不符合上述次要的定义,则不允许将其指定为不变的。该文档可以包含零个不变部分。如果文档没有标识任何不变部分,那么就没有不变部分。

    “封面文本”是在通知中列出的某些简短文本段落,如封面文本或封底文本,说明文档是根据本许可证发布的。封面文本最多可包含 5 个单词,封底文本最多可包含 25 个单词。

    文件的“透明”副本是指机器可读的副本,以公众可获得的规范格式表示,适合使用通用文本编辑器或(对于由像素组成的图像)​​通用绘画直接修改文档程序或(对于绘图)一些广泛使用的绘图编辑器,并且适合输入到文本格式化程序或自动转换为适合输入到文本格式化程序的各种格式。以其他透明文件格式制作的副本,其标记或无标记已被安排为阻止或阻止读者进行后续修改,该副本不是透明的。如果图像格式用于任何大量文本,则该图像格式不是透明的。非“透明”的副本称为“不透明”。

    透明副本的合适格式的示例包括无标记的纯 ASCII、Texinfo 输入格式、LaTeX 输入格式、使用公开可用的 DTD 的 SGML 或 XML,以及为人工修改而设计的符合标准的简单 HTML、PostScript 或 PDF。透明图像格式的示例包括 PNG、XCF 和 JPG。不透明格式包括只能由专有文字处理器读取和编辑的专有格式、DTD 和/或处理工具通常不可用的 SGML 或 XML,以及由某些文字处理器生成的机器生成的 HTML、PostScript 或 PDF。仅用于输出目的。

    对于印刷书籍,“扉页”是指扉页本身,以及清晰地保存本许可证要求在扉页中显示的材料所需的后续页面。对于没有任何标题页的格式的作品,“标题页”是指靠近作品标题最突出的外观、位于文本正文开头之前的文本。

    “发布者”是指向公众分发本文档副本的任何个人或实体。

    “标题为 XYZ”的部分是指文档的命名子单元,其标题要么恰好是 XYZ,要么在将 XYZ 翻译成另一种语言的文本后面的括号中包含 XYZ。 (这里 XYZ 代表下面提到的特定部分名称,例如“致谢”、“奉献”、“认可”或“历史”。)在修改文档时“保留该部分的标题”意味着它根据此定义,保留“标题为 XYZ”的部分。

    该文档可能在通知旁边包含保证免责声明,声明本许可证适用于该文档。这些保证免责声明被视为通过引用包含在本许可证中,但仅限于免责保证:这些保证免责声明可能具有的任何其他含义都是无效的,并且对本许可证的含义没有影响。

  4. APPLICABILITY AND DEFINITIONS

    This License applies to any manual or other work, in any medium, that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. Such a notice grants a world-wide, royalty-free license, unlimited in duration, to use that work under the conditions stated herein. The “Document”, below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as “you”. You accept the license if you copy, modify or distribute the work in a way requiring permission under copyright law.

    A “Modified Version” of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language.

    A “Secondary Section” is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document’s overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (Thus, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them.

    The “Invariant Sections” are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License. If a section does not fit the above definition of Secondary then it is not allowed to be designated as Invariant. The Document may contain zero Invariant Sections. If the Document does not identify any Invariant Sections then there are none.

    The “Cover Texts” are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may be at most 25 words.

    A “Transparent” copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup, or absence of markup, has been arranged to thwart or discourage subsequent modification by readers is not Transparent. An image format is not Transparent if used for any substantial amount of text. A copy that is not “Transparent” is called “Opaque”.

    Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML, PostScript or PDF designed for human modification. Examples of transparent image formats include PNG, XCF and JPG. Opaque formats include proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML, PostScript or PDF produced by some word processors for output purposes only.

    The “Title Page” means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, “Title Page” means the text near the most prominent appearance of the work’s title, preceding the beginning of the body of the text.

    The “publisher” means any person or entity that distributes copies of the Document to the public.

    A section “Entitled XYZ” means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language. (Here XYZ stands for a specific section name mentioned below, such as “Acknowledgements”, “Dedications”, “Endorsements”, or “History”.) To “Preserve the Title” of such a section when you modify the Document means that it remains a section “Entitled XYZ” according to this definition.

    The Document may include Warranty Disclaimers next to the notice which states that this License applies to the Document. These Warranty Disclaimers are considered to be included by reference in this License, but only as regards disclaiming warranties: any other implication that these Warranty Disclaimers may have is void and has no effect on the meaning of this License.

  5. 逐字复制

    您可以在任何商业或非商业媒介上复制和分发本文档,前提是本许可证、版权声明以及说明本许可证适用于本文档的许可证声明均复制到所有副本中,并且您不添加任何其他条件本许可证的内容。您不得使用技术措施阻止或控制您制作或分发的副本的阅读或进一步复制。但是,您可以接受补偿以换取副本。如果您分发足够多的副本,您还必须遵守第 3 节中的条件。

    您还可以在上述相同条件下出借副本,并且可以公开展示副本。

  6. VERBATIM COPYING

    You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3.

    You may also lend copies, under the same conditions stated above, and you may publicly display copies.

  7. 复制数量

    如果您发布文档的印刷副本(或通常有印刷封面的介质中的副本),数量超过 100,并且文档的许可通知需要封面文本,则您必须将副本附在封面上,其中清晰易读地载有所有这些内容封面文本:封面文本在封面上,封底文本在封底上。两个封面还必须清楚易读地表明您是这些副本的出版商。封面必须呈现完整的标题,标题的所有文字都同样突出和可见。您还可以在封面上添加其他材料。仅限于封面更改的复制,只要保留文档标题并满足这些条件,在其他方面就可以被视为逐字复制。

    如果任一封面所需的文本太大而无法清晰显示,则应将列出的第一个文本(尽可能多地合理放置)放在实际封面上,并将其余内容继续放在相邻的页面上。

    如果您发布或分发的文档的不透明副本数量超过 100,则必须在每个不透明副本中附上机器可读的透明副本,或者在每个不透明副本中注明一个计算机网络位置,一般网络可从该位置使用公众可以使用公共标准网络协议下载该文档的完整透明副本,无需添加材料。如果您使用后一个选项,当您开始大量分发不透明副本时,您必须采取相当谨慎的步骤,以确保此透明副本将在指定位置保持可访问状态,直到您上次分发不透明副本后至少一年。将该版本的不透明副本(直接或通过您的代理商或零售商)向公众公开。

    我们要求(但不是要求)您在重新分发大量副本之前与文档的作者联系,以便他们有机会为您提供文档的更新版本。

  8. COPYING IN QUANTITY

    If you publish printed copies (or copies in media that commonly have printed covers) of the Document, numbering more than 100, and the Document’s license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects.

    If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages.

    If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a computer-network location from which the general network-using public has access to download using public-standard network protocols a complete Transparent copy of the Document, free of added material. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public.

    It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document.

  9. 修改

    您可以根据上述第 2 节和第 3 节的条件复制和分发本文档的修改版本,前提是您完全按照本许可证发布修改版本,并且修改版本填补了文档的角色,从而许可分发和修改修改后的版本交给拥有该副本的任何人。此外,您必须在修改版本中执行以下操作:

    1. 在扉页(以及封面,如果有)中使用与文档以及以前版本(如果有的话,应该在文档的历史记录部分中列出)不同的标题。如果该版本的原始发行商允许,您可以使用与先前版本相同的标题。
    2. 在扉页上列出作为作者、负责修改版本中修改的作者的一个或多个个人或实体,以及文档的至少五位主要作者(如果文档的主要作者少于五),除非他们免除您的此要求。
    3. 在扉页上注明修改版本的出版商名称,即出版商。
    4. 保留文档的所有版权声明。
    5. 在其他版权声明旁边添加适合您的修改的版权声明。
    6. 在版权声明之后立即包含一份许可声明,允许公众根据本许可证的条款使用修改版本,其形式如下面的附录所示。
    7. 在该许可通知中保留文档许可通知中给出的不变部分和所需封面文本的完整列表。
    8. 包含本许可证的未更改副本。
    9. 保留标题为“历史”的部分,保留其标题,并向其中添加一个项目,至少说明扉页上给出的修改版本的标题、年份、新作者和出版商。如果文档中没有标题为“历史”的部分,请创建一个说明标题页上给出的文档标题、年份、作者和出版商,然后添加一个描述上一句中所述的修改版本的项目。
    10. 保留文档中给出的网络位置(如果有),以便公众访问文档的透明副本,同样保留文档中给出的其所基于的先前版本的网络位置。这些可以放在“历史”部分。您可以省略至少在文档本身之前四年发布的作品的网络位置,或者如果它所引用的版本的原始出版商给予许可。
    11. 对于任何标题为“致谢”或“奉献”的部分,保留该部分的标题,并在该部分中保留其中给出的每个贡献者致谢和/或奉献的所有实质内容和语气。
    12. 保留文档的所有不变部分,其文本和标题不变。章节编号或同等内容不被视为章节标题的一部分。
    13. 删除任何标题为“认可”的部分。修改版本中可能不包含此类部分。
    14. 请勿将任何现有部分的标题重新命名为“认可”或与任何不变部分的标题发生冲突。
    15. 保留任何保修免责声明。

    如果修改版本包含符合次要部分资格的新的前言部分或附录,并且不包含从文档复制的材料,则您可以选择将这些部分中的部分或全部指定为不变。为此,请将其标题添加到修改版本的许可声明中的不变部分列表中。这些标题必须与任何其他部分标题不同。

    您可以添加标题为“认可”的部分,前提是它只包含各方对您的修改版本的认可,例如同行评审的声明或文本已被组织批准为标准的权威定义。

    您可以将最多 5 个单词的段落作为封面文本,将最多 25 个单词的段落作为封底文本添加到修改版本中封面文本列表的末尾。任何一个实体(或通过其安排)只能添加一段封面文本和一段封底文本。如果文档已包含同一封面的封面文本,且该封面文本由您之前添加或由您代表的同一实体做出安排,则您不得添加其他内容;但您可以在获得添加旧版本的前一发布者的明确许可后更换旧版本。

    文档的作者和出版商未根据本许可证授予使用其姓名进行任何修改版本的宣传或主张或暗示认可的许可。

  10. MODIFICATIONS

    You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version:

    1. Use in the Title Page (and on the covers, if any) a title distinct from that of the Document, and from those of previous versions (which should, if there were any, be listed in the History section of the Document). You may use the same title as a previous version if the original publisher of that version gives permission.
    2. List on the Title Page, as authors, one or more persons or entities responsible for authorship of the modifications in the Modified Version, together with at least five of the principal authors of the Document (all of its principal authors, if it has fewer than five), unless they release you from this requirement.
    3. State on the Title page the name of the publisher of the Modified Version, as the publisher.
    4. Preserve all the copyright notices of the Document.
    5. Add an appropriate copyright notice for your modifications adjacent to the other copyright notices.
    6. Include, immediately after the copyright notices, a license notice giving the public permission to use the Modified Version under the terms of this License, in the form shown in the Addendum below.
    7. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document’s license notice.
    8. Include an unaltered copy of this License.
    9. Preserve the section Entitled “History”, Preserve its Title, and add to it an item stating at least the title, year, new authors, and publisher of the Modified Version as given on the Title Page. If there is no section Entitled “History” in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing the Modified Version as stated in the previous sentence.
    10. Preserve the network location, if any, given in the Document for public access to a Transparent copy of the Document, and likewise the network locations given in the Document for previous versions it was based on. These may be placed in the “History” section. You may omit a network location for a work that was published at least four years before the Document itself, or if the original publisher of the version it refers to gives permission.
    11. For any section Entitled “Acknowledgements” or “Dedications”, Preserve the Title of the section, and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein.
    12. Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles. Section numbers or the equivalent are not considered part of the section titles.
    13. Delete any section Entitled “Endorsements”. Such a section may not be included in the Modified Version.
    14. Do not retitle any existing section to be Entitled “Endorsements” or to conflict in title with any Invariant Section.
    15. Preserve any Warranty Disclaimers.

    If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version’s license notice. These titles must be distinct from any other section titles.

    You may add a section Entitled “Endorsements”, provided it contains nothing but endorsements of your Modified Version by various parties—for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard.

    You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one.

    The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version.

  11. 合并文件

    您可以根据上述第 4 节中针对修改版本定义的条款,将本文档与根据本许可证发布的其他文档合并,前提是您在组合中包含所有未经修改的原始文档的所有不变部分,并将它们全部列出作为您的组合作品的许可声明中的不变部分,并且您保留其所有保证免责声明。

    组合作品只需包含本许可证的一份副本,多个相同的不变部分可以用一份副本替换。如果存在多个具有相同名称但内容不同的不变部分,请通过在其末尾的括号中添加该部分的原始作者或出版商的名称(如果已知),使每个此类部分的标题唯一,否则为唯一的号码。对组合作品的许可声明中不变章节列表中的章节标题进行相同的调整。

    合并时,必须将各原始文件中任何标题为“历史”的章节合并起来,形成一个标题为“历史”的章节;同样,合并任何标题为“致谢”的部分和任何标题为“奉献”的部分。您必须删除所有标题为“认可”的部分。

  12. COMBINING DOCUMENTS

    You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice, and that you preserve all their Warranty Disclaimers.

    The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work.

    In the combination, you must combine any sections Entitled “History” in the various original documents, forming one section Entitled “History”; likewise combine any sections Entitled “Acknowledgements”, and any sections Entitled “Dedications”. You must delete all sections Entitled “Endorsements.”

  13. 文件收集

    您可以制作一个包含本文档和根据本许可证发布的其他文档的集合,并用集合中包含的单个副本替换各个文档中本许可证的各个副本,前提是您遵循本许可证的规则在所有其他方面逐字复制每份文件。

    您可以从此类集合中提取单个文档,并根据本许可证将其单独分发,前提是您将本许可证的副本插入到提取的文档中,并在有关逐字复制该文档的所有其他方面遵循本许可证。

  14. COLLECTIONS OF DOCUMENTS

    You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects.

    You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document.

  15. 与独立作品的聚合

    如果由汇编产生的版权不用于限制合法权利,则在存储或分发介质的卷中或之上对本文件或其衍生品与其他单独且独立的文档或作品的汇编称为“集合体”汇编的用户超出了个别作品允许的范围。当文档包含在一个集合中时,本许可证不适用于集合中的其他作品,这些作品本身不是该文档的衍生作品。

    如果第 3 节的封面文本要求适用于文档的这些副本,则如果文档少于整个聚合的一半,则文档的封面文本可以放置在将文档括在聚合内的封面上,或者如果文档为电子形式,则封面的电子等效项。否则,它们必须出现在支撑整个聚合体的印刷封面上。

  16. AGGREGATION WITH INDEPENDENT WORKS

    A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, is called an “aggregate” if the copyright resulting from the compilation is not used to limit the legal rights of the compilation’s users beyond what the individual works permit. When the Document is included in an aggregate, this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document.

    If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one half of the entire aggregate, the Document’s Cover Texts may be placed on covers that bracket the Document within the aggregate, or the electronic equivalent of covers if the Document is in electronic form. Otherwise they must appear on printed covers that bracket the whole aggregate.

  17. 翻译

    翻译被视为一种修改,因此您可以根据第 4 节的条款分发文档的翻译版本。用翻译替换不变部分需要获得其版权所有者的特别许可,但除了以下内容之外,您还可以包括部分或全部不变部分的翻译这些不变部分的原始版本。您可以包含本许可证的翻译以及文档中的所有许可证声明以及任何保证免责声明,前提是您还包含本许可证的原始英文版本以及这些通知和免责声明的原始版本。如果本许可证或通知或免责声明的翻译版本与原始版本之间存在分歧,则以原始版本为准。

    如果文档中的某个部分的标题为“致谢”、“奉献”或“历史”,则保留其标题(第 1 节)的要求(第 4 节)通常需要更改实际标题。

  18. TRANSLATION

    Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License, and all the license notices in the Document, and any Warranty Disclaimers, provided that you also include the original English version of this License and the original versions of those notices and disclaimers. In case of a disagreement between the translation and the original version of this License or a notice or disclaimer, the original version will prevail.

    If a section in the Document is Entitled “Acknowledgements”, “Dedications”, or “History”, the requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual title.

  19. 终止

    除非本许可证明确规定,否则您不得复制、修改、再许可或分发本文档。任何以其他方式复制、修改、再许可或分发本许可的尝试均无效,并将自动终止您在本许可下的权利。

    但是,如果您停止一切违反本许可的行为,则特定版权所有者向您授予的许可将被恢复 (a) 临时恢复,除非版权所有者明确并最终终止您的许可,以及 (b) 如果版权所有者未能终止您的许可,则永久恢复在停止后 60 天内通过某种合理方式通知您违规行为。

    此外,如果版权所有者通过某种合理方式通知您违规行为,则您从特定版权所有者获得的许可证将被永久恢复,这是您第一次收到该版权所有者违反本许可证(针对任何作品)的通知,并且您在收到通知后 30 天内纠正了违规行为。

    终止您在本节下的权利不会终止已收到您根据本许可提供的副本或权利的各方的许可。如果您的权利已终止且未永久恢复,则收到部分或全部相同材料的副本并不赋予您使用该材料的任何权利。

  20. TERMINATION

    You may not copy, modify, sublicense, or distribute the Document except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, or distribute it is void, and will automatically terminate your rights under this License.

    However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.

    Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.

    Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, receipt of a copy of some or all of the same material does not give you any rights to use it.

  21. 本许可证的未来修订

    自由软件基金会可能会不时发布 GNU 自由文档许可证的新修订版本。此类新版本在精神上与当前版本相似,但在解决新问题或疑虑方面可能在细节上有所不同。请参阅 https://www.gnu.org/licenses/

    每个版本的许可证都有一个独特的版本号。如果文档指定本许可证的特定编号版本“或任何更高版本”适用于它,您可以选择遵循该指定版本或已发布的任何更高版本(不作为草案)由自由软件基金会制定。如果文档未指定本许可证的版本号,您可以选择自由软件基金会曾经发布的任何版本(不是草稿)。如果文档指定代理可以决定可以使用本许可证的哪些未来版本,则该代理接受版本的公开声明将永久授权您为文档选择该版本。

  22. FUTURE REVISIONS OF THIS LICENSE

    The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See https://www.gnu.org/licenses/.

    Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License “or any later version” applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation. If the Document specifies that a proxy can decide which future versions of this License can be used, that proxy’s public statement of acceptance of a version permanently authorizes you to choose that version for the Document.

  23. 重新许可

    “大型多作者协作网站”(或“MMC 网站”)是指发布受版权保护的作品并为任何人编辑这些作品提供显着设施的任何万维网服务器。任何人都可以编辑的公共维基就是此类服务器的一个示例。网站中包含的“大规模多作者合作”(或“MMC”)是指在 MMC 网站上发布的任何一组受版权保护的作品。

    “CC-BY-SA”是指由 Creative Commons Corporation(一家主要营业地点位于加利福尼亚州旧金山的非营利性公司)发布的 Creative Commons 署名-相同方式共享 3.0 许可证,以及该许可证未来的 Copyleft 版本由同一组织发布的许可证。

    “合并”是指将文档全部或部分发布或重新发布,作为另一文档的一部分。

    如果 MMC 根据本许可证获得许可,并且如果所有作品首次根据本许可证在本 MMC 以外的地方发布,并随后全部或部分合并到 MMC 中,则该 MMC 是“有资格获得重新许可的”,(1)封面文本或不变部分,并且 (2) 因此在 2008 年 11 月 1 日之前合并。

    MMC 网站的运营商可以在 2009 年 8 月 1 日之前的任何时间在同一网站上按照 CC-BY-SA 重新发布该网站中包含的 MMC,前提是该 MMC 符合重新许可的条件。

  24. RELICENSING

    “Massive Multiauthor Collaboration Site” (or “MMC Site”) means any World Wide Web server that publishes copyrightable works and also provides prominent facilities for anybody to edit those works. A public wiki that anybody can edit is an example of such a server. A “Massive Multiauthor Collaboration” (or “MMC”) contained in the site means any set of copyrightable works thus published on the MMC site.

    “CC-BY-SA” means the Creative Commons Attribution-Share Alike 3.0 license published by Creative Commons Corporation, a not-for-profit corporation with a principal place of business in San Francisco, California, as well as future copyleft versions of that license published by that same organization.

    “Incorporate” means to publish or republish a Document, in whole or in part, as part of another Document.

    An MMC is “eligible for relicensing” if it is licensed under this License, and if all works that were first published under this License somewhere other than this MMC, and subsequently incorporated in whole or in part into the MMC, (1) had no cover texts or invariant sections, and (2) were thus incorporated prior to November 1, 2008.

    The operator of an MMC Site may republish an MMC contained in the site under CC-BY-SA on the same site at any time before August 1, 2009, provided the MMC is eligible for relicensing.

附录:如何将此许可证用于您的文档

ADDENDUM: How to use this License for your documents

要在您编写的文档中使用本许可证,请在文档中包含许可证的副本,并将以下版权和许可证声明放在标题页之后:

To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page:

  版权所有 (C)    你的名字。
  授予复制、分发和/或修改本文档的许可
  根据 GNU 自由文档许可证 1.3 版的条款
  或自由软件基金会发布的任何更高版本;
  没有不变的部分,没有封面文本,也没有封底
  文本。许可证副本包含在标题为“GNU
  免费文档许可证”。
  Copyright (C)  year  your name.
  Permission is granted to copy, distribute and/or modify this document
  under the terms of the GNU Free Documentation License, Version 1.3
  or any later version published by the Free Software Foundation;
  with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
  Texts.  A copy of the license is included in the section entitled ``GNU
  Free Documentation License''.

如果您有不变的部分、封面文本和封底文本,请将“替换为……文本”。与此一致:

If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, replace the “with…Texts.” line with this:

    不变部分列出了它们的标题,
    封面文本为list,并带有封底文本
    正在列表中
    with the Invariant Sections being list their titles, with
    the Front-Cover Texts being list, and with the Back-Cover Texts
    being list.

如果您有没有封面文本的不变部分,或三者的其他组合,请合并这两个替代方案以适应情况。

If you have Invariant Sections without Cover Texts, or some other combination of the three, merge those two alternatives to suit the situation.

如果您的文档包含重要的程序代码示例,我们建议您根据您选择的自由软件许可证(例如 GNU 通用公共许可证)并行发布这些示例,以允许它们在自由软件中使用。

If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software.


附录 C Emacs 调用的命令行参数

Appendix C Command Line Arguments for Emacs Invocation

Emacs 支持命令行参数来在调用 Emacs 时请求各种操作。这些是为了与其他编辑器兼容并用于复杂的活动。我们不建议将它们用于普通编辑(请参阅使用 Emacs 作为服务器,了解从命令行访问现有 Emacs 作业的方法)。

Emacs supports command line arguments to request various actions when invoking Emacs. These are for compatibility with other editors and for sophisticated activities. We don’t recommend using them for ordinary editing (See Using Emacs as a Server, for a way to access an existing Emacs job from the command line).

以 ' 开头的参数-'是选项,也是'+行号'。所有其他参数指定要访问的文件。 Emacs 在启动时会访问指定的文件。命令行上指定的最后一个文件成为当前缓冲区;其他文件也在其他缓冲区中被访问。与大多数程序一样,特殊参数 '--' 表示所有后续参数都是文件名,而不是选项,即使它们以 ' 开头-'。

Arguments starting with ‘-’ are options, and so is ‘+linenum’. All other arguments specify files to visit. Emacs visits the specified files while it starts up. The last file specified on the command line becomes the current buffer; the other files are also visited in other buffers. As with most programs, the special argument ‘--’ says that all subsequent arguments are file names, not options, even if they start with ‘-’.

Emacs 命令选项可以指定很多内容,例如 Emacs 使用的 X 窗口的大小和位置、其颜色等等。一些选项支持高级用法,例如以批处理模式在文件上运行 Lisp 函数。本章各部分描述了可用的选项,并根据其用途进行了排列。

Emacs command options can specify many things, such as the size and position of the X window Emacs uses, its colors, and so on. A few options support advanced usage, such as running Lisp functions on files in batch mode. The sections of this chapter describe the available options, arranged according to their purpose.

有两种编写选项的方法: 以单个 ' 开头的缩写形式-',以及以 ' 开头的长形式--'。例如, '-d' 是缩写形式并且 '- 展示' 是相应的长形式。

There are two ways of writing options: the short forms that start with a single ‘-’, and the long forms that start with ‘--’. For example, ‘-d’ is a short form and ‘--display’ is the corresponding long form.

带有 ' 的长形式--' 更容易记住,但打字时间更长。但是,您不必拼写出整个选项名称;任何明确的缩写就足够了。当长选项需要参数时,可以使用空格或等号来分隔选项名称和参数。因此,对于选项 '- 展示',你可以写'--显示糖弹:0.0' 或者 '--display=糖弹:0.0'。我们建议使用等号,因为它使关系更清晰,并且下表始终显示等号。

The long forms with ‘--’ are easier to remember, but longer to type. However, you don’t have to spell out the whole option name; any unambiguous abbreviation is enough. When a long option requires an argument, you can use either a space or an equal sign to separate the option name and the argument. Thus, for the option ‘--display’, you can write either ‘--display sugar-bombs:0.0’ or ‘--display=sugar-bombs:0.0’. We recommend an equal sign because it makes the relationship clearer, and the tables below always show an equal sign.

大多数选项指定如何初始化 Emacs,或设置 Emacs 会话的参数。我们称它们为初始选项。有几个选项指定要执行的操作,例如加载库或调用 Lisp 函数。这些称为操作选项。这些和文件名一起称为操作参数。操作参数作为字符串列表存储在变量中 command-line-args。 (实际上,当 Emacs 启动时, command-line-args包含从命令行传递的所有参数;在初始化期间,初始参数在处理时会从该列表中删除,只留下操作参数。)

Most options specify how to initialize Emacs, or set parameters for the Emacs session. We call them initial options. A few options specify things to do, such as loading libraries or calling Lisp functions. These are called action options. These and file names together are called action arguments. The action arguments are stored as a list of strings in the variable command-line-args. (Actually, when Emacs starts up, command-line-args contains all the arguments passed from the command line; during initialization, the initial arguments are removed from this list when they are processed, leaving only the action arguments.)


C.1 行动参数

C.1 Action Arguments

这是一个动作参数表:

Here is a table of action arguments:

'文件'
file
'--文件=文件'
--file=file
'--查找文件=文件'
--find-file=file
'--访问=文件'
--visit=file

访问指定文件。请参阅访问文件

当 Emacs 启动时,它在一个窗口中显示启动缓冲区,并在另一个窗口中显示访问文件的缓冲区(请参阅多个窗口)。如果您提供多个文件参数,则显示的文件是命令行中指定的最后一个文件;访问其他文件但不显示它们的缓冲区。

如果启动缓冲区被禁用(请参阅进入 Emacs ),则使用一个文件参数启动 Emacs 会在单个窗口中显示访问文件的缓冲区 。通过两个文件参数,Emacs 在两个不同的窗口中显示文件。如果有两个以上的文件参数,Emacs 将显示一个窗口中指定的最后一个文件,以及另一个带有缓冲区菜单的窗口,其中显示所有其他文件(请参阅在多个缓冲区上操作)。要禁止使用缓冲区菜单来执行此操作,请将变量更改inhibit-startup-buffer-menut

Visit the specified file. See Visiting Files.

When Emacs starts up, it displays the startup buffer in one window, and the buffer visiting file in another window (see Multiple Windows). If you supply more than one file argument, the displayed file is the last one specified on the command line; the other files are visited but their buffers are not shown.

If the startup buffer is disabled (see Entering Emacs), then starting Emacs with one file argument displays the buffer visiting file in a single window. With two file arguments, Emacs displays the files in two different windows. With more than two file arguments, Emacs displays the last file specified in one window, plus another window with a Buffer Menu showing all the other files (see Operating on Several Buffers). To inhibit using the Buffer Menu for this, change the variable inhibit-startup-buffer-menu to t.

'+文件行数 '
+linenum file

访问指定的文件,然后转到 其中的 行号linenum 。

Visit the specified file, then go to line number linenum in it.

'+ linenum :列号 文件'
+linenum:columnnum file

访问指定的文件,然后转到行号linenum 并将点放在列号columnnum处。

Visit the specified file, then go to line number linenum and put point at column number columnnum.

'-l文件'
-l file
'--加载=文件'
--load=file

使用函数加载名为file 的Lisp 库load。如果file不是绝对文件名,Emacs 首先在当前目录中查找它,然后在 中列出的目录中查找 load-path(请参阅Emacs 的 Lisp 代码库)。

警告:如果前面的命令行参数访问过文件,则当前目录是最后访问的文件的目录。

Load a Lisp library named file with the function load. If file is not an absolute file name, Emacs first looks for it in the current directory, then in the directories listed in load-path (see Libraries of Lisp Code for Emacs).

Warning: If previous command-line arguments have visited files, the current directory is the directory of the last file visited.

'-L目录'
-L dir
'--目录=目录'
--directory=dir

将目录dir添加到变量前面load-path。如果您指定多个 '-L' 选项,Emacs 保留相对顺序;即,使用 '-L /foo -L /酒吧' 结果为 aload-path形式("/foo" "/bar" …)。如果dir以 ' 开头:',Emacs 删除了 ':' 并将余数附加(而不是前置)到load-path. (在 MS Windows 上,使用 ';' 代替 ':';即,使用 的值path-separator。)

Prepend directory dir to the variable load-path. If you specify multiple ‘-L’ options, Emacs preserves the relative order; i.e., using ‘-L /foo -L /bar’ results in a load-path of the form ("/foo" "/bar" …). If dir begins with ‘:’, Emacs removes the ‘:’ and appends (rather than prepends) the remainder to load-path. (On MS Windows, use ‘;’ instead of ‘:’; i.e., use the value of path-separator.)

'-f函数'
-f function
'--funcall=函数'
--funcall=function

调用Lisp函数函数。如果它是交互式函数(命令),它将以交互方式读取参数,就像您使用按键序列调用相同的函数一样。否则,它将调用不带参数的函数。

Call Lisp function function. If it is an interactive function (a command), it reads the arguments interactively just as if you had called the same function with a key sequence. Otherwise, it calls the function with no arguments.

'--eval=表达式'
--eval=expression
'--execute=表达式'
--execute=expression

评估 Lisp 表达式表达式

Evaluate Lisp expression expression.

'--插入=文件'
--insert=file

将文件的内容插入到处理此命令行参数时当前的缓冲区中。通常,这是 *划痕*缓冲区(请参阅Lisp 交互缓冲区),但如果命令行中较早的参数访问文件或切换缓冲区,则可能是不同的缓冲区。此命令行参数的效果类似于M-x insert-file(请参阅其他文件操作)。

Insert the contents of file into the buffer that is current when this command-line argument is processed. Usually, this is the *scratch* buffer (see Lisp Interaction Buffers), but if arguments earlier on the command line visit files or switch buffers, that might be a different buffer. The effect of this command-line argument is like what M-x insert-file does (see Miscellaneous File Operations).

'- 杀'
--kill

退出 Emacs 而不要求确认。

Exit from Emacs without asking for confirmation.

'- 帮助'
--help

打印一条使用消息,列出所有可用选项,然后成功退出。

Print a usage message listing all available options, then exit successfully.

'- 版本'
--version

打印Emacs版本,然后成功退出。

Print Emacs version, then exit successfully.

'- 指纹'
--fingerprint

打印Emacs“指纹”,用于唯一标识Emacs的编译版本。

Print the Emacs “fingerprint”, which is used to uniquely identify the compiled version of Emacs.


C.2 初始选项

C.2 Initial Options

初始选项指定 Emacs 会话的参数。本节描述更一般的初始选项;一些与 X Window 系统特别相关的其他选项出现在以下部分中。

The initial options specify parameters for the Emacs session. This section describes the more general initial options; some other options specifically related to the X Window System appear in the following sections.

一些初始选项会影响初始化文件的加载。通常,Emacs 首先加载站点启动.el如果存在,那么你自己的初始化文件如果存在,最后是默认的初始化文件默认值.el如果存在(请参阅Emacs 初始化文件)。某些选项会阻止加载其中某些文件或用其他文件替换它们。

Some initial options affect the loading of the initialization file. Normally, Emacs first loads site-start.el if it exists, then your own initialization file if it exists, and finally the default initialization file default.el if it exists (see The Emacs Initialization File). Certain options prevent loading of some of these files or substitute other files for them.

'-chdir目录'
-chdir directory
'--chdir=目录'
--chdir=directory

在执行其他操作之前更改到目录。这主要用于 X 中的会话管理,以便 Emacs 在其停止时的同一目录中启动。这使得桌面保存和恢复变得更加容易。

Change to directory before doing anything else. This is mainly used by session management in X so that Emacs starts in the same directory as it stopped. This makes desktop saving and restoring easier.

'-t设备'
-t device
'--终端=设备'
--terminal=device

使用device作为终端输入输出的设备。该选项意味着 '--无窗口系统'。

Use device as the device for terminal input and output. This option implies ‘--no-window-system’.

'-d显示'
-d display
'--显示=显示'
--display=display

使用 X Window 系统并使用名为 display 的显示打开初始 Emacs 框架。有关更多详细信息, 请参阅指定显示名称。

Use the X Window System and use the display named display to open the initial Emacs frame. See Specifying the Display Name, for more details.

'-西北'
-nw
'--无窗口系统'
--no-window-system

不要直接与窗口系统通信,忽略 DISPLAY环境变量,即使它已设置。这意味着 Emacs 使用启动它的终端来进行所有显示和输入。

Don’t communicate directly with the window system, disregarding the DISPLAY environment variable even if it is set. This means that Emacs uses the terminal from which it was launched for all its display and input.

'-批'
-batch
'- 批'
--batch

以批处理模式运行 Emacs 。批处理模式用于运行通过 shell 脚本、makefile 等用 Emacs Lisp 编写的程序。要调用 Lisp 程序,请使用 '-批' 选项与一个或多个 ' 结合使用-l','-F' 或者 '--评估'(参见操作参数)。有关示例, 请参阅命令参数示例。

在批处理模式下,Emacs 不会显示正在编辑的文本,标准终端中断字符(例如C-z和 )C-c 具有其通常的效果。通常在回显区域打印消息的 Emacs 函数将打印到标准输出流 ( stdout) 或标准错误流 ( stderr)。 (准确地说,诸如prin1princprintprint to stdout、 whilemessageerrorprint to 之类的函数stderr。)通常从迷你缓冲区读取键盘输入的函数会从终端的标准输入流 ( stdin) 获取输入。

'- 批' 暗示 '-q'(不加载初始化文件),但是站点启动.el尽管如此,还是已加载。它还会导致 Emacs 在处理完所有命令选项后退出。此外,它会禁用自动保存,除非明确请求自动保存的缓冲区中,并且在保存文件时,fsync 除非另有要求,否则它会忽略系统调用。

运行 ' 时发生的错误- 批' Emacs 将导致打印 Emacs Lisp 回溯。要禁用此行为,请设置 backtrace-on-error-noninteractivenil

Run Emacs in batch mode. Batch mode is used for running programs written in Emacs Lisp from shell scripts, makefiles, and so on. To invoke a Lisp program, use the ‘-batch’ option in conjunction with one or more of ‘-l’, ‘-f’ or ‘--eval’ (see Action Arguments). See Command Argument Example, for an example.

In batch mode, Emacs does not display the text being edited, and the standard terminal interrupt characters such as C-z and C-c have their usual effect. Emacs functions that normally print a message in the echo area will print to either the standard output stream (stdout) or the standard error stream (stderr) instead. (To be precise, functions like prin1, princ and print print to stdout, while message and error print to stderr.) Functions that normally read keyboard input from the minibuffer take their input from the terminal’s standard input stream (stdin) instead.

--batch’ implies ‘-q’ (do not load an initialization file), but site-start.el is loaded nonetheless. It also causes Emacs to exit after processing all the command options. In addition, it disables auto-saving except in buffers for which auto-saving is explicitly requested, and when saving files it omits the fsync system call unless otherwise requested.

Errors that occur when running a ‘--batch’ Emacs will result in an Emacs Lisp backtrace being printed. To disable this behavior, set backtrace-on-error-noninteractive to nil.

'--脚本文件'
--script file

以批处理模式运行 Emacs,例如 '- 批',然后读取并执行file中的 Lisp 代码。

此选项的正常使用是在运行 Emacs 的可执行脚本文件中。他们可以从第一行的这段文字开始

#!/usr/bin/emacs --script

这将调用 Emacs '- 脚本' 并将脚本文件的名称提供为file。 Emacs Lisp 然后处理 '#!' 在第一行作为注释分隔符。

Run Emacs in batch mode, like ‘--batch’, and then read and execute the Lisp code in file.

The normal use of this option is in executable script files that run Emacs. They can start with this text on the first line

#!/usr/bin/emacs --script

which will invoke Emacs with ‘--script’ and supply the name of the script file as file. Emacs Lisp then treats the ‘#!’ on this first line as a comment delimiter.

'-X'
-x

该选项只能在可执行脚本文件中使用,并且应该像这样调用:

#!/usr/bin/emacs -x

这就像'- 脚本',但会禁止加载初始化文件(如--quick),并且不能在普通命令行上使用(因为它没有指定要加载的脚本)。此外,当到达脚本末尾时,它退出 Emacs 并使用最终形式的值作为脚本的退出值(如果最终值是数字)。否则,它将始终以零值退出。请注意,在这种情况下,当 Emacs 读取 Lisp 代码时,它会忽略第一行和靠近文件末尾的本地变量部分中的 任何文件本地变量(请参阅指定文件变量)。

This option can only be used in executable script files, and should be invoked like this:

#!/usr/bin/emacs -x

This is like ‘--script’, but suppresses loading the init files (like --quick), and can’t be used on a normal command line (since it doesn’t specify the script to load). In addition, when it reaches the end of the script, it exits Emacs and uses the value of the final form as the exit value from the script (if the final value is numerical). Otherwise, it will always exit with a zero value. Note that when Emacs reads the Lisp code in this case, it ignores any file-local variables (see Specifying File Variables), both in the first line and in a local-variables section near the end of the file.

'--无构建细节'
--no-build-details

省略 Emacs 可执行文件中的系统名称和构建时间等详细信息,以便构建更具确定性。此开关不适合常规(或交互式)使用,因为它会发出类似 system-namereturn 的命令nil

Omit details like system name and build time from the Emacs executable, so that builds are more deterministic. This switch is not meant for regular (or interactive) use, since it makes commands like system-name return nil.

'-q'
-q
'--无初始化文件'
--no-init-file

不要加载任何初始化文件(请参阅Emacs 初始化文件)。当使用此选项调用 Emacs 时,自定义工具不允许保存选项(请参阅轻松自定义界面)。此选项不会禁用加载站点启动.el

Do not load any initialization file (see The Emacs Initialization File). When Emacs is invoked with this option, the Customize facility does not allow options to be saved (see Easy Customization Interface). This option does not disable loading site-start.el.

'--无站点文件'
--no-site-file
'-nsl'
-nsl

请勿加载站点启动.el(请参阅Emacs 初始化文件)。这 '-Q' 选项也可以这样做,但其他选项如 '-q' 不要。

Do not load site-start.el (see The Emacs Initialization File). The ‘-Q’ option does this too, but other options like ‘-q’ do not.

'--无站点 Lisp'
--no-site-lisp

不包括站点 Lisp目录load-path (请参阅Emacs 初始化文件)。这 '-Q' 选项也执行此操作。

Do not include the site-lisp directories in load-path (see The Emacs Initialization File). The ‘-Q’ option does this too.

'--init-目录'
--init-directory

指定查找 Emacs 初始化文件时要使用的目录。

Specify the directory to use when looking for the Emacs init files.

'--无飞溅'
--no-splash

不显示启动屏幕。您还可以通过 在初始化文件中将变量设置inhibit-startup-screen为 non- 来实现此效果(请参阅进入 Emacs)。 nil

Do not display a startup screen. You can also achieve this effect by setting the variable inhibit-startup-screen to non-nil in your initialization file (see Entering Emacs).

'--无-x-资源'
--no-x-resources

不加载 X 资源。您还可以通过在初始化文件中将变量设置inhibit-x-resources为 来实现此效果(请参阅X Resources)。 t

Do not load X resources. You can also achieve this effect by setting the variable inhibit-x-resources to t in your initialization file (see X Resources).

'-Q'
-Q
'- 快的'
--quick

以最少的自定义启动 Emacs。这类似于使用 '-q','--无站点文件','--无站点 Lisp','--无-x-资源', 和 '--无飞溅' 一起。

Start Emacs with minimum customizations. This is similar to using ‘-q’, ‘--no-site-file’, ‘--no-site-lisp’, ‘--no-x-resources’, and ‘--no-splash’ together.

'-守护进程'
-daemon
'--守护进程[=名称]'
--daemon[=name]
'--bg-daemon[=名称]'
--bg-daemon[=name]
'--fg-守护进程[=名称]'
--fg-daemon[=name]

作为守护进程启动 Emacs:Emacs 启动后,它会启动 Emacs 服务器而不打开任何框架。然后您可以使用该 emacsclient命令连接到 Emacs 进行编辑。 (可选地,您可以为服务器指定一个显式名称;如果这样做,您将需要在调用时 通过其指定相同的名称emacsclient--套接字名称有关使用 Emacs 作为守护程序的emacsclient信息, 请参阅使用 Emacs 作为服务器。 “后台”守护进程与终端断开连接并在后台运行('--守护进程' 是 ' 的别名--bg-守护进程')。

Start Emacs as a daemon: after Emacs starts up, it starts the Emacs server without opening any frames. You can then use the emacsclient command to connect to Emacs for editing. (Optionally, you can specify an explicit name for the server; if you do, you will need to specify the same name when you invoke emacsclient, via its --socket-name option, see emacsclient Options.) See Using Emacs as a Server, for information about using Emacs as a daemon. A “background” daemon disconnects from the terminal and runs in the background (‘--daemon’ is an alias for ‘--bg-daemon’).

'--无桌面'
--no-desktop

不要重新加载任何已保存的桌面。请参阅保存 Emacs 会话

Do not reload any saved desktop. See Saving Emacs Sessions.

'-u用户'
-u user
'--用户=用户'
--user=user

加载用户的初始化文件而不是你自己的26

Load user’s initialization file instead of your own26.

'--调试初始化'
--debug-init

启用 Emacs Lisp 调试器以检查 init 文件中的错误。请参阅《GNU Emacs Lisp 参考手册》中的“出现错误时进入调试器”

Enable the Emacs Lisp debugger for errors in the init file. See Entering the Debugger on an Error in The GNU Emacs Lisp Reference Manual.

'--模块断言'
--module-assertions

在处理动态可加载模块时启用昂贵的正确性检查。这适用于希望验证其模块是否符合模块 API 要求的模块作者。如果触发了与模块相关的断言,该选项会使 Emacs 中止。请参阅《GNU Emacs Lisp 参考手册》中的“编写动态加载模块”

Enable expensive correctness checks when dealing with dynamically loadable modules. This is intended for module authors that wish to verify that their module conforms to the module API requirements. The option makes Emacs abort if a module-related assertion triggers. See Writing Dynamically-Loaded Modules in The GNU Emacs Lisp Reference Manual.

'--dump-file=文件'
--dump-file=file

从指定文件加载转储的 Emacs 状态。默认情况下,已安装的 Emacs 将在名为的文件中查找其转储状态 emacs.pdmp在 Emacs 安装放置依赖于体系结构的文件的目录中;该变量 exec-directory保存该目录的名称。 emacs 是 Emacs 可执行文件的名称,通常只是emacs。 (当您从源代码如果您重命名或将转储文件移动到其他位置,则可以使用此选项告诉 Emacs 在哪里可以找到该文件。

Load the dumped Emacs state from the named file. By default, an installed Emacs will look for its dump state in a file named emacs.pdmp in the directory where the Emacs installation puts the architecture-dependent files; the variable exec-directory holds the name of that directory. emacs is the name of the Emacs executable file, normally just emacs. (When you invoke Emacs from the src directory where it was built without installing it, it will look for the dump file in the directory of the executable.) If you rename or move the dump file to a different place, you can use this option to tell Emacs where to find that file.


C.3 命令参数示例

C.3 Command Argument Example

下面是使用带有参数和选项的 Emacs 的示例。它假设你有一个名为的 Lisp 程序文件黑客c.el当加载时,它会对当前缓冲区执行一些有用的操作,预计是一个 C 程序。

Here is an example of using Emacs with arguments and options. It assumes you have a Lisp program file called hack-c.el which, when loaded, performs some useful operation on the current buffer, expected to be a C program.

emacs --batch foo.c -l hack-c -f 保存缓冲区 >& 日志
emacs --batch foo.c -l hack-c -f save-buffer >& log

这说的是访问foo.c, 加载黑客c.el(这会对访问的文件进行更改),保存foo.c(注意这 save-buffer是绑定到的函数C-x C-s),然后退出回到shell(因为'- 批')。 '- 批' 还保证将输出重定向到不会出现问题 日志,因为 Emacs 不会假设它有一个可以使用的显示终端。

This says to visit foo.c, load hack-c.el (which makes changes in the visited file), save foo.c (note that save-buffer is the function that C-x C-s is bound to), and then exit back to the shell (because of ‘--batch’). ‘--batch’ also guarantees there will be no problem redirecting output to log, because Emacs will not assume that it has a display terminal to work with.


C.4 环境变量

C.4 Environment Variables

环境是操作系统的一个功能它由具有名称和值的变量集合组成。每个变量称为环境变量;环境变量名称区分大小写,通常只使用大写字母。这些值都是文本字符串。

The environment is a feature of the operating system; it consists of a collection of variables with names and values. Each variable is called an environment variable; environment variable names are case-sensitive, and it is conventional to use upper case letters only. The values are all text strings.

该环境的有用之处在于子进程自动从其父进程继承环境。这意味着您可以在登录 shell 中设置一个环境变量,并且您运行的所有程序(包括 Emacs)都会自动看到它。 Emacs 的子进程(例如 shell、编译器和版本控制程序)也继承了 Emacs 的环境。

What makes the environment useful is that subprocesses inherit the environment automatically from their parent process. This means you can set up an environment variable in your login shell, and all the programs you run (including Emacs) will automatically see it. Subprocesses of Emacs (such as shells, compilers, and version control programs) inherit the environment from Emacs, too.

在 Emacs 中,该命令M-x getenv读取环境变量的名称,并在回显区域中打印其值。 M-x setenv在 Emacs 环境中设置变量,并C-u M-x setenv删除变量。 (环境变量替换为 '$' 就像在文件名中一样使用值;请参阅带有 $ 的文件名。)该变量initial-environment存储 Emacs 继承的初始环境。

Inside Emacs, the command M-x getenv reads the name of an environment variable, and prints its value in the echo area. M-x setenv sets a variable in the Emacs environment, and C-u M-x setenv removes a variable. (Environment variable substitutions with ‘$’ work in the value just as in file names; see File Names with $.) The variable initial-environment stores the initial environment inherited by Emacs.

在 Emacs 之外设置环境变量的方法取决于操作系统,尤其是您所使用的 shell。例如,以下是如何将环境变量设置ORGANIZATION 为“不是很多' 使用 Bash:

The way to set environment variables outside of Emacs depends on the operating system, and especially the shell that you are using. For example, here’s how to set the environment variable ORGANIZATION to ‘not very much’ using Bash:

出口组织=“不是很多”
export ORGANIZATION="not very much"

以下是在 csh 或 tcsh 中执行此操作的方法:

and here’s how to do it in csh or tcsh:

setenv 组织“不是很多”
setenv ORGANIZATION "not very much"

当 Emacs 使用 X Window 系统时,控制 X 的各种环境变量也适用于 Emacs。请参阅 X 文档以获取更多信息。

When Emacs is using the X Window System, various environment variables that control X work for Emacs as well. See the X documentation for more information.


C.4.1 通用变量

C.4.1 General Variables

以下是按字母顺序排列的环境变量列表,这些变量在 Emacs 中具有特殊含义。大多数这些变量也被其他一些程序使用。 Emacs 不需要设置任何这些环境变量,但如果设置了它们,它就会使用它们的值。

Here is an alphabetical list of environment variables that have special meanings in Emacs. Most of these variables are also used by some other programs. Emacs does not require any of these environment variables to be set, but it uses their values if they are set.

CDPATH
CDPATH

当您指定相对目录时,命令将使用该cd命令来搜索您指定的目录。

Used by the cd command to search for the directory you specify, when you specify a relative directory.

COLORTERM
COLORTERM

如果此变量设置为值 '本色',它告诉 Emacs 在文本模式显示上使用 24 位真彩色,即使没有安装 terminfo 数据库也是如此。 Emacs 将使用内置命令通过 RGB 值请求真实颜色,而不是缺少 terminfo 信息。

If this variable is set to the value ‘truecolor’, it tells Emacs to use 24-bit true color on text-mode displays even if the terminfo database is not installed. Emacs will use built-in commands to request true color by RGB values instead of the missing terminfo information.

DBUS_SESSION_BUS_ADDRESS
DBUS_SESSION_BUS_ADDRESS

当 Emacs 与 D-Bus 一起编译时,由 D-Bus 使用。通常,无需更改它。将其设置为虚拟地址,例如'unix:path=/dev/null',抑制与 D-Bus 会话总线的连接,并在尚未运行时自动启动 D-Bus 会话总线。

Used by D-Bus when Emacs is compiled with it. Usually, there is no need to change it. Setting it to a dummy address, like ‘unix:path=/dev/null’, suppresses connections to the D-Bus session bus as well as autolaunching the D-Bus session bus if not running yet.

EMACSDATA
EMACSDATA

Emacs 附带的与体系结构无关的文件的目录。这用于初始化变量data-directory

Directory for the architecture-independent files that come with Emacs. This is used to initialize the variable data-directory.

EMACSDOC
EMACSDOC

文档字符串文件的目录,用于初始化 Lisp 变量doc-directory

Directory for the documentation string file, which is used to initialize the Lisp variable doc-directory.

EMACSLOADPATH
EMACSLOADPATH

以冒号分隔的目录列表27用于搜索 Emacs Lisp 文件。如果设置,它会修改变量的通常初始值 load-path(请参阅Libraries of Lisp Code for Emacs)。空元素代表load-path;的默认值例如,使用 'EMACSLOADPATH="/tmp:"”补充道/tmp到默认的前面load-path。要在列表中间指定空元素,请连续使用 2 个冒号,如 'EMACSLOADPATH="/tmp::/foo"'。

A colon-separated list of directories27 to search for Emacs Lisp files. If set, it modifies the usual initial value of the load-path variable (see Libraries of Lisp Code for Emacs). An empty element stands for the default value of load-path; e.g., using ‘EMACSLOADPATH="/tmp:"’ adds /tmp to the front of the default load-path. To specify an empty element in the middle of the list, use 2 colons in a row, as in ‘EMACSLOADPATH="/tmp::/foo"’.

EMACSPATH
EMACSPATH

用于搜索可执行文件的以冒号分隔的目录列表。如果设置,EmacsPATH在初始化变量时除了(见下文)之外还会使用它exec-path(请参阅从 Emacs 运行 Shell 命令)。

A colon-separated list of directories to search for executable files. If set, Emacs uses this in addition to PATH (see below) when initializing the variable exec-path (see Running Shell Commands from Emacs).

EMAIL
EMAIL

您的电子邮件地址;用于初始化 Lisp 变量 user-mail-address,Emacs 邮件界面将其放入 '' 外发邮件的标头(请参阅邮件标头字段)。

Your email address; used to initialize the Lisp variable user-mail-address, which the Emacs mail interface puts into the ‘From’ header of outgoing messages (see Mail Header Fields).

ESHELL
ESHELL

用于 shell 模式覆盖SHELL环境变量(请参阅Interactive Subshel​​l)。

Used for shell-mode to override the SHELL environment variable (see Interactive Subshell).

HISTFILE
HISTFILE

shell 命令在两次登录之间保存的文件的名称。该变量默认为〜/.bash_history如果您使用 Bash, ~/.sh_历史记录如果您使用 ksh,并且~/.历史 否则。

The name of the file that shell commands are saved in between logins. This variable defaults to ~/.bash_history if you use Bash, to ~/.sh_history if you use ksh, and to ~/.history otherwise.

HOME
HOME

文件在目录树中的位置;用于扩展以波形符开头的文件名()。如果设置,则应设置为绝对文件名。 (如果设置为相对文件名,Emacs 会相对于 Emacs 启动的目录来解释它,但我们不建议使用此功能。)如果未设置,HOME 通常默认为 给定的用户的主目录 LOGNAMEUSER或者您的用户 ID,或/如果一切都失败了。在 MS-DOS 上,它默认为启动 Emacs 的目录,带有 '/垃圾桶' 如果存在则从末尾删除。在 Windows 上,默认HOME值为应用数据用户配置文件目录的子目录(通常是 C:/文档和设置/用户名/应用程序数据,其中username是您的用户名),但为了向后兼容C:/如果a.emacs在那里找到文件。

The location of your files in the directory tree; used for expansion of file names starting with a tilde (~). If set, it should be set to an absolute file name. (If set to a relative file name, Emacs interprets it relative to the directory where Emacs was started, but we don’t recommend to use this feature.) If unset, HOME normally defaults to the home directory of the user given by LOGNAME, USER or your user ID, or to / if all else fails. On MS-DOS, it defaults to the directory from which Emacs was started, with ‘/bin’ removed from the end if it was present. On Windows, the default value of HOME is the Application Data subdirectory of the user profile directory (normally, this is C:/Documents and Settings/username/Application Data, where username is your user name), though for backwards compatibility C:/ will be used instead if a .emacs file is found there.

HOSTNAME
HOSTNAME

运行 Emacs 的计算机的名称。

The name of the machine that Emacs is running on.

INFOPATH
INFOPATH

以冒号分隔的目录列表,在其中搜索信息文件。

A colon-separated list of directories in which to search for Info files.

LC_ALL
LC_ALL
LC_COLLATE
LC_COLLATE
LC_CTYPE
LC_CTYPE
LC_MESSAGES
LC_MESSAGES
LC_MONETARY
LC_MONETARY
LC_NUMERIC
LC_NUMERIC
LC_TIME
LC_TIME
LANG
LANG

用户的首选区域设置。区域设置有六个类别,LC_COLLATE由用于排序、 LC_CTYPE字符编码、LC_MESSAGES系统消息、LC_MONETARY货币格式、LC_NUMERIC数字以及LC_TIME日期和时间的环境变量指定。如果未设置这些变量之一,则类别默认为环境变量的值 LANG,或默认的 'C' 如果 LANG未设置区域设置。但如果LC_ALL指定,它将覆盖所有其他区域设置环境变量的设置。

在 MS-Windows 和 macOS 上,如果LANG环境中尚未设置,Emacs 将根据系统范围的默认值进行设置。您可以在某些版本的 MS-Windows 上的“区域设置”控制面板中以及 macOS 上的“语言和区域”系统偏好设置中进行设置。

类别的值与、 和 LC_CTYPE中的条目进行匹配,以选择默认语言环境和编码系统。请参阅语言环境locale-language-nameslocale-charset-language-nameslocale-preferred-coding-systems

The user’s preferred locale. The locale has six categories, specified by the environment variables LC_COLLATE for sorting, LC_CTYPE for character encoding, LC_MESSAGES for system messages, LC_MONETARY for monetary formats, LC_NUMERIC for numbers, and LC_TIME for dates and times. If one of these variables is not set, the category defaults to the value of the LANG environment variable, or to the default ‘C’ locale if LANG is not set. But if LC_ALL is specified, it overrides the settings of all the other locale environment variables.

On MS-Windows and macOS, if LANG is not already set in the environment, Emacs sets it based on the system-wide default. You can set this in the “Regional Settings” Control Panel on some versions of MS-Windows, and in the “Language and Region” System Preference on macOS.

The value of the LC_CTYPE category is matched against entries in locale-language-names, locale-charset-language-names, and locale-preferred-coding-systems, to select a default language environment and coding system. See Language Environments.

LOGNAME
LOGNAME

用户的登录名。也可以看看USER

The user’s login name. See also USER.

MAIL
MAIL

您的系统邮件收件箱的名称。

The name of your system mail inbox.

MH
MH

mh 系统安装文件的名称。请参阅MH 的 Emacs 接口中的MH-E

Name of setup file for the mh system. See MH-E in The Emacs Interface to MH.

NAME
NAME

你真实世界的名字。这用于初始化变量 user-full-name(请参阅邮件标头字段)。

Your real-world name. This is used to initialize the variable user-full-name (see Mail Header Fields).

NNTPSERVER
NNTPSERVER

新闻服务器的名称。由 mh 和 Gnus 软件包使用。

The name of the news server. Used by the mh and Gnus packages.

ORGANIZATION
ORGANIZATION

您所属组织的名称。用于设置 '组织:' 来自 Gnus 包的帖子中的标题。

The name of the organization to which you belong. Used for setting the ‘Organization:’ header in your posts from the Gnus package.

PATH
PATH

以冒号分隔的包含可执行文件的目录列表。这用于初始化变量exec-path (请参阅从 Emacs 运行 Shell 命令)。

A colon-separated list of directories containing executable files. This is used to initialize the variable exec-path (see Running Shell Commands from Emacs).

PWD
PWD

如果设置,这应该是 Emacs 启动时的默认目录。

If set, this should be the default directory when Emacs was started.

REPLYTO
REPLYTO

如果设置,则指定变量的初始值 mail-default-reply-to(请参阅邮件标头字段)。

If set, this specifies an initial value for the variable mail-default-reply-to (see Mail Header Fields).

SAVEDIR
SAVEDIR

默认保存新闻文章的目录名称。由 Gnus 包使用。

The name of a directory in which news articles are saved by default. Used by the Gnus package.

SHELL
SHELL

用于解析和执行 Emacs 内部运行的程序的解释器的名称。这用于初始化变量 shell-file-name(请参阅单 Shell 命令)。

The name of an interpreter used to parse and execute programs run from inside Emacs. This is used to initialize the variable shell-file-name (see Single Shell Commands).

SMTPSERVER
SMTPSERVER

发送邮件服务器的名称。这用于初始化变量smtpmail-smtp-server(请参阅邮件发送)。

The name of the outgoing mail server. This is used to initialize the variable smtpmail-smtp-server (see Mail Sending).

TERM
TERM

Emacs 正在使用的终端的类型。除非 Emacs 以批处理模式运行,否则必须设置此变量。在 MS-DOS 上,它默认为 '内部的',它指定处理机器自身显示的内置终端仿真。

The type of the terminal that Emacs is using. This variable must be set unless Emacs is run in batch mode. On MS-DOS, it defaults to ‘internal’, which specifies a built-in terminal emulation that handles the machine’s own display.

TERMCAP
TERMCAP

termcap 库文件的名称,描述如何对 指定的终端进行编程TERM。这默认为 /etc/termcap

The name of the termcap library file describing how to program the terminal specified by TERM. This defaults to /etc/termcap.

TMPDIR
TMPDIR
TMP
TMP
TEMP
TEMP

这些环境变量用于初始化变量 temporary-file-directory,该变量指定放置临时文件的目录(请参阅备份文件)。 Emacs先尝试使用 TMPDIR。如果未设置,Emacs 通常会依靠 /tmp,但在 MS-Windows 和 MS-DOS 上,它反而依赖于 TMP,然后TEMP,最后c:/温度

These environment variables are used to initialize the variable temporary-file-directory, which specifies a directory in which to put temporary files (see Backup Files). Emacs tries to use TMPDIR first. If that is unset, Emacs normally falls back on /tmp, but on MS-Windows and MS-DOS it instead falls back on TMP, then TEMP, and finally c:/temp.

TZ
TZ

这指定了默认时区,还可能指定夏令时信息。请参阅《GNU Emacs Lisp 参考手册》中的时区规则。在 MS-DOS 上,如果在 Emacs 启动时未在环境中设置 ,Emacs 会定义一个适合 DOS 返回的国家/地区代码的默认值。在 MS-Windows 上,Emacs根本 不使用。TZTZ

This specifies the default time zone and possibly also daylight saving time information. See Time Zone Rules in The GNU Emacs Lisp Reference Manual. On MS-DOS, if TZ is not set in the environment when Emacs starts, Emacs defines a default value as appropriate for the country code returned by DOS. On MS-Windows, Emacs does not use TZ at all.

USER
USER

用户的登录名。也可以看看LOGNAME。在 MS-DOS 上,默认为 ''。

The user’s login name. See also LOGNAME. On MS-DOS, this defaults to ‘root’.

VERSION_CONTROL
VERSION_CONTROL

用于初始化version-control变量(请参阅单个备份或编号备份)。

Used to initialize the version-control variable (see Single or Numbered Backups).


C.4.2 杂项变量

C.4.2 Miscellaneous Variables

这些变量仅用于特定配置:

These variables are used only on particular configurations:

COMSPEC
COMSPEC

在 MS-DOS 和 MS-Windows 上,调用 shell 内部的批处理文件和命令时使用的命令解释器的名称。在 MS-DOS 上,这也用于为SHELL环境变量设置默认值。

On MS-DOS and MS-Windows, the name of the command interpreter to use when invoking batch files and commands internal to the shell. On MS-DOS this is also used to make a default value for the SHELL environment variable.

NAME
NAME

在 MS-DOS 上,此变量默认为变量的值USER

On MS-DOS, this variable defaults to the value of the USER variable.

EMACSTEST
EMACSTEST

在 MS-DOS 上,这指定一个用于记录内部终端仿真器操作的文件。此功能对于提交错误报告非常有用。

On MS-DOS, this specifies a file to use to log the operation of the internal terminal emulator. This feature is useful for submitting bug reports.

EMACSCOLORS
EMACSCOLORS

在 MS-DOS 上,这指定屏幕颜色。以这种方式设置它们很有用,否则 Emacs 会在启动时立即显示默认颜色。

该变量的值应该是默认脸部的前景(第一个字符)和背景(第二个字符)颜色的双字符编码。每个字符都应该是标准 PC 文本模式显示器上所需颜色的十六进制代码。例如,要在浅灰色背景上获取蓝色文本,请指定 'EMAC颜色=17',因为 1 是蓝色的代码,7 是浅灰色的代码。

PC 显示器通常仅支持八种背景颜色。然而,Emacs 将 DOS 显示切换到所有 16 种颜色都可以用于背景的模式,因此背景颜色的所有四位实际上都被使用。

On MS-DOS, this specifies the screen colors. It is useful to set them this way, since otherwise Emacs would display the default colors momentarily when it starts up.

The value of this variable should be the two-character encoding of the foreground (the first character) and the background (the second character) colors of the default face. Each character should be the hexadecimal code for the desired color on a standard PC text-mode display. For example, to get blue text on a light gray background, specify ‘EMACSCOLORS=17’, since 1 is the code of the blue color and 7 is the code of the light gray color.

The PC display usually supports only eight background colors. However, Emacs switches the DOS display to a mode where all 16 colors can be used for the background, so all four bits of the background color are actually used.

PRELOAD_WINSOCK
PRELOAD_WINSOCK

在 MS-Windows 上,如果设置此变量,Emacs 将在启动时加载并初始化网络库,而不是等到第一次需要时才加载和初始化。

On MS-Windows, if you set this variable, Emacs will load and initialize the network library at startup, instead of waiting until the first time it is required.

WAYLAND_DISPLAY
WAYLAND_DISPLAY

Pgtk Emacs(使用--with-pgtk)可以在 Wayland 上本地运行。 WAYLAND_DISPLAY指定与合成器的连接。

Pgtk Emacs (built with --with-pgtk) can run on Wayland natively. WAYLAND_DISPLAY specifies the connection to the compositor.

emacs_dir
emacs_dir

在 MS-Windows 上,emacs_dir是一个特殊的环境变量,它指示 Emacs 安装目录的完整路径。如果 Emacs 安装在标准目录结构中,它会自动计算该值。除非您的安装是非标准的,否则您自己设置此变量并没有多大用处,因为与其他环境变量不同,它会在启动时被 Emacs 覆盖。设置其他环境变量(例如 )时 EMACSLOADPATH,您可能会发现使用绝对emacs_dir 路径而不是硬编码绝对路径很有用。这允许 Emacs 的多个版本共享相同的环境变量设置,并且允许您移动 Emacs 安装目录,而无需更改任何环境或注册表设置。

On MS-Windows, emacs_dir is a special environment variable, which indicates the full path of the directory in which Emacs is installed. If Emacs is installed in the standard directory structure, it calculates this value automatically. It is not much use setting this variable yourself unless your installation is non-standard, since unlike other environment variables, it will be overridden by Emacs at startup. When setting other environment variables, such as EMACSLOADPATH, you may find it useful to use emacs_dir rather than hard-coding an absolute path. This allows multiple versions of Emacs to share the same environment variable settings, and it allows you to move the Emacs installation directory, without changing any environment or registry settings.


C.4.3 MS-Windows 系统注册表

C.4.3 The MS-Windows System Registry

在 MS-Windows 上,环境变量emacs_dir, EMACSLOADPATH, EMACSDATA, EMACSPATH, , EMACSDOC, SHELL, TERM, HOME,LANGPRELOAD_WINSOCK也可以在HKEY_CURRENT_USER 或者HKEY_LOCAL_MACHINE系统注册表部分,在/软件/GNU/Emacs钥匙。当 Emacs 启动时,除了检查环境之外,它还会检查系统注册表中的这些变量。

On MS-Windows, the environment variables emacs_dir, EMACSLOADPATH, EMACSDATA, EMACSPATH, EMACSDOC, SHELL, TERM, HOME, LANG, and PRELOAD_WINSOCK can also be set in the HKEY_CURRENT_USER or the HKEY_LOCAL_MACHINE section of the system registry, under the /Software/GNU/Emacs key. When Emacs starts, as well as checking the environment, it also checks the system registry for those variables.

为了确定这些变量的值,Emacs 执行以下过程。首先,它检查环境。如果在那里找不到该变量,Emacs 会根据该变量的名称查找注册表项/软件/GNU/Emacs;首先在 HKEY_CURRENT_USER注册表部分,如果没有找到,则在HKEY_LOCAL_MACHINE部分。最后,如果 Emacs 仍然无法确定这些值,它将使用编译后的默认值。

To determine the value of those variables, Emacs goes through the following procedure. First, it checks the environment. If the variable is not found there, Emacs looks for a registry key by the name of the variable under /Software/GNU/Emacs; first in the HKEY_CURRENT_USER section of the registry, and if not found there, in the HKEY_LOCAL_MACHINE section. Finally, if Emacs still cannot determine the values, it uses the compiled-in defaults.

请注意,注册表设置具有全局系统范围的影响:它们将影响系统上运行的所有 Emacs 会话。因此,如果您运行不同的 Emacs 版本,或者同时使用已安装和未安装的 Emacs 可执行文件,或者构建较新版本的 Emacs,注册表中的设置将导致它们全部使用相同的目录,这可能不是您想要的。因此,我们建议不要在注册表中设置这些变量。如果您的注册表中有此类设置,我们建议您将其删除。

Note that the registry settings have global system-wide effect: they will affect all Emacs sessions run on the system. Thus, if you run different Emacs versions, or use both installed and un-installed Emacs executables, or build newer versions of Emacs, the settings in the registry will cause all of them to use the same directories, which is probably not what you want. For this reason, we recommend against setting these variables in the registry. If you have such settings in the registry, we recommend that you remove them.

如果您运行 Emacs MS-Windows 安装程序 ,它将更新、、、 、、和变量addpm.exe的任何现有注册表设置,使其具有适合所安装的 Emacs 版本的值 。请注意,不会 创建任何不存在的注册表设置,它只会更新现有设置(这些设置很可能是从旧的 Emacs 安装继承的,以便它们与新安装的 Emacs 版本兼容。安装最新版本的 Emacs 时不再需要 运行,因此我们仅建议您在从旧版本升级并且由于某种原因无法从注册表中删除这些设置时才执行此操作。emacs_dirEMACSLOADPATHEMACSDATAEMACSPATHEMACSDOCSHELLTERMaddpm.exeaddpm.exeaddpm.exe

If you run the Emacs MS-Windows installation program addpm.exe, it will update any existing registry settings of the emacs_dir, EMACSLOADPATH, EMACSDATA, EMACSPATH, EMACSDOC, SHELL, and TERM variables to have the values suitable for the installed Emacs version with which addpm.exe came. Note that addpm.exe will not create any registry setting that didn’t exist, it will only update existing settings, which are most probably inherited from an old Emacs installation, so that they are compatible with the newly installed Emacs version. Running addpm.exe is no longer necessary when installing recent versions of Emacs, so we only recommend doing that if you are upgrading from an older version, and cannot remove these settings from the registry for some reason.

除了上面的环境变量之外,还可以添加设置/软件/GNU/Emacs用于指定 X 资源的注册表项(请参阅X 选项和资源)。大多数设置都可以在您的.X默认值文件可以从该注册表项设置。

In addition to the environment variables above, you can also add settings to the /Software/GNU/Emacs registry key to specify X resources (see X Options and Resources). Most of the settings you can specify in your .Xdefaults file can be set from that registry key.


C.5 指定显示名称

C.5 Specifying the Display Name

环境变量DISPLAY告诉所有 X 客户端(包括 Emacs)在哪里显示其窗口。在一般情况下,当您启动 X 服务器并在本地运行作业时,它的值是默认设置的。您可以自己指定显示;这样做的一个原因是如果您想登录到另一个系统并在那里运行 Emacs,并在本地终端上显示该窗口。

The environment variable DISPLAY tells all X clients, including Emacs, where to display their windows. Its value is set by default in ordinary circumstances, when you start an X server and run jobs locally. You can specify the display yourself; one reason to do this is if you want to log into another system and run Emacs there, and have the window displayed at your local terminal.

DISPLAY具有语法 '主持人展示屏幕',其中host是 X Window 系统服务器计算机的主机名,display是任意分配的数字,用于将您的服务器(X 终端)与同一计算机上的其他服务器区分开来,screen是一个允许 X 服务器控制多个终端屏幕。句点和屏幕字段是可选的。如果包含, 屏幕通常为零。

DISPLAY has the syntax ‘host:display.screen’, where host is the host name of the X Window System server machine, display is an arbitrarily-assigned number that distinguishes your server (X terminal) from other servers on the same machine, and screen is a field that allows an X server to control multiple terminal screens. The period and the screen field are optional. If included, screen is usually zero.

例如,如果您的主机名为“格拉斯珀勒' 并且您的服务器是配置中列出的第一个(或者可能是唯一的)服务器,您的服务器 DISPLAY是 '格拉斯佩尔:0.0'。

For example, if your host is named ‘glasperle’ and your server is the first (or perhaps the only) server listed in the configuration, your DISPLAY is ‘glasperle:0.0’.

您可以在运行 Emacs 时显式指定显示名称,方法是更改​​变量DISPLAY或使用选项 '-d 显示' 或者 '--显示=显示'。这是一个例子:

You can specify the display name explicitly when you run Emacs, either by changing the DISPLAY variable, or with the option ‘-d display’ or ‘--display=display’. Here is an example:

emacs --display=glasperle:0 &
emacs --display=glasperle:0 &

您可以使用 ' 来禁止使用 X 窗口系统-西北' 选项。然后 Emacs 使用其控制文本终端进行显示。请参阅初始选项

You can inhibit the use of the X window system with the ‘-nw’ option. Then Emacs uses its controlling text terminal for display. See Initial Options.

有时,安全措施会阻止远程系统上的程序在本地系统上显示。在这种情况下,尝试运行 Emacs 会产生如下消息:

Sometimes, security arrangements prevent a program on a remote system from displaying on your local system. In this case, trying to run Emacs produces messages like this:

Xlib:服务器拒绝连接到“glasperle:0.0”
Xlib:  connection to "glasperle:0.0" refused by server

您可以通过xhost 在本地系统上使用命令授予远程计算机的访问权限来解决此问题。

You might be able to overcome this problem by using the xhost command on the local system to give permission for access from your remote machine.


C.6 字体规范选项

C.6 Font Specification Options

您可以使用命令行选项'-fn字体' (或者 '--字体',这是 ' 的别名-fn') 指定默认字体:

You can use the command line option ‘-fn font’ (or ‘--font’, which is an alias for ‘-fn’) to specify a default font:

'-fn字体'
-fn font
'--font=字体'
--font=font

使用字体作为默认字体。

Use font as the default font.

当在命令行上将字体名称传递给 Emacs 时,如果它包含 shell 特殊处理的字符(例如空格),您可能需要将其用引号引起来。例如:

When passing a font name to Emacs on the command line, you may need to quote it, by enclosing it in quotation marks, if it contains characters that the shell treats specially (e.g., spaces). For example:

emacs -fn "DejaVu Sans Mono-12"
emacs -fn "DejaVu Sans Mono-12"

有关字体名称和指定默认字体的其他方法的详细信息, 请参阅字体。

See Fonts, for details about font names and other ways to specify the default font.


C.7 窗口颜色选项

C.7 Window Color Options

您可以使用以下命令行选项来指定 Emacs 显示的各个部分使用的颜色。可以使用颜色名称或 RGB 三元组来指定颜色(请参阅面的颜色)。

You can use the following command-line options to specify the colors to use for various parts of the Emacs display. Colors may be specified using either color names or RGB triplets (see Colors for Faces).

'-fg颜色'
-fg color
'--前景色=颜色'
--foreground-color=color

指定前景色,覆盖由 default面指定的颜色(请参阅文本面)。

Specify the foreground color, overriding the color specified by the default face (see Text Faces).

'-背景颜色'
-bg color
'--背景颜色=颜色'
--background-color=color

指定背景颜色,覆盖面部指定的颜色 default

Specify the background color, overriding the color specified by the default face.

'-bd颜色'
-bd color
'--边框颜色=颜色'
--border-color=color

指定 X 窗口边框的颜色。如果 Emacs 是使用 GTK+ 支持编译的,则这不会产生任何影响。

Specify the color of the border of the X window. This has no effect if Emacs is compiled with GTK+ support.

'-cr颜色'
-cr color
'--光标颜色=颜色'
--cursor-color=color

指定 Emacs 光标的颜色,指示点所在的位置。

Specify the color of the Emacs cursor which indicates where point is.

'-ms颜色'
-ms color
'--鼠标颜色=颜色'
--mouse-color=color

指定鼠标位于 Emacs 窗口中时鼠标光标的颜色。

Specify the color for the mouse cursor when the mouse is in the Emacs window.

'-r'
-r
'-rv'
-rv
'--反向视频'
--reverse-video

反转视频:交换前景色和背景色。

Reverse video: swap the foreground and background colors.

'--颜色=模式'
--color=mode

设置Emacs 在文本终端上运行时的颜色支持模式termcap。此选项会覆盖字符终端在其数据库中公布的支持颜色的数量terminfo 。参数模式可以是以下之一:

'绝不'
''

即使终端的功能指定颜色支持,也不要使用颜色。

'默认'
'汽车'

和当时一样- 颜色根本不使用:Emacs 在启动时检测终端是否支持颜色,如果支持,则打开彩色显示。

'总是'
'是的'
'ANSI8'

无条件打开颜色支持,并对 8 种标准颜色使用 ANSI 转义序列指定的颜色命令。

'编号'

对num种颜色使用颜色模式。如果num为 -1,则关闭颜色支持(相当于 '绝不');如果为 0,则使用该终端的默认颜色支持(相当于 '汽车');否则对num颜色使用适当的标准模式。根据您终端的功能,Emacs 可能能够打开 8、16、88 或 256 的颜色模式作为num的值。如果没有支持num颜色的模式,Emacs 的行为就好像 num为 0,即,它使用终端的默认颜色支持模式。

如果省略mode ,则默认为ansi8

Set the color support mode when Emacs is run on a text terminal. This option overrides the number of supported colors that the character terminal advertises in its termcap or terminfo database. The parameter mode can be one of the following:

never
no

Don’t use colors even if the terminal’s capabilities specify color support.

default
auto

Same as when --color is not used at all: Emacs detects at startup whether the terminal supports colors, and if it does, turns on colored display.

always
yes
ansi8

Turn on the color support unconditionally, and use color commands specified by the ANSI escape sequences for the 8 standard colors.

num

Use color mode for num colors. If num is −1, turn off color support (equivalent to ‘never’); if it is 0, use the default color support for this terminal (equivalent to ‘auto’); otherwise use an appropriate standard mode for num colors. Depending on your terminal’s capabilities, Emacs might be able to turn on a color mode for 8, 16, 88, or 256 as the value of num. If there is no mode that supports num colors, Emacs acts as if num were 0, i.e., it uses the terminal’s default color support mode.

If mode is omitted, it defaults to ansi8.

例如,要使用珊瑚色鼠标光标和石板蓝色文本光标,请输入:

For example, to use a coral mouse cursor and a slate blue text cursor, enter:

emacs -ms Coral -cr '石板蓝' &
emacs -ms coral -cr 'slate blue' &

您可以通过 ' 反转前景色和背景色-rv' 选项或使用 X 资源 '反向视频'。

You can reverse the foreground and background colors through the ‘-rv’ option or with the X resource ‘reverseVideo’.

这 '-fg','-bg', 和 '-rv' 选项在文本终端和图形显示器上起作用。

The ‘-fg’, ‘-bg’, and ‘-rv’ options function on text terminals as well as on graphical displays.


C.8 窗口大小和位置选项

C.8 Options for Window Size and Position

以下是用于指定初始 Emacs 框架的大小和位置的命令行选项列表:

Here is a list of the command-line options for specifying size and position of the initial Emacs frame:

'-g宽度x高度[{ +- } xoffset { +- } yoffset ]]'
-g widthxheight[{+-}xoffset{+-}yoffset]]
'--geometry=宽度x高度[{ +- } xoffset { +- } yoffset ]]'
--geometry=widthxheight[{+-}xoffset{+-}yoffset]]

指定尺寸宽度高度(以字符列和行为单位测量)以及位置xoffsetyoffset (以像素为单位测量)。 width和height参数适用于所有帧,而xoffsetyoffset适用于初始帧。

Specify the size width and height (measured in character columns and lines), and positions xoffset and yoffset (measured in pixels). The width and height parameters apply to all frames, whereas xoffset and yoffset only to the initial frame.

'-fs'
-fs
'- 全屏'
--fullscreen

指定宽度和高度应为屏幕的宽度和高度。通常不显示窗口管理器装饰。 (启动 Emacs 后,您可以使用 , 切换此状态F11toggle-frame-fullscreen

Specify that width and height should be that of the screen. Normally no window manager decorations are shown. (After starting Emacs, you can toggle this state using F11, toggle-frame-fullscreen.)

'-毫米'
-mm
'--最大化'
--maximized

指定 Emacs 框架应最大化。这通常意味着框架具有窗口管理器装饰。 (启动 Emacs 后,您可以使用 , 切换此状态M-F10toggle-frame-maximized

Specify that the Emacs frame should be maximized. This normally means that the frame has window manager decorations. (After starting Emacs, you can toggle this state using M-F10, toggle-frame-maximized.)

'-fh'
-fh
'--全高'
--fullheight

指定高度应该是屏幕的高度。

Specify that the height should be the height of the screen.

'-fw'
-fw
'- 全屏宽度'
--fullwidth

指定宽度应该是屏幕的宽度。

Specify that the width should be the width of the screen.

在里面 '- 几何学' 选项,表示加号或减号。xoffset前面的加号表示距屏幕左侧的距离;减号表示从右侧开始计数。yoffset前面的加号表示距屏幕顶部的距离,减号表示距屏幕底部的距离。xoffsetyoffset值本身可能是正数或负数,但这不会改变它们的含义,只会改变它们的方向。 {+-}

In the ‘--geometry’ option, {+-} means either a plus sign or a minus sign. A plus sign before xoffset means it is the distance from the left side of the screen; a minus sign means it counts from the right side. A plus sign before yoffset means it is the distance from the top of the screen, and a minus sign there indicates the distance from the bottom. The values xoffset and yoffset may themselves be positive or negative, but that doesn’t change their meaning, only their direction.

xtermEmacs 使用与解释几何相同的单位。宽度和高度以字符为单位测量,因此大字体会比小字体创建更大的框架。 (如果指定比例字体,Emacs 将使用其最大边界宽度作为宽度单位。)xoffset yoffset像素为单位进行测量。

Emacs uses the same units as xterm does to interpret the geometry. The width and height are measured in characters, so a large font creates a larger frame than a small font. (If you specify a proportional font, Emacs uses its maximum bounds width as the width unit.) The xoffset and yoffset are measured in pixels.

您不必指定几何规范中的所有字段。如果您省略xoffsetyoffset,窗口管理器将决定将 Emacs 框架放置在哪里,可能是通过让您用鼠标放置它来决定。例如, '164x55' 指定窗口宽 164 列,足以并排两个普通宽度窗口,高 55 行。

You do not have to specify all of the fields in the geometry specification. If you omit both xoffset and yoffset, the window manager decides where to put the Emacs frame, possibly by letting you place it with the mouse. For example, ‘164x55’ specifies a window 164 columns wide, enough for two ordinary width windows side by side, and 55 lines tall.

默认框架宽度为 80 个字符,默认高度为 35 到 40 行,具体取决于操作系统和窗口管理器。您可以省略宽度或高度,或两者都省略。如果您以整数开始几何图形,Emacs 会将其解释为宽度。如果你以 ' 开头X' 后跟一个整数,Emacs 将其解释为高度。因此, '81' 仅指定宽度; 'x45' 仅指定高度。

The default frame width is 80 characters and the default height is between 35 and 40 lines, depending on the OS and the window manager. You can omit either the width or the height or both. If you start the geometry with an integer, Emacs interprets it as the width. If you start with an ‘x’ followed by an integer, Emacs interprets it as the height. Thus, ‘81’ specifies just the width; ‘x45’ specifies just the height.

如果您以 ' 开始几何图形+' 或者 '-',这引入了偏移量,这意味着两个尺寸都被省略。因此, '-3' 仅指定xoffset。 (如果只给出一个偏移量,它始终是xoffset。) '+3-3' 指定xoffsetyoffset,将框架放置在屏幕左下角附近。

If you start the geometry with ‘+’ or ‘-’, that introduces an offset, which means both sizes are omitted. Thus, ‘-3’ specifies the xoffset only. (If you give just one offset, it is always xoffset.) ‘+3-3’ specifies both the xoffset and the yoffset, placing the frame near the bottom left of the screen.

您可以为 X 资源文件中的任何或所有字段指定默认值(请参阅X 资源),然后使用 ' 覆盖所选字段- 几何学' 选项。

You can specify a default for any or all of the fields in your X resource file (see X Resources), and then override selected fields with a ‘--geometry’ option.

由于模式线和回波区域占据帧的最后 2 行,因此初始文本窗口的高度比几何中指定的高度小 2。在 Emacs 的非 X-toolkit 版本中,菜单栏也占据指定编号的一行。但在 X 工具包版本中,菜单栏是附加的,并且不计入指定的高度。工具栏(如果有)也是附加的。

Since the mode line and the echo area occupy the last 2 lines of the frame, the height of the initial text window is 2 less than the height specified in your geometry. In non-X-toolkit versions of Emacs, the menu bar also takes one line of the specified number. But in the X toolkit version, the menu bar is additional and does not count against the specified height. The tool bar, if present, is also additional.

启用或禁用菜单栏或工具栏会改变普通文本的可用空间量。因此,如果 Emacs 启动时有一个工具栏(这是默认的),并假设有一个工具栏来处理几何规范,然后你的初始化文件禁用了工具栏,那么你最终会得到一个与实际框架几何形状不同的框架几何形状。你要求的。要获得没有工具栏的预期大小,请使用 X 资源指定“无工具栏”(请参阅​​ Emacs 的 X 资源表);那么 Emacs 在处理指定的几何图形时就已经知道没有工具栏了。

Enabling or disabling the menu bar or tool bar alters the amount of space available for ordinary text. Therefore, if Emacs starts up with a tool bar (which is the default), and handles the geometry specification assuming there is a tool bar, and then your initialization file disables the tool bar, you will end up with a frame geometry different from what you asked for. To get the intended size with no tool bar, use an X resource to specify “no tool bar” (see Table of X Resources for Emacs); then Emacs will already know there’s no tool bar when it processes the specified geometry.

当使用其中之一时- 全屏','--最大化','- 全屏宽度' 或者 '--全高',某些窗口管理器要求您将变量设置frame-resize-pixelwise为非值,nil 以使框架真正最大化或全屏显示。

When using one of ‘--fullscreen’, ‘--maximized’, ‘--fullwidth’ or ‘--fullheight’, some window managers require you to set the variable frame-resize-pixelwise to a non-nil value to make a frame appear truly maximized or full-screen.

某些窗口管理器具有可以使它们忽略程序指定的位置和用户指定的位置的选项。如果设置了这些,Emacs 将无法正确定位窗口。

Some window managers have options that can make them ignore both program-specified and user-specified positions. If these are set, Emacs fails to position the window correctly.


C.9 内部和外部边界

C.9 Internal and Outer Borders

Emacs 框架有一个内部边框和一个外部边框。内部边框是框架文本部分周围背景颜色的额外条带。 Emacs 自己绘制内部边框。外边框由 X 在框架的工具栏和菜单栏之外绘制。还有一个由窗口管理器绘制的外部边框。外部边框的大小无法在 Emacs 内设置。

An Emacs frame has an internal border and an outer border. The internal border is an extra strip of the background color around the text portion of the frame. Emacs itself draws the internal border. The outer border is drawn by X outside the tool and menu bars of the frame. There is also an external border which is drawn by the window manager. The size of the external border cannot be set from within Emacs.

'-ib宽度'
-ib width
'--内部边框=宽度'
--internal-border=width

将宽度指定为内部边框(框架文本区域周围)的宽度,以像素为单位。

Specify width as the width of the internal border (around the frame’s text area), in pixels.

'-bw宽度'
-bw width
'--边框宽度=宽度'
--border-width=width

将width指定为外边框的宽度(以像素为单位)。

Specify width as the width of the outer border, in pixels.

当您指定框架的大小时,不会计算边框。框架的位置是从外部边框的外边缘开始测量的。

When you specify the size of the frame, that does not count the borders. The frame’s position is measured from the outside edge of the external border.

使用 '-ib n' 选项指定 n像素宽的内部边框。默认值为 1。使用 '-bwn' 指定外边框的宽度(尽管窗口管理器可能不会注意您指定的内容)。外边框的默认宽度为 2。

Use the ‘-ib n’ option to specify an internal border n pixels wide. The default is 1. Use ‘-bw n’ to specify the width of the outer border (though the window manager may not pay attention to what you specify). The default width of the outer border is 2.


C.10 框架标题

C.10 Frame Titles

每个 Emacs 框架始终有一个标题,它作为框架的名称出现在窗口装饰和图标中。默认标题的形式为 '调用名称@机器'(如果只有一帧)或显示所选窗口的缓冲区名称(如果有多于一帧)。

Each Emacs frame always has a title, which appears in window decorations and icons as the name of the frame. The default title is of the form ‘invocation-name@machine’ (if there is only one frame) or shows the selected window’s buffer name (if there is more than one frame).

您可以使用命令行选项为初始 Emacs 框架指定非默认标题:

You can specify a non-default title for the initial Emacs frame with a command line option:

'-T标题'
-T title
'--标题=标题'
--title=title

指定title作为初始 Emacs 框架的标题。

Specify title as the title for the initial Emacs frame.

这 '- 姓名' 选项(参见X Resources)还指定初始 Emacs 框架的标题。

The ‘--name’ option (see X Resources) also specifies the title for the initial Emacs frame.


C.11 图标

C.11 Icons

'-标志性的'
-iconic
'--标志性的'
--iconic

以图标化状态启动 Emacs。

Start Emacs in an iconified state.

'-nbi'
-nbi
'--无位图图标'
--no-bitmap-icon

禁用 Emacs 图标的使用。

Disable the use of the Emacs icon.

大多数窗口管理器允许您图标化(或“最小化”)Emacs 框架,将其隐藏起来。一些窗口管理器用小图标替换图标化窗口,而另一些窗口管理器则将它们完全从视线中删除。这 '-标志性的' 选项告诉 Emacs 开始以图标化状态运行,而不是立即显示框架。文本框架只有在取消图标化(或“取消最小化”)后才会出现。

Most window managers allow you to iconify (or “minimize”) an Emacs frame, hiding it from sight. Some window managers replace iconified windows with tiny icons, while others remove them entirely from sight. The ‘-iconic’ option tells Emacs to begin running in an iconified state, rather than showing a frame right away. The text frame doesn’t appear until you deiconify (or “un-minimize”) it.

默认情况下,Emacs 使用包含 Emacs 徽标的图标。在 Gnome 等桌面环境中,此图标也会在其他上下文中显示,例如,当切换到 Emacs 框架时。这 '-nbi' 或者 '--无位图图标' 选项告诉 Emacs 让窗口管理器选择要使用的图标类型 - 通常只是一个包含框架标题的小矩形。

By default, Emacs uses an icon containing the Emacs logo. On desktop environments such as Gnome, this icon is also displayed in other contexts, e.g., when switching into an Emacs frame. The ‘-nbi’ or ‘--no-bitmap-icon’ option tells Emacs to let the window manager choose what sort of icon to use—usually just a small rectangle containing the frame’s title.


C.12 其他显示选项

C.12 Other Display Options

'--parent-id id'
--parent-id id

通过 XEmbed 协议将 Emacs 作为客户端 X 窗口打开,id 作为父 X 窗口 id。目前,此选项主要对开发人员有用。

Open Emacs as a client X window via the XEmbed protocol, with id as the parent X window id. Currently, this option is mainly useful for developers.

'-VB'
-vb
'--垂直滚动条'
--vertical-scroll-bars

启用垂直滚动条。

Enable vertical scroll bars.

'-lsp像素'
-lsp pixels
'--行距=像素'
--line-spacing=pixels

将像素指定为在行之间放置的附加空间(以像素为单位)。

Specify pixels as additional space to put between lines, in pixels.

'-全国广播公司'
-nbc
'--不闪烁光标'
--no-blinking-cursor

禁用图形显示上闪烁的光标。

Disable the blinking cursor on graphical displays.

'-D'
-D
'--基本显示'
--basic-display

禁用菜单栏、工具栏、滚动条、工具提示,并关闭字体锁定模式和闪烁光标。这对于制作简化显示问题调试的测试用例很有用。

Disable the menu-bar, the tool-bar, the scroll-bars, tool tips, and turn off font-lock-mode and the blinking cursor. This can be useful for making a test case that simplifies debugging of display problems.

这 '--xrm' 选项(请参阅X 资源)指定附加的 X 资源值。

The ‘--xrm’ option (see X Resources) specifies additional X resource values.


附录 DX 选项和资源

Appendix D X Options and Resources

您可以使用 X 资源自定义 Emacs 行为的一些与 X 相关的方面,就像使用 X 的程序一样。

You can customize some X-related aspects of Emacs behavior using X resources, as is usual for programs that use X.

当 Emacs 编译为支持 GTK+ 时,各种图形小部件(例如菜单栏、滚动条和对话框)的外观由 GTK+ 资源决定,我们也将对此进行描述。当 Emacs 在没有 GTK+ 支持的情况下构建时,这些小部件的外观由额外的 X 资源决定。

When Emacs is compiled with GTK+ support, the appearance of various graphical widgets, such as the menu-bar, scroll-bar, and dialog boxes, is determined by GTK+ resources, which we will also describe. When Emacs is built without GTK+ support, the appearance of these widgets is determined by additional X resources.

在 MS-Windows 上,您可以使用系统注册表自定义一些相同的方面(请参阅MS-Windows 系统注册表)。

On MS-Windows, you can customize some of the same aspects using the system registry (see The MS-Windows System Registry).


D.1 X 资源

D.1 X Resources

在 X Window 系统下运行的程序在类和资源的层次结构下组织其用户选项。您可以在X 资源文件中指定这些选项的默认值,通常命名为~/.Xdefaults或者~/.Xresources。该文件中的更改不会立即生效,因为 X 服务器存储自己的资源列表;要更新它,请使用命令 xrdb- 例如,'xrdb ~/.Xdefaults'。

Programs running under the X Window System organize their user options under a hierarchy of classes and resources. You can specify default values for these options in your X resource file, usually named ~/.Xdefaults or ~/.Xresources. Changes in this file do not take effect immediately, because the X server stores its own list of resources; to update it, use the command xrdb—for instance, ‘xrdb ~/.Xdefaults’.

通过 X 资源指定的设置通常会覆盖 Emacs 初始化文件中的等效设置(请参阅Emacs 初始化文件),特别是初始框架的参数(请参阅框架参数)。

Settings specified via X resources in general override the equivalent settings in Emacs init files (see The Emacs Initialization File), in particular for parameters of the initial frame (see Frame Parameters).

(MS-Windows 系统不支持 X 资源文件;在此类系统上,Emacs 在 Windows 注册表中查找 X 资源,首先在键 'HKEY_CURRENT_USER\SOFTWARE\GNU\Emacs',它仅影响当前用户并覆盖系统范围的设置,然后在键 'HKEY_LOCAL_MACHINE\SOFTWARE\GNU\Emacs',这会影响系统的所有用户。菜单和滚动条是 MS-Windows 上的本机小部件,因此只能通过显示控制面板中的系统范围设置来自定义它们。您还可以使用 '-xrm' 命令行选项,如下所述。)

(MS-Windows systems do not support X resource files; on such systems, Emacs looks for X resources in the Windows Registry, first under the key ‘HKEY_CURRENT_USER\SOFTWARE\GNU\Emacs’, which affects only the current user and override the system-wide settings, and then under the key ‘HKEY_LOCAL_MACHINE\SOFTWARE\GNU\Emacs’, which affects all users of the system. The menu and scroll bars are native widgets on MS-Windows, so they are only customizable via the system-wide settings in the Display Control Panel. You can also set resources using the ‘-xrm’ command line option, as explained below.)

X 资源文件中的每一行指定一个选项或一组相关选项的值。行在文件中出现的顺序并不重要。每个资源规范由程序名称资源名称组成。每个名称的大小写区别都很重要。这是一个例子:

Each line in the X resource file specifies a value for one option or for a collection of related options. The order in which the lines appear in the file does not matter. Each resource specification consists of a program name and a resource name. Case distinctions are significant in each of these names. Here is an example:

emacs.cursorColor:深绿色
emacs.cursorColor: dark green

程序名称是资源应用到的可执行文件的名称。对于 Emacs,这通常是 'emacs'。要指定适用于 Emacs 所有实例的定义,无论 Emacs 可执行文件的名称如何,请使用 'Emacs'。

The program name is the name of the executable file to which the resource applies. For Emacs, this is normally ‘emacs’. To specify a definition that applies to all instances of Emacs, regardless of the name of the Emacs executable, use ‘Emacs’.

资源名称是程序设置的名称。例如,Emacs 识别 '光标颜色' 控制文本光标颜色的资源。

The resource name is the name of a program setting. For instance, Emacs recognizes a ‘cursorColor’ resource that controls the color of the text cursor.

资源被分组为命名的类。例如,'前景' 类包含 '光标颜色','前景' 和 '指针颜色' 资源(请参阅Emacs 的 X 资源表)。您可以使用类名来指定该类中所有资源的默认值,而不是使用资源名称,如下所示:

Resources are grouped into named classes. For instance, the ‘Foreground’ class contains the ‘cursorColor’, ‘foreground’ and ‘pointerColor’ resources (see Table of X Resources for Emacs). Instead of using a resource name, you can use a class name to specify the default value for all resources in that class, like this:

emacs.前景:深绿色
emacs.Foreground: dark green

inhibit-x-resources如果您将变量设置为非值, Emacs 根本不会处理 X 资源 nil。如果您使用 ' 调用 Emacs-Q' (或者 '- 快的') 命令行选项 inhibit-x-resources会自动设置为t (请参阅初始选项)。

Emacs does not process X resources at all if you set the variable inhibit-x-resources to a non-nil value. If you invoke Emacs with the ‘-Q’ (or ‘--quick’) command-line option, inhibit-x-resources is automatically set to t (see Initial Options).

此外,您可以使用以下命令行选项来覆盖 X 资源文件:

In addition, you can use the following command-line options to override the X resources file:

'- 姓名姓名'
-name name
'--名称=名称'
--name=name

该选项将初始 Emacs 框架的程序名称设置为 name。它还将初始帧的标题设置为 name。该选项不会影响后续帧。

如果不指定此选项,则默认使用 Emacs 可执行文件的名称作为程序名称。

为了保持一致性,'-姓名' 还指定用于不属于任何特定框架的其他资源值的名称。

命名 Emacs 调用的资源也属于一个名为 'Emacs'。如果你写'Emacs' 代替 'emacs',该资源适用于所有 Emacs 作业中的所有框架,无论框架标题如何,也无论可执行文件的名称如何。

This option sets the program name of the initial Emacs frame to name. It also sets the title of the initial frame to name. This option does not affect subsequent frames.

If you don’t specify this option, the default is to use the Emacs executable’s name as the program name.

For consistency, ‘-name’ also specifies the name to use for other resource values that do not belong to any particular frame.

The resources that name Emacs invocations also belong to a class, named ‘Emacs’. If you write ‘Emacs’ instead of ‘emacs’, the resource applies to all frames in all Emacs jobs, regardless of frame titles and regardless of the name of the executable file.

'-xrm资源值'
-xrm resource-value
'--xrm=资源值'
--xrm=resource-value

该选项指定当前 Emacs 作业的 X 资源值。

资源值的格式应与您在 X 资源文件中使用的格式相同。一些 '-xrm' 选项可以包含多个资源规范。您还可以使用 '#include“文件名' 作为资源值来包含完整的资源规范文件。用 ' 指定的资源值-xrm' 优先于所有其他资源规范。

This option specifies X resource values for the present Emacs job.

resource-value should have the same format that you would use inside a file of X resources. Several ‘-xrm’ options are possible to include multiple resource specifications. You can also use ‘#include "filename"’ as resource-value to include a file full of resource specifications. Resource values specified with ‘-xrm’ take precedence over all other resource specifications.


D.2 Emacs 的 X 资源表

D.2 Table of X Resources for Emacs

下表列出了 Emacs 识别的 X 资源名称。请注意,某些资源在使用各种 X 工具包(GTK+、Lucid 等)编译的 Emacs 中不起作用 — 我们会在下面指出这种情况。

The table below lists the X resource names that Emacs recognizes. Note that some of the resources have no effect in Emacs compiled with various X toolkits (GTK+, Lucid, etc.)—we indicate below when this is the case.

alpha(班级Alpha
alpha (class Alpha)

设置 'α' 框架参数,确定框架透明度(请参阅Emacs Lisp 参考手册中的框架参数)。

Sets the ‘alpha’ frame parameter, determining frame transparency (see Frame Parameters in The Emacs Lisp Reference Manual).

alphaBackground(班级AlphaBackground
alphaBackground (class AlphaBackground)

设置 '阿尔法背景' 框架参数,确定背景透明度(请参阅Emacs Lisp 参考手册中的框架参数)。

Sets the ‘alpha-background’ frame parameter, determining background transparency (see Frame Parameters in The Emacs Lisp Reference Manual).

background(班级Background
background (class Background)

背景颜色(请参阅面部颜色)。

Background color (see Colors for Faces).

bitmapIcon(班级BitmapIcon
bitmapIcon (class BitmapIcon)

告诉窗口管理器显示 Emacs 图标,如果 '';不要这样做,如果 '离开'。有关图标的说明, 请参阅图标。

Tell the window manager to display the Emacs icon if ‘on’; don’t do so if ‘off’. See Icons, for a description of the icon.

borderColor(班级BorderColor
borderColor (class BorderColor)

框架外边框的颜色。如果 Emacs 是使用 GTK+ 支持编译的,则这不会产生任何影响。

Color of the frame’s external border. This has no effect if Emacs is compiled with GTK+ support.

borderWidth(班级BorderWidth
borderWidth (class BorderWidth)

框架外部边框的宽度(以像素为单位)。如果 Emacs 是使用 GTK+ 支持编译的,则这不会产生任何影响。

Width of the frame’s external border, in pixels. This has no effect if Emacs is compiled with GTK+ support.

cursorBlink(班级CursorBlink
cursorBlink (class CursorBlink)

如果该资源的值为 '离开' 或者 '错误的' 或者 '0' 在启动时,Emacs 禁用闪烁光标模式(请参阅显示光标)。

If the value of this resource is ‘off’ or ‘false’ or ‘0’ at startup, Emacs disables Blink Cursor mode (see Displaying the Cursor).

cursorColor(班级Foreground
cursorColor (class Foreground)

文本光标颜色。如果在 Emacs 启动时指定了此资源,Emacs 会将其值设置为cursor 面的背景颜色(请参阅Text Faces)。

Text cursor color. If this resource is specified when Emacs starts up, Emacs sets its value as the background color of the cursor face (see Text Faces).

font(班级Font
font (class Font)

脸部的字体名称default(请参阅字体)。您还可以指定字体集名称(请参阅字体集)。

Font name for the default face (see Fonts). You can also specify a fontset name (see Fontsets).

fontBackend(班级FontBackend
fontBackend (class FontBackend)

用于绘制字体的后端的逗号分隔列表(按优先顺序排列)。例如,值 'x,xft' 告诉 Emacs 使用 X 核心字体驱动程序绘制字体,如果失败,则使用 Xft 字体驱动程序。通常,您应该不设置此资源,在这种情况下,Emacs 会尝试使用所有可用的字体后端。

Comma-delimited list of backend(s) to use for drawing fonts, in order of precedence. For instance, the value ‘x,xft’ tells Emacs to draw fonts using the X core font driver, falling back on the Xft font driver if that fails. Normally, you should leave this resource unset, in which case Emacs tries using all available font backends.

foreground(班级Foreground
foreground (class Foreground)

文本的默认前景色。

Default foreground color for text.

fullscreen(班级Fullscreen
fullscreen (class Fullscreen)

所需的全屏尺寸。该值可以是fullbothmaximizedfullwidth或之一fullheight,对应于命令行选项 '-fs','-毫米','-fw', 和 '-fh'(请参阅窗口大小和位置选项)。请注意,这仅适用于初始帧。

The desired fullscreen size. The value can be one of fullboth, maximized, fullwidth or fullheight, which correspond to the command-line options ‘-fs’, ‘-mm’, ‘-fw’, and ‘-fh’ (see Options for Window Size and Position). Note that this applies to the initial frame only.

geometry(班级Geometry
geometry (class Geometry)

窗口大小和位置。该值应该是大小和位置规范,其形式与 '-G' 或者 '- 几何学' 命令行选项(请参阅窗口大小和位置选项)。

该大小适用于 Emacs 会话中的所有框架,但该位置仅适用于初始 Emacs 框架(或者,对于特定框架名称的资源,仅适用于该框架)。

请注意不要将此资源指定为 'emacs*几何',因为这可能会影响各个菜单以及 Emacs 主框架。

Window size and position. The value should be a size and position specification, of the same form as in the ‘-g’ or ‘--geometry’ command-line option (see Options for Window Size and Position).

The size applies to all frames in the Emacs session, but the position applies only to the initial Emacs frame (or, in the case of a resource for a specific frame name, only that frame).

Be careful not to specify this resource as ‘emacs*geometry’, as that may affect individual menus as well as the main Emacs frame.

horizontalScrollBars(班级ScrollBars
horizontalScrollBars (class ScrollBars)

如果该资源的值为 '离开' 或者 '错误的' 或者 '0',Emacs 在启动时禁用水平滚动条模式(请参阅滚动条)。

If the value of this resource is ‘off’ or ‘false’ or ‘0’, Emacs disables Horizontal Scroll Bar mode at startup (see Scroll Bars).

iconName(班级Title
iconName (class Title)

要在图标中显示的名称。

Name to display in the icon.

internalBorder(班级BorderWidth
internalBorder (class BorderWidth)

内部框架边框的宽度,以像素为单位。

Width of the internal frame border, in pixels.

lineSpacing(班级LineSpacing
lineSpacing (class LineSpacing)

行之间的额外空间(以像素为单位)。

Additional space between lines, in pixels.

menuBackground(班级Background
menuBackground (class Background)

非工具包版本的 Emacs 中菜单的背景颜色。 (有关工具包版本,请参阅Lucid Menu And Dialog X Resources,另请参阅Motif Menu X Resources,并参阅GTK+ resources。)

The background color of the menus in non-toolkit versions of Emacs. (For toolkit versions, see Lucid Menu And Dialog X Resources, also see Motif Menu X Resources, and see GTK+ resources.)

menuBar(班级MenuBar
menuBar (class MenuBar)

如果该资源的值为 '离开' 或者 '错误的' 或者 '0',Emacs 在启动时禁用菜单栏模式(请参阅菜单栏)。

If the value of this resource is ‘off’ or ‘false’ or ‘0’, Emacs disables Menu Bar mode at startup (see Menu Bars).

minibuffer(班级Minibuffer
minibuffer (class Minibuffer)

如果 '没有任何', Emacs 不会在此帧中创建迷你缓冲区;它将使用一个单独的迷你缓冲区帧来代替。

If ‘none’, Emacs will not make a minibuffer in this frame; it will use a separate minibuffer frame instead.

paneFont(班级Font
paneFont (class Font)

在非工具包版本的 Emacs 中,菜单窗格标题的字体名称。 (有关工具包版本,请参阅Lucid Menu And Dialog X Resources,另请参阅Motif Menu X Resources,并参阅GTK+ resources。)

Font name for menu pane titles, in non-toolkit versions of Emacs. (For toolkit versions, see Lucid Menu And Dialog X Resources, also see Motif Menu X Resources, and see GTK+ resources.)

paneForeground(班级Foreground
paneForeground (class Foreground)

在非工具包版本的 Emacs 中,菜单窗格标题的前景色。 (有关工具包版本,请参阅Lucid Menu And Dialog X Resources,另请参阅 Motif Menu X Resources,并参阅GTK+ resources。)

Foreground color for menu pane titles, in non-toolkit versions of Emacs. (For toolkit versions, see Lucid Menu And Dialog X Resources, also see Motif Menu X Resources, and see GTK+ resources.)

pointerColor(班级Foreground
pointerColor (class Foreground)

鼠标光标的颜色。这在许多图形桌面环境中没有效果,因为它们不允许 Emacs 以这种方式更改鼠标光标。

Color of the mouse cursor. This has no effect in many graphical desktop environments, as they do not let Emacs change the mouse cursor this way.

privateColormap(班级PrivateColormap
privateColormap (class PrivateColormap)

如果 '',在类 PseudoColor 和 Emacs 的默认视觉效果正在使用它的情况下,使用私有颜色图。

If ‘on’, use a private color map, in the case where the default visual of class PseudoColor and Emacs is using it.

reverseVideo(班级ReverseVideo
reverseVideo (class ReverseVideo)

切换前景色和背景默认颜色 if '',使用指定的颜色,如果 '离开'。

Switch foreground and background default colors if ‘on’, use colors as specified if ‘off’.

screenGamma(班级ScreenGamma
screenGamma (class ScreenGamma)

颜色的伽玛校正,相当于帧参数 screen-gamma

Gamma correction for colors, equivalent to the frame parameter screen-gamma.

scrollBar(班级ScrollBar
scrollBar (class ScrollBar)

如果该资源的值为 '离开' 或者 '错误的' 或者 '0',Emacs 在启动时禁用滚动条模式(请参阅滚动条)。

If the value of this resource is ‘off’ or ‘false’ or ‘0’, Emacs disables Scroll Bar mode at startup (see Scroll Bars).

scrollBarWidth(班级ScrollBarWidth
scrollBarWidth (class ScrollBarWidth)

滚动条宽度(以像素为单位),相当于frame参数 scroll-bar-width。如果 Emacs 是使用 GTK+ 支持编译的,请勿设置此资源。

The scroll bar width in pixels, equivalent to the frame parameter scroll-bar-width. Do not set this resource if Emacs is compiled with GTK+ support.

selectionFont(班级SelectionFont
selectionFont (class SelectionFont)

在非工具包版本的 Emacs 中,弹出菜单项的字体名称。 (有关工具包版本,请参阅Lucid Menu And Dialog X Resources,另请参阅Motif Menu X Resources,并参阅GTK+ resources。)

Font name for pop-up menu items, in non-toolkit versions of Emacs. (For toolkit versions, see Lucid Menu And Dialog X Resources, also see Motif Menu X Resources, and see GTK+ resources.)

selectionForeground(班级SelectionForeground
selectionForeground (class SelectionForeground)

在非工具包版本的 Emacs 中,弹出菜单项的前景色。 (有关工具包版本,请参阅Lucid Menu And Dialog X Resources,另请参阅 Motif Menu X Resources,并参阅GTK+ resources。)

Foreground color for pop-up menu items, in non-toolkit versions of Emacs. (For toolkit versions, see Lucid Menu And Dialog X Resources, also see Motif Menu X Resources, and see GTK+ resources.)

selectionTimeout(班级SelectionTimeout
selectionTimeout (class SelectionTimeout)

等待选择回复的毫秒数。如果选择所有者这次没有回复,我们就放弃。值 0 表示根据需要等待。

Number of milliseconds to wait for a selection reply. If the selection owner doesn’t reply in this time, we give up. A value of 0 means wait as long as necessary.

synchronous(班级Synchronous
synchronous (class Synchronous)

以同步模式运行 Emacs if ''。同步模式对于调试 X 问题很有用。

Run Emacs in synchronous mode if ‘on’. Synchronous mode is useful for debugging X problems.

title(班级Title
title (class Title)

显示在初始 Emacs 框架的标题栏中的名称。

Name to display in the title bar of the initial Emacs frame.

toolBar(班级ToolBar
toolBar (class ToolBar)

如果该资源的值为 '离开' 或者 '错误的' 或者 '0',Emacs 在启动时禁用工具栏模式(请参阅工具栏)。

If the value of this resource is ‘off’ or ‘false’ or ‘0’, Emacs disables Tool Bar mode at startup (see Tool Bars).

tabBar(班级TabBar
tabBar (class TabBar)

如果该资源的值为 '' 或者 '是的' 或者 '1',Emacs 在启动时启用选项卡栏模式(请参阅选项卡栏)。

If the value of this resource is ‘on’ or ‘yes’ or ‘1’, Emacs enables Tab Bar mode at startup (see Tab Bars).

useXIM(班级UseXIM
useXIM (class UseXIM)

禁用 X 输入法 (XIM) 如果 '错误的' 或者 '离开'。仅当您的 Emacs 是使用 XIM 支持构建的时,这才有意义。在缓慢的 X 客户端/服务器链接上关闭 XIM 可能很有用。

Disable use of X input methods (XIM) if ‘false’ or ‘off’. This is only relevant if your Emacs is built with XIM support. It might be useful to turn off XIM on slow X client/server links.

inputStyle(班级InputStyle
inputStyle (class InputStyle)

此资源控制如何显示 X 输入法生成的预览文本。它的值可以是以下之一:

'打回来'

显示当前缓冲区中预览文本的内容。

'场外'

在 Emacs 提供的显示的单独区域内显示预览文本。

'现场'

在当前窗口中的点位置的弹出窗口内显示预览文本。

'没有任何'

让输入法决定如何显示自己。这通常相当于 '现场',但它可能适用于更多输入法。

'本国的'

使用工具包处理输入法。目前仅在 GTK 上实现。

''

使用特定于输入法的显示器上的某个位置来显示预览文本。

This resource controls how preview text generated by X input methods is displayed. Its value can be on of the following:

callback

Display the contents of the preview text in the current buffer.

offthespot

Display the preview text inside a separate area of the display provided by Emacs.

overthespot

Display the preview text inside a popup window at the location of point in the current window.

none

Let the input method decide how to display itself. This is usually equivalent to ‘overthespot’, but it might work with more input methods.

native

Use the toolkit for handling input methods. This is currently implemented only on GTK.

root

Use some location on display specific to the input method for displaying the preview text.

synchronizeResize(班级SynchronizeResize
synchronizeResize (class SynchronizeResize)

如果 '离开' 或者 '错误的',Emacs 不会尝试告诉窗口管理器何时完成重绘显示以响应调整框架大小。否则,窗口管理器将推迟绘制刚刚调整大小的框架,直到更新其内容,这会阻止显示尚未绘制的框架的空白区域。如果设置为 '扩展',它将启用替代帧同步协议,某些不支持 Emacs 默认使用的协议的合成窗口管理器可能支持该协议,并导致 Emacs 在兼容的合成窗口时将显示与显示器刷新率同步管理器正在使用中。

If ‘off’ or ‘false’, Emacs will not try to tell the window manager when it has finished redrawing the display in response to a frame being resized. Otherwise, the window manager will postpone drawing a frame that was just resized until its contents are updated, which prevents blank areas of a frame that have not yet been painted from being displayed. If set to ‘extended’, it will enable use of an alternative frame synchronization protocol, which might be supported by some compositing window managers that don’t support the protocol Emacs uses by default, and causes Emacs to synchronize display with the monitor refresh rate when a compatible compositing window manager is in use.

verticalScrollBars(班级ScrollBars
verticalScrollBars (class ScrollBars)

如果 ' 则在左侧提供框架滚动条左边',在右边,如果 '正确的';没有滚动条如果 '离开'(参见滚动条)。

Give frames scroll bars on the left if ‘left’, on the right if ‘right’; don’t have scroll bars if ‘off’ (see Scroll Bars).

visualClass(班级VisualClass
visualClass (class VisualClass)

X 颜色显示的视觉类别。如果指定,该值应以 ' 之一开头本色','伪彩色','直接彩色','静态颜色','灰度', 和 '静态灰色', 其次是 '-深度',其中深度 是颜色平面的数量。

The visual class for X color display. If specified, the value should start with one of ‘TrueColor’, ‘PseudoColor’, ‘DirectColor’, ‘StaticColor’, ‘GrayScale’, and ‘StaticGray’, followed by ‘-depth’, where depth is the number of color planes.

您还可以使用 X 资源来自定义各个 Emacs 界面(请参阅文本界面)。例如,设置资源 '脸部.attributeForeground' 相当于自定义 '前景'脸的属性。但是,我们建议在 Emacs 中自定义面孔,而不是使用 X 资源。请参阅自定义面

You can also use X resources to customize individual Emacs faces (see Text Faces). For example, setting the resource ‘face.attributeForeground’ is equivalent to customizing the ‘foreground’ attribute of the face face. However, we recommend customizing faces from within Emacs, instead of using X resources. See Customizing Faces.


D.3 清晰菜单和对话框 X 资源

D.3 Lucid Menu And Dialog X Resources

如果 Emacs 是使用 Lucid 小部件与 X 工具包支持一起编译的,则可以使用 X 资源来自定义菜单栏(请参阅菜单栏)、弹出菜单和对话框(请参阅使用对话框)的外观。菜单栏的资源位于 '窗格菜单栏' 类(一如既往,后面是 Emacs 可执行文件的名称或 'Emacs' 对于所有 Emacs 调用)。弹出菜单的资源位于 '菜单*' 班级。对话框的资源位于 '对话*' 班级。

If Emacs is compiled with the X toolkit support using Lucid widgets, you can use X resources to customize the appearance of the menu bar (see The Menu Bar), pop-up menus, and dialog boxes (see Using Dialog Boxes). The resources for the menu bar fall in the ‘pane.menubar’ class (following, as always, either the name of the Emacs executable or ‘Emacs’ for all Emacs invocations). The resources for the pop-up menu are in the ‘menu*’ class. The resources for dialog boxes are in the ‘dialog*’ class.

例如,要显示带有 ' 的菜单栏条目快递12' 字体(参见Fonts),这样写:

For example, to display menu bar entries with the ‘Courier-12’ font (see Fonts), write this:

Emacs.pane.menubar.font:Courier-12
Emacs.pane.menubar.font: Courier-12

Lucid 小部件可以在您的语言环境中显示多语言文本。要启用此功能,请指定fontSet资源而不是font 资源。请参阅字体集。如果同时 指定了font和resources,则使用该资源。 fontSetfontSet

Lucid widgets can display multilingual text in your locale. To enable this, specify a fontSet resource instead of a font resource. See Fontsets. If both font and fontSet resources are specified, the fontSet resource is used.

以下是菜单栏、弹出菜单和对话框的资源列表:

Here is a list of resources for menu bars, pop-up menus, and dialogs:

font
font

菜单项文本的字体。

Font for menu item text.

fontSet
fontSet

菜单项文本的字体集。

Fontset for menu item text.

background
background

背景颜色。

Background color.

buttonForeground
buttonForeground

所选项目的前景色。

Foreground color for a selected item.

foreground
foreground

前景色。

Foreground color.

disabledForeground
disabledForeground

禁用菜单项的前景色。

Foreground color for a disabled menu item.

highlightForeground
highlightForeground

通过鼠标或按键导航突出显示的菜单项的前景色。

Foreground color for a menu item highlighted by the mouse or key navigation.

highlightBackground
highlightBackground

通过鼠标或按键导航突出显示的菜单项的背景颜色。

Background color for a menu item highlighted by the mouse or key navigation.

horizontalSpacing
horizontalSpacing

项目之间的水平间距(以像素为单位)。默认值为 3。

Horizontal spacing in pixels between items. Default is 3.

verticalSpacing
verticalSpacing

项目之间的垂直间距(以像素为单位)。默认值为 2。

Vertical spacing in pixels between items. Default is 2.

arrowSpacing
arrowSpacing

箭头(表示子菜单)和关联文本之间的水平间距。默认值为 10。

Horizontal spacing between the arrow (which indicates a submenu) and the associated text. Default is 10.

shadowThickness
shadowThickness

3D 按钮、箭头和其他图形元素的阴影线粗细。默认值为 1。

Thickness of shadow lines for 3D buttons, arrows, and other graphical elements. Default is 1.

borderThickness
borderThickness

菜单栏和弹出菜单的外部边框的厚度。默认值为 1。

Thickness of the external borders of the menu bars and pop-up menus. Default is 1.

cursor
cursor

在菜单栏和弹出菜单中使用的光标的名称。默认为"right_ptr".

Name of the cursor to use in the menu bars and pop-up menus. Default is "right_ptr".

margin
margin

菜单栏的边距(以字符为单位)。默认值为 1。

Margin of the menu bar, in characters. Default is 1.


D.4 主题菜单 X 资源

D.4 Motif Menu X Resources

如果 Emacs 是使用 Motif 或 LessTif 小部件使用 X 工具包支持进行编译的,则可以使用 X 资源来自定义菜单栏(请参阅菜单栏)、弹出菜单和对话框(请参阅使用对话框)的外观。然而,资源的组织方式与 Lucid 小部件不同。

If Emacs is compiled with the X toolkit support using Motif or LessTif widgets, you can use X resources to customize the appearance of the menu bar (see The Menu Bar), pop-up menus, and dialog boxes (see Using Dialog Boxes). However, the resources are organized differently from Lucid widgets.

菜单栏的资源名称位于 '窗格菜单栏' 类,并且它们必须以这种形式指定:

The resource names for the menu bar are in the ‘pane.menubar’ class, and they must be specified in this form:

Emacs.pane.menubar。子小部件资源价值
Emacs.pane.menubar.subwidget.resource: value

对于弹出菜单,资源位于 '菜单*' 类,而不是 '窗格菜单栏'。对于对话框,它们位于 '对话'。在每种情况下,每个单独的菜单字符串都是一个子小部件;子窗口小部件的名称与菜单项字符串相同。例如,'文件' 菜单栏中的菜单是一个名为 'emacs.pane.menubar.File'。

For pop-up menus, the resources are in the ‘menu*’ class, instead of ‘pane.menubar’. For dialog boxes, they are in ‘dialog’. In each case, each individual menu string is a subwidget; the subwidget’s name is the same as the menu item string. For example, the ‘File’ menu in the menu bar is a subwidget named ‘emacs.pane.menubar.File’.

通常,您希望为整个菜单栏指定相同的资源。为此,请使用 '*' 而不是特定的子小部件名称。例如,指定字体 '8x16' 对于所有菜单栏项(包括子菜单),请写下以下内容:

Typically, you want to specify the same resources for the whole menu bar. To do this, use ‘*’ instead of a specific subwidget name. For example, to specify the font ‘8x16’ for all menu bar items, including submenus, write this:

Emacs.pane.menubar.*.fontList: 8x16
Emacs.pane.menubar.*.fontList: 8x16

子菜单中的每个项目也有自己的 X 资源名称;例如,'文件' 子菜单有一个名为 '保存(当前缓冲区)'。子菜单项的资源规范如下所示:

Each item in a submenu also has its own name for X resources; for example, the ‘File’ submenu has an item named ‘Save (current buffer)’. A resource specification for a submenu item looks like this:

Emacs.pane.menubar.popup_*。菜单物品资源价值
Emacs.pane.menubar.popup_*.menu.item.resource: value

例如,以下是如何指定 '保存(当前缓冲区)' 物品:

For example, here’s how to specify the font for the ‘Save (current buffer)’ item:

Emacs.pane.menubar.popup_*.File.Save(当前缓冲区).fontList:8x16
Emacs.pane.menubar.popup_*.File.Save (current buffer).fontList: 8x16

对于二级子菜单中的项目,例如 '完整的单词' 在下面 '拼写检查' 在下面 '工具',资源适合此模板:

For an item in a second-level submenu, such as ‘Complete Word’ under ‘Spell Checking’ under ‘Tools’, the resource fits this template:

Emacs.pane.menubar.popup_*.popup_*。菜单资源价值
Emacs.pane.menubar.popup_*.popup_*.menu.resource: value

例如,

For example,

Emacs.pane.menubar.popup_*.popup_*.拼写检查.完整单词:
Emacs.pane.menubar.popup_*.popup_*.Spell Checking.Complete Word: value

(这应该是一根很长的线。)

(This should be one long line.)

如果您希望子菜单项看起来与菜单栏本身不同,则必须首先为所有子菜单项指定资源,然后单独覆盖子菜单的值。这是一个例子:

If you want the submenu items to look different from the menu bar itself, you must first specify the resource for all of them, then override the value for submenus alone. Here is an example:

Emacs.pane.menubar.*.fontList: 9x18
Emacs.pane.menubar.popup_*.fontList:8x16
Emacs.pane.menubar.*.fontList: 9x18
Emacs.pane.menubar.popup_*.fontList: 8x16

要为 LessTif 文件选择框指定资源,请使用 '前端总线*', 像这样:

To specify resources for the LessTif file-selection box, use ‘fsb*’, like this:

Emacs.fsb*.fontList:8x16
Emacs.fsb*.fontList: 8x16

以下是 LessTif 菜单栏和弹出菜单的资源列表:

Here is a list of resources for LessTif menu bars and pop-up menus:

armColor
armColor

武装按钮中显示的颜色。

The color to show in an armed button.

fontList
fontList

要使用的字体。

The font to use.

marginBottom
marginBottom
marginHeight
marginHeight
marginLeft
marginLeft
marginRight
marginRight
marginTop
marginTop
marginWidth
marginWidth

边框内项目周围留出的空间量。

Amount of space to leave around the item, within the border.

borderWidth
borderWidth

菜单项四周边框的宽度。

The width of the border around the menu item, on all sides.

shadowThickness
shadowThickness

边框阴影的宽度。

The width of the border shadow.

bottomShadowColor
bottomShadowColor

底部和右侧边框阴影的颜色。

The color for the border shadow, on the bottom and the right.

topShadowColor
topShadowColor

顶部和左侧边框阴影的颜色。

The color for the border shadow, on the top and the left.


D.5 GTK+ 资源

D.5 GTK+ resources

如果 Emacs 是使用 GTK+ 工具包支持编译的,则自定义其 GTK+ 小部件(例如菜单、对话框、工具栏和滚动条)的最简单方法是选择适当的 GTK+ 主题,例如使用 GNOME 主题选择器。

If Emacs is compiled with GTK+ toolkit support, the simplest way to customize its GTK+ widgets (e.g., menus, dialogs, tool bars and scroll bars) is to choose an appropriate GTK+ theme, for example with the GNOME theme selector.

在 GTK+ 版本 2 中,您还可以使用GTK+ 资源来自定义 Emacs 使用的 GTK+ 小部件的外观。这些资源在文件中指定〜/.emacs.d/gtkrc (对于 Emacs 特定的 GTK+ 资源),或者〜/.gtkrc-2.0(对于一般 GTK+ 资源)。我们建议使用〜/.emacs.d/gtkrc,因为 GTK+ 似乎忽略了〜/.gtkrc-2.0当使用 GNOME 运行 GConf 时。但请注意,某些 GTK+ 主题可能会覆盖〜/.emacs.d/gtkrc;我们对此无能为力。 GTK+ 资源不会影响与 GTK+ 小部件无关的 Emacs 方面,例如主 Emacs 窗口中的字体和颜色;这些由普通的 X 资源管理(参见X 资源)。

In GTK+ version 2, you can also use GTK+ resources to customize the appearance of GTK+ widgets used by Emacs. These resources are specified in either the file ~/.emacs.d/gtkrc (for Emacs-specific GTK+ resources), or ~/.gtkrc-2.0 (for general GTK+ resources). We recommend using ~/.emacs.d/gtkrc, since GTK+ seems to ignore ~/.gtkrc-2.0 when running GConf with GNOME. Note, however, that some GTK+ themes may override customizations in ~/.emacs.d/gtkrc; there is nothing we can do about this. GTK+ resources do not affect aspects of Emacs unrelated to GTK+ widgets, such as fonts and colors in the main Emacs window; those are governed by normal X resources (see X Resources).

以下部分描述如何为 Emacs 定制 GTK+ 资源。有关 GTK+ 资源的详细信息,请参阅 GTK+ API 文档: https://developer-old.gnome.org/gtk2/stable/gtk2-Resource-Files.html

The following sections describe how to customize GTK+ resources for Emacs. For details about GTK+ resources, see the GTK+ API document at https://developer-old.gnome.org/gtk2/stable/gtk2-Resource-Files.html.

在 GTK+ 版本 3 中,GTK+ 资源已被完全不同的系统所取代。 GTK+ 小部件的外观现在由类似 CSS 的样式文件确定:gtk-3.0/gtk.css在 GTK+ 安装目录中,以及〜/.themes/主题/gtk-3.0/gtk.css用于本地样式设置(其中theme是当前 GTK+ 主题的名称)。因此,本节中对 GTK+ 资源的描述不适用于 GTK+ 3。有关 GTK+ 3 样式系统的详细信息,请参阅 https://developer-old.gnome.org/gtk3/3.0/GtkCssProvider.html

In GTK+ version 3, GTK+ resources have been replaced by a completely different system. The appearance of GTK+ widgets is now determined by CSS-like style files: gtk-3.0/gtk.css in the GTK+ installation directory, and ~/.themes/theme/gtk-3.0/gtk.css for local style settings (where theme is the name of the current GTK+ theme). Therefore, the description of GTK+ resources in this section does not apply to GTK+ 3. For details about the GTK+ 3 styling system, see https://developer-old.gnome.org/gtk3/3.0/GtkCssProvider.html.


D.5.1 GTK+ 资源基础知识

D.5.1 GTK+ Resource Basics

在 GTK+ 2 资源文件中(通常〜/.emacs.d/gtkrc),最简单的资源设置只是将值分配给变量。例如,将以下行放入资源文件中会将所有 GTK+ 小部件上的字体更改为 '快递12':

In a GTK+ 2 resource file (usually ~/.emacs.d/gtkrc), the simplest kind of a resource setting simply assigns a value to a variable. For example, putting the following line in the resource file changes the font on all GTK+ widgets to ‘courier-12’:

gtk-字体名称 =“快递 12”
gtk-font-name = "courier 12"

请注意,在这种情况下,字体名称必须作为 GTK 字体模式(也称为Pango 字体名称)提供,而不是作为 Fontconfig 样式字体名称或 XLFD。请参阅字体

Note that in this case the font name must be supplied as a GTK font pattern (also called a Pango font name), not as a Fontconfig-style font name or XLFD. See Fonts.

要自定义小部件,您首先需要定义样式,然后将该样式应用到小部件。这是设置菜单字体的示例('#' 字符表示注释):

To customize widgets you first define a style, and then apply the style to the widgets. Here is an example that sets the font for menus (‘#’ characters indicate comments):

#定义样式'我的风格'。
风格“我的风格”
{
  font_name = "helvetica 粗体 14"
}

#指定小部件类型 '*emacs-菜单项*'使用'我的风格'。
小部件“*emacs-menuitem*”样式“my_style”
# Define the style ‘my_style’.
style "my_style"
{
  font_name = "helvetica bold 14"
}

# Specify that widget type ‘*emacs-menuitem*’ uses ‘my_style’.
widget "*emacs-menuitem*" style "my_style"

此示例中的小部件名称包含通配符,因此该样式将应用于所有匹配 ' 的小部件*emacs-菜单项*'。小部件根据它们的包含方式来命名,从外部小部件到内部小部件。这是另一个适用的例子'我的风格' 特别针对 Emacs 菜单栏:

The widget name in this example contains wildcards, so the style is applied to all widgets matching ‘*emacs-menuitem*’. The widgets are named by the way they are contained, from the outer widget to the inner widget. Here is another example that applies ‘my_style’ specifically to the Emacs menu bar:

小部件“Emacs.pane.menubar.*”样式“my_style”
widget "Emacs.pane.menubar.*" style "my_style"

这是一个更详细的示例,展示了如何更改滚动条的各个部分:

Here is a more elaborate example, showing how to change the parts of the scroll bar:

样式“滚动”
{
  fg[NORMAL] = "red" #箭头颜色。 
  bg[NORMAL] = "yellow" #拇指和箭头周围的背景。 
  bg[ACTIVE] = "blue" #槽颜色。 
  bg[PRELIGHT] = "white" #鼠标悬停在拇指上时的颜色。
}

小部件“*verticalScrollBar*”样式“滚动”
style "scroll"
{
  fg[NORMAL] = "red"     # Arrow color.
  bg[NORMAL] = "yellow"  # Thumb and background around arrow.
  bg[ACTIVE] = "blue"    # Trough color.
  bg[PRELIGHT] = "white" # Thumb color when the mouse is over it.
}

widget "*verticalScrollBar*" style "scroll"

D.5.2 GTK+ 小部件名称

D.5.2 GTK+ widget names

GTK+ 小部件由小部件名称小部件类指定。小部件名称指的是特定的小部件(例如,'emacs 菜单项'),而小部件类指的是类似小部件的集合(例如,'Gtk菜单项')。小部件总是有一个类,但不需要有名称。

A GTK+ widget is specified by a widget name and a widget class. The widget name refers to a specific widget (e.g., ‘emacs-menuitem’), while the widget class refers to a collection of similar widgets (e.g., ‘GtkMenuItem’). A widget always has a class, but need not have a name.

绝对名称是小部件名称或小部件类的序列,对应于嵌入其他小部件中的小部件的层次结构。例如,如果GtkWindow命名top 包含GtkVBox命名,而命名box又包含调用,则菜单栏小部件的绝对类名称为,其绝对小部件名称为。 GtkMenuBarmenubarGtkWindow.GtkVBox.GtkMenuBartop.box.menubar

Absolute names are sequences of widget names or widget classes, corresponding to hierarchies of widgets embedded within other widgets. For example, if a GtkWindow named top contains a GtkVBox named box, which in turn contains a GtkMenuBar called menubar, the absolute class name of the menu-bar widget is GtkWindow.GtkVBox.GtkMenuBar, and its absolute widget name is top.box.menubar.

GTK+ 资源文件可以包含两种类型的用于指定小部件外观的命令:

GTK+ resource files can contain two types of commands for specifying widget appearances:

widget
widget

根据类名或仅根据类指定小部件的样式。

specifies a style for widgets based on the class name, or just the class.

widget_class
widget_class

根据类名指定小部件的样式。

specifies a style for widgets based on the class name.

widget 有关使用该命令的示例,请参阅上一小节;该widget_class命令的使用方式类似。请注意,小部件名称/类和样式必须用双引号引起来,并且这些命令必须位于 GTK+ 资源文件的顶层。

See the previous subsection for examples of using the widget command; the widget_class command is used similarly. Note that the widget name/class and the style must be enclosed in double-quotes, and these commands must be at the top level in the GTK+ resource file.

如前所述,您可以使用 shell 通配符语法指定小部件名称或类:'*' 匹配零个或多个字符并且 '' 匹配一个字符。此示例为所有小部件分配样式:

As previously noted, you may specify a widget name or class with shell wildcard syntax: ‘*’ matches zero or more characters and ‘?’ matches one character. This example assigns a style to all widgets:

小部件“*”样式“my_style”
widget "*" style "my_style"

D.5.3 Emacs 中的 GTK+ 小部件名称

D.5.3 GTK+ Widget Names in Emacs

下面列出了 Emacs 框架使用的 GTK+ 小部件:

The GTK+ widgets used by an Emacs frame are listed below:

Emacs(班级GtkWindow
Emacs (class GtkWindow)
pane(班级GtkVBox
menubar(班级GtkMenuBar
[菜单项小部件]
[未命名小部件](类GtkHandleBox
emacs-toolbar(班级GtkToolbar
[工具栏项目小部件]
emacs(班级GtkFixed
verticalScrollBar(班级GtkVScrollbar
pane (class GtkVBox)
menubar (class GtkMenuBar)
[menu item widgets]
[unnamed widget] (class GtkHandleBox)
emacs-toolbar (class GtkToolbar)
[tool bar item widgets]
emacs (class GtkFixed)
verticalScrollBar (class GtkVScrollbar)

Emacs 窗口的内容在emacs小部件中绘制。请注意,即使有多个 Emacs 窗口,每个滚动条小部件也被命名为verticalScrollBar

The contents of Emacs windows are drawn in the emacs widget. Note that even if there are multiple Emacs windows, each scroll bar widget is named verticalScrollBar.

例如,以下是设置菜单栏样式的两种不同方法:

For example, here are two different ways to set the menu bar style:

小部件“Emacs.pane.menubar.*”样式“my_style”
widget_class“GtkWindow.GtkVBox.GtkMenuBar.*”样式“my_style”
widget "Emacs.pane.menubar.*" style "my_style"
widget_class "GtkWindow.GtkVBox.GtkMenuBar.*" style "my_style"

对于 GTK+ 对话框,Emacs 使用名为emacs-dialog、 类的小部件GtkDialog。对于文件选择,Emacs 使用名为 emacs-filedialog、 类的小部件GtkFileSelection

For GTK+ dialogs, Emacs uses a widget named emacs-dialog, of class GtkDialog. For file selection, Emacs uses a widget named emacs-filedialog, of class GtkFileSelection.

因为弹出菜单和对话框的小部件是独立的窗口并且不包含在Emacs小部件中,所以它们的 GTK+ 绝对名称不以 ' 开头Emacs'。要自定义这些小部件,请使用如下通配符:

Because the widgets for pop-up menus and dialogs are free-standing windows and not contained in the Emacs widget, their GTK+ absolute names do not start with ‘Emacs’. To customize these widgets, use wildcards like this:

小部件“*emacs-dialog*”样式“my_dialog_style”
小部件“*emacs-filedialog* 样式”my_file_style”
小部件“*emacs-menuitem* 样式”my_menu_style”
widget "*emacs-dialog*" style "my_dialog_style"
widget "*emacs-filedialog* style "my_file_style"
widget "*emacs-menuitem* style "my_menu_style"

如果您想将样式应用于 Emacs 中的所有菜单,请使用以下命令:

If you want to apply a style to all menus in Emacs, use this:

widget_class“*菜单*”样式“my_menu_style”
widget_class "*Menu*" style "my_menu_style"

D.5.4 GTK+ 样式

D.5.4 GTK+ styles

以下是两个 GTK+ 样式声明的示例:

Here is an example of two GTK+ style declarations:

pixmap_path “/usr/share/pixmaps:/usr/include/X11/pixmaps”

样式“默认”
{
  字体名称 = "helvetica 12"

  bg[正常] = { 0.83, 0.80, 0.73 }
  bg[选定] = { 0.0, 0.55, 0.55 }
  bg[不敏感] = { 0.77, 0.77, 0.66 }
  bg[活动] = { 0.0, 0.55, 0.55 }
  bg[预亮] = { 0.0, 0.55, 0.55 }

  fg[正常] = "黑色"
  fg[选定] = { 0.9, 0.9, 0.9 }
  fg[活动] = "黑色"
  fg[预亮] = { 0.9, 0.9, 0.9 }

  基础[不敏感] = "#777766"
  文本[不敏感] = { 0.60, 0.65, 0.57 }

  bg_pixmap[正常] = "背景.xpm"
  bg_pixmap[INSENSITIVE] = "背景.xpm"
  bg_pixmap[活动] = "背景.xpm"
  bg_pixmap[PRELIGHT] = "<无>"

}

样式“标尺”=“默认”
{
  字体名称 = "helvetica 8"
}

pixmap_path "/usr/share/pixmaps:/usr/include/X11/pixmaps"

style "default"
{
  font_name = "helvetica 12"

  bg[NORMAL] = { 0.83, 0.80, 0.73 }
  bg[SELECTED] = { 0.0, 0.55, 0.55 }
  bg[INSENSITIVE] = { 0.77, 0.77, 0.66 }
  bg[ACTIVE] = { 0.0, 0.55, 0.55 }
  bg[PRELIGHT] = { 0.0, 0.55, 0.55 }

  fg[NORMAL] = "black"
  fg[SELECTED] = { 0.9, 0.9, 0.9 }
  fg[ACTIVE] = "black"
  fg[PRELIGHT] = { 0.9, 0.9, 0.9 }

  base[INSENSITIVE] = "#777766"
  text[INSENSITIVE] = { 0.60, 0.65, 0.57 }

  bg_pixmap[NORMAL] = "background.xpm"
  bg_pixmap[INSENSITIVE] = "background.xpm"
  bg_pixmap[ACTIVE] = "background.xpm"
  bg_pixmap[PRELIGHT] = "<none>"

}

style "ruler" = "default"
{
  font_name = "helvetica 8"
}

样式 '统治者' 继承自 '默认'。这样您就可以在现有样式的基础上进行构建。字体和颜色的语法如下所述。

The style ‘ruler’ inherits from ‘default’. This way you can build on existing styles. The syntax for fonts and colors is described below.

如本示例所示,可以根据小部件的状态指定前景和背景的多个值。可能的状态有:

As this example shows, it is possible to specify several values for foreground and background depending on the widget’s state. The possible states are:

NORMAL
NORMAL

这是小部件的默认状态。

This is the default state for widgets.

ACTIVE
ACTIVE

这是准备做某事的小部件的状态。也是针对滚动条的槽,即将bg[ACTIVE] = "red" 滚动条的槽设置为红色。已布防的按钮(按下但尚未释放)处于此状态。

This is the state for a widget that is ready to do something. It is also for the trough of a scroll bar, i.e., bg[ACTIVE] = "red" sets the scroll bar trough to red. Buttons that have been armed (pressed but not released yet) are in this state.

PRELIGHT
PRELIGHT

这是当鼠标指针位于小部件上方时(例如,当鼠标位于滚动条中的滑块上方或菜单项上方时)可进行操作的小部件的状态。当鼠标悬停在未按下的按钮上时,该按钮处于此状态。

This is the state for a widget that can be manipulated, when the mouse pointer is over it—for example when the mouse is over the thumb in the scroll bar or over a menu item. When the mouse is over a button that is not pressed, the button is in this state.

SELECTED
SELECTED

这是用户已选择的数据的状态。它可以是选定的文本或列表中选定的项目。 Emacs 中不使用此状态。

This is the state for data that has been selected by the user. It can be selected text or items selected in a list. This state is not used in Emacs.

INSENSITIVE
INSENSITIVE

这是可见的小部件的状态,但无法以通常的方式操作它们,例如,无法按下的按钮和禁用的菜单项。要将禁用的菜单项显示为黄色,请使用fg[INSENSITIVE] = "yellow"

This is the state for widgets that are visible, but they cannot be manipulated in the usual way—for example, buttons that can’t be pressed, and disabled menu items. To display disabled menu items in yellow, use fg[INSENSITIVE] = "yellow".

以下是样式声明中可以包含的内容:

Here are the things that can go in a style declaration:

bg[state] = color
bg[state] = color

这指定了小部件的背景颜色。请注意,可编辑文本不使用bg;它使用base相反。

This specifies the background color for the widget. Note that editable text doesn’t use bg; it uses base instead.

base[state] = color
base[state] = color

这指定可编辑文本的背景颜色。在 Emacs 中,此颜色用于文件对话框中文本字段的背景。

This specifies the background color for editable text. In Emacs, this color is used for the background of the text fields in the file dialog.

bg_pixmap[state] = "pixmap"
bg_pixmap[state] = "pixmap"

这指定图像背景(而不是背景颜色)。 pixmap应该是图像文件名。 GTK+ 可以使用多种图像文件格式,包括 XPM、XBM、GIF、JPEG 和 PNG。如果您希望小部件使用与其父部件相同的图像,请使用 '<父>'。如果您不需要任何图像,请使用 '<无>'。 '<无>' 是取消从父样式继承的背景图像的方法。

您不能通过绝对文件名来指定文件。 GTK+ 在 中指定的目录中查找像素图文件pixmap_pathpixmap_path是用冒号分隔的双引号内的目录列表,在顶层指定GTKRC文件(即不在样式定义内;参见上面的示例):

pixmap_path “/usr/share/pixmaps:/usr/include/X11/pixmaps”

This specifies an image background (instead of a background color). pixmap should be the image file name. GTK+ can use a number of image file formats, including XPM, XBM, GIF, JPEG and PNG. If you want a widget to use the same image as its parent, use ‘<parent>’. If you don’t want any image, use ‘<none>’. ‘<none>’ is the way to cancel a background image inherited from a parent style.

You can’t specify the file by its absolute file name. GTK+ looks for the pixmap file in directories specified in pixmap_path. pixmap_path is a colon-separated list of directories within double quotes, specified at the top level in a gtkrc file (i.e., not inside a style definition; see example above):

pixmap_path "/usr/share/pixmaps:/usr/include/X11/pixmaps"
fg[state] = color
fg[state] = color

这指定了小部件要使用的前景色。它是菜单和按钮中文本的颜色以及滚动条中箭头的颜色。对于可编辑文本,请使用text.

This specifies the foreground color for widgets to use. It is the color of text in menus and buttons, and the color for the arrows in the scroll bar. For editable text, use text.

text[state] = color
text[state] = color

这是可编辑文本的颜色。在 Emacs 中,此颜色用于文件对话框中的文本字段。

This is the color for editable text. In Emacs, this color is used for the text fields in the file dialog.

font_name = "font"
font_name = "font"

这指定小部件中文本的字体。 font是 GTK 风格(或 Pango)字体名称,例如 '无斜体 10'。请参阅字体。名称不区分大小写。

This specifies the font for text in the widget. font is a GTK-style (or Pango) font name, like ‘Sans Italic 10’. See Fonts. The names are case insensitive.

有三种方法可以指定颜色:颜色名称、RGB 三元组或 GTK 样式 RGB 三元组。有关颜色名称和 RGB 三元组的说明,请参阅面的颜色。颜色名称应该用双引号括起来,例如 '“红色的”'。 RGB 三元组应不带双引号,例如 '#ff0000'。 GTK 样式 RGB 三元组的形式为,其中 rgb是 0–65535 范围内的整数或 0.0–1.0 范围内的浮点数。 rgb }

There are three ways to specify a color: a color name, an RGB triplet, or a GTK-style RGB triplet. See Colors for Faces, for a description of color names and RGB triplets. Color names should be enclosed with double quotes, e.g., ‘"red"’. RGB triplets should be written without double quotes, e.g., ‘#ff0000’. GTK-style RGB triplets have the form rgb }, where r, g and b are either integers in the range 0–65535 or floats in the range 0.0–1.0.


附录 E Emacs 28 反新闻

Appendix E Emacs 28 Antinews

对于那些生活在过去的用户,以下是有关降级到 Emacs 版本 28.2 的信息。我们希望您能享受到由于 Emacs 29.2 缺少许多功能而带来的更大的简单性。

For those users who live backwards in time, here is information about downgrading to Emacs version 28.2. We hope you will enjoy the greater simplicity that results from the absence of many Emacs 29.2 features.

  • 与其新版本一样,Emacs 28 仍然可以通过支持 Lisp 程序的本机编译来构建。然而,为了准备在某些先前版本中删除此功能,我们删除了 Emacs 附带的所有 Lisp 文件的提前本机编译功能。这使得 Emacs 构建过程更快。
  • Like its newer releases, Emacs 28 can still be built with support of native compilation of Lisp programs. However, in preparation for removal of this feature in some previous version, we’ve deleted the capability of ahead-of-time native compilation of all the Lisp files that come with Emacs. This makes the Emacs build process much faster.
  • Emacs 不能再使用 tree-sitter 库构建,因此您不再需要寻找和安装您想要编程的语言的语法库。同样,基于 Tree-sitter 库的所有模式都被删除,为每种受支持的编程语言留下了一种主要模式:不再需要决定是否打开 Tree-sitter 支持的模式并尝试使用其解析器基于字体、缩进和其他功能。对于某些语言和文件类型,这意味着根本不需要主要模式,而您可以选择古老的基本模式作为自然的高性能选择。例如,Go、Rust 和 CMake 文件不再有任何主要的文件编辑模式——这是迈向更简单、更精简的 Emacs 的另一个里程碑。
  • Emacs can no longer be built with the tree-sitter library, so you no longer will need to look for and install the grammar libraries for the languages in which you want to program. Similarly, all the modes that are based on the tree-sitter library were deleted, leaving you with just one major mode for every supported programming language: no more need to decide whether to turn the tree-sitter supported modes on and try using their parser-based fontification, indentation, and other features. For some languages and file types, this means no major mode at all, leaving you with the venerable Fundamental mode as the natural, high-performance choice. For example, Go, Rust, and CMake files no longer have any major modes for editing their files — another milestone towards a simpler, leaner Emacs.
  • 删除了对访问 SQLite 数据库的内置支持。现在,您可以再次将 SQLite 文件编辑为简单的二进制文件,Emacs 一如既往地能够支持这种功能。
  • Built-in support for accessing SQLite databases was removed. You can now again edit SQLite files as simple binary files, which Emacs is quite capable to support, as it always did.
  • 作为对 Haiku 操作系统用户的一个姿态,我们删除了允许在该操作系统上构建 Emacs 的代码。我们希望 Haiku 用户能够享受更简单的编辑器来编辑文件。
  • As a gesture to users of the Haiku operating system, we’ve dropped the code which allowed Emacs to be built on that OS. We expect Haiku users to enjoy the much simpler editors they have for editing their files.
  • X 上对 XInput2 输入事件的支持已消失。我们认为传统的 X 输入事件已经足够了,当然,当你回到过去时,一旦 X Windows 系统的维护者意识到支持花哨的输入机制是完全徒劳的,XInput2 最终也将从 X 中删除。
  • Support for XInput2 input events on X is gone. We think the traditional X input events are more than enough, certainly so as you move back in time, where XInput2 will eventually be removed from X as well, once the maintainers of the X Windows system realize the utter futility of supporting fancy input mechanisms.
  • 不再支持 Emacs 的“纯 GTK”(又名PGTK )配置。这是为了从 Emacs 中完全删除 GTK 工具包支持,并且根据我们的预期,当你回到过去时,GTK 将不复存在。我们还计划取消对所有其他工具包的支持,只留下带有我们自己的小部件的纯 X 版本作为 X 上单一受支持的 GUI 配置。
  • The “pure GTK” (a.k.a. PGTK) configuration of Emacs is no longer supported. This is in anticipation of the complete removal of the GTK toolkit support from Emacs, and in accordance with our expectation that GTK will cease to exist as you move back in time. We plan on removing support for all the other toolkits as well, leaving only the pure X build with our own widgets as the single supported GUI configuration on X.
  • --init-目录命令行选项被删除,因为用另一个用户的 init 文件初始化 Emacs 无论如何都是一个荒谬的想法。
  • The --init-directory command-line option was removed, as initializing Emacs with init files of another user is a preposterous idea anyway.
  • 为了简化并最终删除本机编译选项,我们删除了 --with-native-compilation=aot配置时间选项。这极大地简化了本机编译的工作方式,并使您在 Emacs 中进行有关本机编译的配置时决策变得清晰:Emacs 仅在使用非预加载的 Lisp 包之前将其编译为本机代码,或者根本不使用本机编译;不再采取半途而废的措施和特殊例外。出于类似的原因, native-compile-prune-cachestartup-redirect-eln-cache功能不再是 Emacs 的一部分。
  • In line with simplifying and eventually removing the native-compilation option, we’ve deleted the --with-native-compilation=aot configure-time option. This greatly simplifies how native compilation works and makes your configure-time decision regarding native compilation in Emacs clear-cut: either Emacs compiles non-preloaded Lisp packages to native code only before using it, or it never uses native compilation at all; no more half measures and special exceptions. For similar reasons, native-compile-prune-cache and startup-redirect-eln-cache features are no longer part of Emacs.
  • 我们删除了特殊的代码和功能,这些代码和功能使 Emacs 在编辑具有很长行的文件时能够呈现良好的性能和响应能力。随着时间的推移,此类文件变得越来越罕见,因此为了他们的利益而在 Emacs 中使用所有这些棘手的代码被认为是不必要的复杂化。
  • We’ve deleted the special code and features which allowed Emacs to present decent performance and responsiveness when editing files with very long lines. Such files become more and more rare as time goes back, and so having all this tricky code in Emacs for their benefit was deemed an unnecessary complication.
  • Emacs 放弃了对 Eglot 和 LSP 服务器的支持。我们认为,当您回到过去时,分析源代码的内置方法已经足够了。
  • Emacs dropped support for Eglot and the LSP servers. We decided that the built-in ways of analyzing source code are more than enough as you move back in time.
  • 缩放和旋转图像的命令再次绑定到单个键,例如+-、 和r,这使得它们更容易键入。至于错误输入这些内容的风险,我们不认为 Emacs 用户会犯输入错误,尤其是当他们回到过去并且变得越来越年轻时。
  • Commands to scale and rotate images are once again bound to single keys like +, -, and r, which makes them much easier to type. As for the risk of typing these by mistake, we don’t believe Emacs users make typing mistakes, especially as they move back in time and become younger and younger.
  • 为了简化常用命令的输入,我们将C-x 8 . . backC-x 8 .C-x 8 = =back 回弹到C-x 8 =.不需要更奇特、更长的按键序列,因为回到过去意味着我们首先绑定到它们的命令会越来越少。
  • To simplify typing popular commands, we’ve rebound the C-x 8 . . back to C-x 8 . and C-x 8 = = back to C-x 8 =. There’s no need for fancier, longer key sequences, as moving back in time means we will have fewer and fewer commands to bind to them in the first place.
  • 如果你不小心杀死了*划痕*buffer,Emacs 会在 Fundamental 模式下重新创建它,而不是在 Lisp Interaction 模式下。您可以打开自己喜欢的模式。我们对过去 Emacs 版本的长期计划是消除重新创建*划痕* 总的来说,这是朝这个方向迈出的第一步。
  • If you inadvertently kill the *scratch* buffer, Emacs will recreate it in Fundamental mode, not in Lisp Interaction mode. You get to turn on the mode you like yourself. Our long-term plans for past Emacs releases is to remove the recreation of *scratch* altogether, and this is the first step in that direction.
  • rlogin对协议的支持rsh又回来了,因为我们预计随着时间的推移,它们会变得越来越重要和流行。
  • Support for rlogin and rsh protocols are back, since we expect them to become more and more important and popular as you move back in time.
  • 为了准备最终从 Emacs 中删除 Unicode 支持,我们已将 Unicode 支持降级至版本 14.0。
  • In preparation for eventual removal of Unicode support from Emacs, we’ve downgraded our Unicode support to version 14.0.
  • 您无法再全局更改字体大小。由于 Emacs 将在过去的某个日期删除对可变大小字体的所有支持,因此拥有这样的命令是一种奢侈,我们最好没有。
  • You can no longer change the size of the font globally. Since Emacs will at some past date remove all support for variable-size fonts, having such commands is a luxury we are better without.
  • 为了实现简化 Emacs 的永久追求,我们删除了命令duplicate-lineduplicate-dwim;老朋友M-wC-y(输入一次或多次)应该就足够了。由于同样的原因,该命令rename-visited-file消失了。
  • On our permanent quest for simplifying Emacs, we’ve removed the commands duplicate-line and duplicate-dwim; the old-time friends M-w and C-y (typed one or more times) should suffice. The command rename-visited-file is gone for the same reason.
  • 我们删除了许多与表情符号相关的命令,这些命令绑定在 C-x 8 e前缀键映射中。我们认为使用输入表情符号序列的能力就足够了,并且通过要求用户知道他们想要输入的序列的代码点来实际上更好地为我们的用户服务。 C-x 8 RET
  • We’ve deleted many commands related to Emoji, which were bound in the C-x 8 e prefix keymap. We decided that the ability to type Emoji sequences using C-x 8 RET is enough, and actually serves our users better by requiring them to know the codepoints of the sequences they want to type.
  • 我们放弃了对许多脚本和输入法的支持,尤其是没人使用的旧脚本。出于类似的原因,Emacs 教程的希腊语和乌克兰语翻译不再可用。
  • We dropped support for many scripts and input methods, especially old scripts that no one uses anyway. For similar reasons, Greek and Ukrainian translations of the Emacs tutorial are not available anymore.
  • 包.el无法再从其 VCS 存储库获取包的源代码。我们认为像 Git 这样的命令行工具应该足以让您克隆他们的存储库。所以我们删除了该package-vc-install命令以及其他类似的命令。
  • package.el can no longer fetch source code of packages from their VCS repositories. We think command-line tools like Git should be enough to allow you to clone their repositories. So we deleted the package-vc-install command and other similar commands.
  • 为了跟上计算机内存容量和磁盘空间的减少,Emacs 28.2 中删除了许多其他功能和文件。
  • To keep up with decreasing computer memory capacity and disk space, many other functions and files have been eliminated in Emacs 28.2.

附录 F Emacs 和 macOS / GNUstep

Appendix F Emacs and macOS / GNUstep

本节介绍在 GNU/Linux 或其他操作系统上,或在具有本机窗口系统支持的 macOS 上使用使用 GNUstep 库构建的 Emacs 的特性。在 macOS 上,Emacs 可以在没有窗口系统支持的情况下使用 X11 或使用 Cocoa 界面来构建;本节仅适用于 Cocoa 构建。这不支持 macOS 10.6 之前的版本。

This section describes the peculiarities of using Emacs built with the GNUstep libraries on GNU/Linux or other operating systems, or on macOS with native window system support. On macOS, Emacs can be built either without window system support, with X11, or with the Cocoa interface; this section only applies to the Cocoa build. This does not support versions before macOS 10.6.

GNUstep 是免费软件; macOS 不是。由于 macOS 是一个非自由操作系统,因此剥夺了用户每个计算机用户应得的自由。这是不公平的。为了您的自由,我们强烈建议您切换到免费操作系统。

GNUstep is free software; macOS is not. Because it is a non-free operating system, macOS denies its users the freedom that every computer user deserves. That is an injustice. For your freedom’s sake, we urge you to switch to a free operating system.

我们在专有操作系统上支持 GNU Emacs,因为我们希望这种自由的味道能够激励用户摆脱它们。

We support GNU Emacs on proprietary operating systems because we hope this taste of freedom will inspire users to escape from them.

由于各种历史和技术原因,Emacs 使用术语“下一步' 在内部,而不是“Cocoa”或“macOS”;例如,本节中描述的大多数命令和变量都以 ' 开头ns-',这是 ' 的缩写下一步'。 NeXTstep 是 NeXT Inc. 在 20 世纪 80 年代发布的应用程序界面,Cocoa 是 NeXT Inc. 的直接后代。除了Cocoa之外,还有另一个NeXTstep风格的系统:GNUstep,它是免费软件。截至撰写本文时,Emacs GNUstep 支持处于 alpha 状态(请参阅GNUstep 支持),但我们希望将来对其进行改进。

For various historical and technical reasons, Emacs uses the term ‘Nextstep’ internally, instead of “Cocoa” or “macOS”; for instance, most of the commands and variables described in this section begin with ‘ns-’, which is short for ‘Nextstep’. NeXTstep was an application interface released by NeXT Inc. during the 1980s, of which Cocoa is a direct descendant. Apart from Cocoa, there is another NeXTstep-style system: GNUstep, which is free software. As of this writing, Emacs GNUstep support is in alpha status (see GNUstep Support), but we hope to improve it in the future.


F.1 macOS 和 GNUstep 下的基本 Emacs 使用

F.1 Basic Emacs usage under macOS and GNUstep

默认情况下,AltOption键与 相同 Meta。 MacCmd键与 相同Super,并且 Emacs 使用此修饰键提供了一组键绑定,模仿其他 Mac / GNUstep 应用程序(请参阅macOS / GNUstep 下的窗口系统事件)。您可以按照通常的方式更改这些绑定(请参阅自定义按键绑定)。修饰符本身可以定制;请参阅Mac/GNUstep 自定义

By default, the Alt and Option keys are the same as Meta. The Mac Cmd key is the same as Super, and Emacs provides a set of key bindings using this modifier key that mimic other Mac / GNUstep applications (see Windowing System Events under macOS / GNUstep). You can change these bindings in the usual way (see Customizing Key Bindings). The modifiers themselves can be customized; see Mac / GNUstep Customization.

S-mouse-1将区域调整到点击位置,如mouse-3( mouse-save-then-kill);它不会像S-mouse-1通常那样弹出用于更改默认面的菜单(请参阅文本比例)。这一变化使得 Emacs 的行为更像其他 Mac/GNUstep 应用程序。

S-mouse-1 adjusts the region to the click position, just like mouse-3 (mouse-save-then-kill); it does not pop up a menu for changing the default face, as S-mouse-1 normally does (see Text Scale). This change makes Emacs behave more like other Mac / GNUstep applications.

当您使用菜单或使用 Cmd-oCmd-S绑定打开或保存文件时,Emacs 使用图形文件对话框来读取文件名。但是,如果您使用常规 Emacs 键序列(例如 )C-x C-f,Emacs 将使用迷你缓冲区来读取文件名。

When you open or save files using the menus, or using the Cmd-o and Cmd-S bindings, Emacs uses graphical file dialogs to read file names. However, if you use the regular Emacs key sequences, such as C-x C-f, Emacs uses the minibuffer to read file names.

在 GNUstep 上,在 X-windows 环境中,您需要使用或命令Cmd-c 之一来将文本传输到 X 主选择;否则,Emacs 将使用剪贴板选择。同样,(而不是)从 X 主要选择而不是 Kill-ring 或剪贴板中进行拉取。 C-wM-wCmd-yC-y

On GNUstep, in an X-windows environment you need to use Cmd-c instead of one of the C-w or M-w commands to transfer text to the X primary selection; otherwise, Emacs will use the clipboard selection. Likewise, Cmd-y (instead of C-y) yanks from the X primary selection instead of the kill-ring or clipboard.

F.1.1 获取环境变量

F.1.1 Grabbing environment variables

许多在 Emacs 下运行的程序,例如 Latex 或 man,都依赖于环境变量的设置。如果 Emacs 从 shell 启动,它将自动继承这些环境变量,并且它的子进程也会从中继承它们。但是,如果 Emacs 是从 Finder 启动的,那么它就不是任何 shell 的后代,因此它的环境变量尚未设置,这通常会导致它启动的子进程的行为与从 shell 启动时不同。

Many programs which may run under Emacs, like latex or man, depend on the settings of environment variables. If Emacs is launched from the shell, it will automatically inherit these environment variables and its subprocesses will inherit them from it. But if Emacs is launched from the Finder it is not a descendant of any shell, so its environment variables haven’t been set, which often causes the subprocesses it launches to behave differently than they would when launched from the shell.

对于 PATH 和 MANPATH 变量,建议在 macOS 上使用系统范围的设置 PATH 的方法,使用 /etc/路径文件和/etc/paths.d目录。

For the PATH and MANPATH variables, a system-wide method of setting PATH is recommended on macOS, using the /etc/paths files and the /etc/paths.d directory.


F.2 Mac / GNUstep 定制

F.2 Mac / GNUstep Customization

有一些特定于 Nextstep 端口的自定义选项。例如,它们会影响修改键和全屏行为等内容。要查看所有此类选项,请使用 . M-x customize-group RET ns RET

There are a few customization options that are specific to the Nextstep port. For example, they affect things such as the modifier keys and the fullscreen behavior. To see all such options, use M-x customize-group RET ns RET.

F.2.1 修饰键

F.2.1 Modifier keys

以下变量控制实际修饰键的行为:

The following variables control the behavior of the actual modifier keys:

ns-alternate-modifier
ns-alternate-modifier
ns-right-alternate-modifier
ns-right-alternate-modifier

左右OptionAlt键。

The left and right Option or Alt keys.

ns-command-modifier
ns-command-modifier
ns-right-command-modifier
ns-right-command-modifier

左键和右键Command

The left and right Command keys.

ns-control-modifier
ns-control-modifier
ns-right-control-modifier
ns-right-control-modifier

左键和右键Control

The left and right Control keys.

ns-function-modifier
ns-function-modifier

(fn)键Function

The Function (fn) key.

每个变量的值要么是一个符号,描述用于任何目的的键,要么是一个形式的列表 ,它描述与普通键、功能键(不产生字符,例如箭头键)一起使用时的修饰符,和鼠标点击。 (:ordinary symbol :function symbol :mouse symbol)

The value of each variable is either a symbol, describing the key for any purpose, or a list of the form (:ordinary symbol :function symbol :mouse symbol), which describes the modifier when used with ordinary keys, function keys (that do not produce a character, such as arrow keys), and mouse clicks.

如果该符号control是、metaalt或 之一superhyper则描述它所代表的 Emacs 修饰符。如果符号none,Emacs 不使用该键,这会保留其标准行为。例如, OptionmacOS 中的按键可用于组合其他字符。

If the symbol is one of control, meta, alt, super or hyper, this describes the Emacs modifier it represents. If symbol is none, Emacs does not use the key, which retains its standard behavior. For instance, the Option key in macOS is then used for composing additional characters.

右手键的变量(例如ns-right-alternate-modifier)也可以设置为left,这意味着使用与相应左手键相同的行为。

The variables for right-hand keys, like ns-right-alternate-modifier, may also be set to left, which means to use the same behavior as the corresponding left-hand key.

F.2.2 框架变量

F.2.2 Frame Variables

ns-use-proxy-icon
ns-use-proxy-icon

该变量指定是否在标题栏中显示代理图标。代理图标可用于将与当前缓冲区关联的文件拖到其他应用程序、打印机、桌面等,就像从 Finder 中一样。您可能必须禁用 tool-bar-mode才能看到代理图标。

This variable specifies whether to display the proxy icon in the titlebar. The proxy icon can be used to drag the file associated with the current buffer to other applications, a printer, the desktop, etc., in the same way you can from Finder. You might have to disable tool-bar-mode to see the proxy icon.

ns-confirm-quit
ns-confirm-quit

该变量指定退出时是否显示图形确认对话框。

This variable specifies whether to display a graphical confirmation dialog on quitting.

ns-auto-hide-menu-bar
ns-auto-hide-menu-bar

此变量指定选择 Emacs 框架时是否隐藏 macOS 菜单栏。如果不是,则nil不会显示菜单栏,除非将鼠标指针移动到屏幕顶部附近。

This variable specifies whether the macOS menu bar is hidden when an Emacs frame is selected. If non-nil the menu bar is not shown unless the mouse pointer is moved near to the top of the screen.

ns-use-native-fullscreen
ns-use-native-fullscreen

此变量控制是使用本机还是非本机全屏。本机全屏仅适用于 macOS 10.7 及更高版本。

This variable controls whether to use native, or non-native fullscreen. Native fullscreen is only available on macOS 10.7 and above.

F.2.3 macOS 触控板/鼠标滚轮变量

F.2.3 macOS Trackpad/Mousewheel Variables

这些变量仅适用于 macOS 10.7 (Lion) 及更高版本。

These variables only apply to macOS 10.7 (Lion) and above.

ns-use-mwheel-acceleration
ns-use-mwheel-acceleration

该变量控制 Emacs 是否忽略系统鼠标滚轮加速度。鼠标滚轮的每次“点击”都nil与一个鼠标滚轮事件完全对应。当非 时nil,默认情况下,每次“单击”可能对应多个鼠标滚轮事件,具体取决于用户的输入。

This variable controls whether Emacs ignores the system mousewheel acceleration. When nil each ‘click’ of the mousewheel will correspond exactly with one mousewheel event. When non-nil, the default, each ‘click’ may correspond with more than one mousewheel event, depending on the user’s input.

ns-use-mwheel-momentum
ns-use-mwheel-momentum

该变量控制 Emacs 在使用触控板滚动时是否忽略系统“动量”。当非nil默认值时,快速滚动可能会导致缓冲区在用户将手指离开触控板后继续滚动一小会儿。

This variable controls whether Emacs ignores the system ‘momentum’ when scrolling using a trackpad. When non-nil, the default, scrolling rapidly may result in the buffer continuing to scroll for a short while after the user has lifted their fingers off the trackpad.

ns-mwheel-line-height
ns-mwheel-line-height

该变量控制触控板滚动的灵敏度。 Apple 触控板按像素滚动,而不是按行滚动,因此 Emacs 将系统的像素值转换为行。当设置为数字时,此变量设置 Emacs 将视为一行的像素数。当 nil或非数字时,使用默认行高。

设置较低的数字会使触控板更敏感,设置较高的数字会使触控板不太敏感。

This variable controls the sensitivity of scrolling with the trackpad. Apple trackpads scroll by pixels, not lines, so Emacs converts the system’s pixel values into lines. When set to a number, this variable sets the number of pixels Emacs will consider as one line. When nil or a non-number the default line height is used.

Setting a lower number makes the trackpad more sensitive, and a higher number makes the trackpad less sensitive.


F.3 macOS / GNUstep 下的窗口系统事件

F.3 Windowing System Events under macOS / GNUstep

Nextstep 应用程序会收到许多没有 X 等效事件的特殊事件。它们作为专门定义的按键事件发送,不对应于任何击键序列。在 Emacs 下,这些按键事件可以像普通击键一样绑定到函数。以下是这些事件的列表。

Nextstep applications receive a number of special events which have no X equivalent. These are sent as specially defined key events, which do not correspond to any sequence of keystrokes. Under Emacs, these key events can be bound to functions just like ordinary keystrokes. Here is a list of these events.

ns-open-file
ns-open-file

当另一个 Nextstep 应用程序请求 Emacs 打开文件时,会发生此事件。出现这种情况的典型原因是用户双击 Finder 应用程序中的文件。默认情况下,Emacs 通过打开一个新框架并访问该框架中的文件来响应此事件 ( ns-find-file)。作为例外,如果所选缓冲区是*划痕*buffer,Emacs 访问所选帧中的文件。

ns-open-file您可以通过更改变量来更改 Emacs 对事件的响应方式ns-pop-up-frames。它的默认值,'新鲜的’,就是我们刚才所描述的。值t 表示始终在新框架中访问文件。值表示nil 始终访问所选帧中的文件。

This event occurs when another Nextstep application requests that Emacs open a file. A typical reason for this would be a user double-clicking a file in the Finder application. By default, Emacs responds to this event by opening a new frame and visiting the file in that frame (ns-find-file). As an exception, if the selected buffer is the *scratch* buffer, Emacs visits the file in the selected frame.

You can change how Emacs responds to a ns-open-file event by changing the variable ns-pop-up-frames. Its default value, ‘fresh’, is what we have just described. A value of t means to always visit the file in a new frame. A value of nil means to always visit the file in the selected frame.

ns-open-temp-file
ns-open-temp-file

当另一个应用程序请求 Emacs 打开临时文件时,会发生此事件。默认情况下,这是通过生成一个 ns-open-file事件来处理的,其结果如上所述。

This event occurs when another application requests that Emacs open a temporary file. By default, this is handled by just generating a ns-open-file event, the results of which are described above.

ns-open-file-line
ns-open-file-line

某些应用程序(例如 ProjectBuilder 和 gdb)不仅请求特定文件,还请求文件中的特定行或行序列。 Emacs 通过访问该文件并突出显示请求的行 ( ns-open-file-select-line) 来处理此问题。

Some applications, such as ProjectBuilder and gdb, request not only a particular file, but also a particular line or sequence of lines in the file. Emacs handles this by visiting that file and highlighting the requested line (ns-open-file-select-line).

ns-power-off
ns-power-off

当用户注销且 Emacs 仍在运行时,或者从应用程序菜单中选择“退出 Emacs”时,会发生此事件。默认行为是保存所有文件访问缓冲区。

This event occurs when the user logs out and Emacs is still running, or when “Quit Emacs” is chosen from the application menu. The default behavior is to save all file-visiting buffers.

ns-show-prefs
ns-show-prefs

当用户从应用程序菜单中选择“首选项”时,会发生此事件。默认情况下,它绑定到命令 customize

This event occurs when the user selects “Preferences” from the application menu. By default, it is bound to the command customize.

Emacs 还允许用户通过一组名称以 ' 开头的命令来使用 Nextstep 服务ns-服务-' 并以服务名称结尾。键入以查看这些命令的列表。这些函数要么对标记的文本进行操作(用结果替换它),要么采用字符串参数并将结果作为字符串返回。您还可以使用 Lisp 函数 将任意字符串传递给任意服务并接收返回的结果。请注意,您可能需要重新启动 Emacs 才能访问新可用的服务。 M-x ns-service- TABns-perform-service

Emacs also allows users to make use of Nextstep services, via a set of commands whose names begin with ‘ns-service-’ and end with the name of the service. Type M-x ns-service- TAB to see a list of these commands. These functions either operate on marked text (replacing it with the result) or take a string argument and return the result as a string. You can also use the Lisp function ns-perform-service to pass arbitrary strings to arbitrary services and receive the results back. Note that you may need to restart Emacs to access newly-available services.


F.4 GNUstep 支持

F.4 GNUstep Support

Emacs 可以在 GNUstep 下构建和运行,但仍有一些问题需要解决。有兴趣的开发人员应该联系 emacs-devel 邮件列表

Emacs can be built and run under GNUstep, but there are still issues to be addressed. Interested developers should contact the emacs-devel mailing list.


附录 G Emacs 和俳句

Appendix G Emacs and Haiku

Haiku 是一个类 Unix 操作系统,最初是操作系统 BeOS 的重新实现。

Haiku is a Unix-like operating system that originated as a re-implementation of the operating system BeOS.

本节介绍使用应用程序工具包(Haiku 原生的窗口系统)构建的 Emacs 的特性。这里描述的奇怪之处不适用于在没有窗口支持的情况下构建的 Haiku 上使用 Emacs,或者使用 X11 构建的 Emacs。

This section describes the peculiarities of using Emacs built with the Application Kit, the windowing system native to Haiku. The oddities described here do not apply to using Emacs on Haiku built without windowing support, or built with X11.


G.1 Haiku 下的安装和使用特性

G.1 Installation and usage peculiarities under Haiku

Emacs 在 Haiku 下安装两个独立的可执行文件;由用户决定哪一个最适合他:一个常规可执行文件,名称为小写emacs,以及一个包含俳句特定应用程序元数据的二进制文件,名称为Emacs

Emacs installs two separate executables under Haiku; it is up to the user to decide which one suits him best: A regular executable, with the lowercase name emacs, and a binary containing Haiku-specific application metadata, with the name Emacs.

如果您从 Tracker 启动 Emacs,或者想让 Tracker 使用 Emacs 打开文件,您应该使用名为 Emacs;的二进制文件。如果您打算在终端中使用 Emacs,或者希望启动单独的 Emacs 实例,或者不关心上述系统集成功能,请改用名为的二进制文件 emacs

If you are launching Emacs from the Tracker, or want to make the Tracker open files using Emacs, you should use the binary named Emacs; if you are going to use Emacs in the terminal, or wish to launch separate instances of Emacs, or do not care for the aforementioned system integration features, use the binary named emacs instead.

在俳句中,不支持不常见的修饰键(例如 Hyper 键)。默认情况下,super键与操作系统定义的option键对应,meta键与command键对应,control键与系统控制键对应,shift键与系统shift键对应。在标准 PC 键盘上,Haiku 应该将这些键映射到使用 GNU 系统的用户熟悉的位置,但这可能需要对系统配置进行一些调整才能工作。

On Haiku, unusual modifier keys such as the Hyper key are unsupported. By default, the super key corresponds with the option key defined by the operating system, the meta key with the command key, the control key with the system control key, and the shift key with the system shift key. On a standard PC keyboard, Haiku should map these keys to positions familiar to those using a GNU system, but this may require some adjustment to your system’s configuration to work.

使用系统超级键映射无法键入重音字符。

It is impossible to type accented characters using the system super key map.

您可以自定义系统已知的修饰键与 Emacs 已知的修饰键之间的对应关系。下面描述了允许这种情况的变量。

You can customize the correspondence between modifier keys known to the system, and those known to Emacs. The variables that allow for that are described below.

haiku-meta-keysym
haiku-meta-keysym

Emacs 将将其视为 Meta 键的系统修饰键。它默认为command.

The system modifier key that will be treated as the Meta key by Emacs. It defaults to command.

haiku-control-keysym
haiku-control-keysym

Emacs 将将其视为 Control 键的系统修饰键。它默认为control.

The system modifier key that will be treated as the Control key by Emacs. It defaults to control.

haiku-super-keysym
haiku-super-keysym

Emacs 将将其视为超级键的系统修饰键。它默认为option.

The system modifier key that will be treated as the Super key by Emacs. It defaults to option.

haiku-shift-keysym
haiku-shift-keysym

Emacs 将将其视为 Shift 键的系统修饰键。它默认为shift.

The system modifier key that will be treated as the Shift key by Emacs. It defaults to shift.

每个变量的值可以是符号commandcontroloptionshift、 或之一nilnil或任何其他值将导致使用默认值。

The value of each variable can be one of the symbols command, control, option, shift, or nil. nil or any other value will cause the default value to be used instead.

在 Haiku 上,Emacs 默认使用系统工具提示机制。这通常会导致工具提示响应更快,但工具提示将无法显示文本属性或面孔。如果您需要这些功能,请将变量自定义use-system-tooltipsnil值,Emacs 将使用它自己的工具提示实现。

On Haiku, Emacs defaults to using the system tooltip mechanism. This usually leads to more responsive tooltips, but the tooltips will not be able to display text properties or faces. If you need those features, customize the variable use-system-tooltips to the nil value, and Emacs will use its own implementation of tooltips.

与 X 窗口系统不同,Haiku 没有系统范围的资源数据库。由于许多重要选项是通过 X 资源指定的(请参阅X 选项和资源),因此提供了一个模拟:启动时,Emacs 将加载一个名为GNU Emacs在用户配置目录中(通常/启动/主页/配置/设置),这应该是一个扁平化的系统消息,其中键和值都是字符串,并分别对应于属性及其值。

Unlike the X window system, Haiku does not have a system-wide resource database. Since many important options are specified via X resources (see X Options and Resources), an emulation is provided: upon startup, Emacs will load a file named GNU Emacs inside the user configuration directory (normally /boot/home/config/settings), which should be a flattened system message where keys and values are both strings, and correspond to attributes and their values respectively.

您可以使用该工具创建这样的文件xmlbmessage

You can create such a file with the xmlbmessage tool.

G.1.1 Emacs 崩溃时该怎么办

G.1.1 What to do when Emacs crashes

如果变量haiku-debug-on-fatal-error不是 - nil,Emacs 将在收到致命信号时启动系统调试器。它默认为t.如果您的系统无法使用GDB,请在报告错误时附上系统调试器生成的报告。

If the variable haiku-debug-on-fatal-error is non-nil, Emacs will launch the system debugger when a fatal signal is received. It defaults to t. If GDB cannot be used on your system, please attach the report generated by the system debugger when reporting a bug.


G.2 Haiku 上的字体和字体后端选择

G.2 Font and font backend selection on Haiku

当使用 Haiku 窗口支持构建 Emacs 时,可以使用几种不同的字体后端构建。您可以通过在-xrm Emacs.fontBackend:BACKEND用于调用 Emacs 的命令行上指定来指定字体后端(其中BACKEND是下面指定的后端之一),或者通过更改帧参数来逐帧 指定font-backend

Emacs, when built with Haiku windowing support, can be built with several different font backends. You can specify font backends by specifying -xrm Emacs.fontBackend:BACKEND on the command line used to invoke Emacs, where BACKEND is one of the backends specified below, or on a per-frame basis by changing the font-backend frame parameter.

其中两个后端ftcrftcrhbX Window 系统上的对应后端相同。还有一个名为 的俳句专用后端haiku,它使用 App Server 来绘制字体,但目前不支持显示彩色字体和表情符号。

Two of these backends, ftcr and ftcrhb are identical to their counterparts on the X Window System. There is also a Haiku-specific backend named haiku, that uses the App Server to draw fonts, but does not at present support display of color font and emoji.


附录 H Emacs 和 Microsoft Windows/MS-DOS

Appendix H Emacs and Microsoft Windows/MS-DOS

本节描述在 Microsoft Windows 上使用 Emacs 的特殊性。其中一些特性也与 Microsoft 较旧的 MS-DOS 操作系统相关。但是,与 MS-DOS相关的 Emacs 功能将在单独的部分中进行描述(请参阅Emacs 和 MS-DOS)。

This section describes peculiarities of using Emacs on Microsoft Windows. Some of these peculiarities are also relevant to Microsoft’s older MS-DOS operating system. However, Emacs features that are relevant only to MS-DOS are described in a separate section (see Emacs and MS-DOS).

MS-Windows 是一个非自由操作系统;这意味着它剥夺了用户每个计算机用户应有的自由。这是不公平的。为了您的自由,我们强烈建议您切换到免费操作系统。

MS-Windows is a non-free operating system; that means it denies its users the freedom that every computer user deserves. That is an injustice. For your freedom’s sake, we urge you to switch to a free operating system.

我们在专有操作系统上支持 GNU Emacs,因为我们希望这种自由的味道能够激励用户摆脱它们。

We support GNU Emacs on proprietary operating systems because we hope this taste of freedom will inspire users to escape from them.

MS-Windows 上 Emacs 的行为与手册其余部分中记录的行为相当相似,包括对长文件名、多框架、滚动条、鼠标菜单和子进程的支持。但是,需要注意一些特殊的注意事项,此处对其进行了描述。

The behavior of Emacs on MS-Windows is reasonably similar to what is documented in the rest of the manual, including support for long file names, multiple frames, scroll bars, mouse menus, and subprocesses. However, a few special considerations apply, and they are described here.


H.1 如何在 MS-Windows 上启动 Emacs

H.1 How to Start Emacs on MS-Windows

在 MS-Windows 上启动 Emacs 有多种方法:

There are several ways of starting Emacs on MS-Windows:

  1. 从桌面快捷方式图标:在该图标上双击鼠标左键,或单击一次,然后按RET。桌面快捷方式应指定其“目标”(在快捷方式的“属性”中)完整的绝对文件名运行程序属于emacs.exe。这是因为运行程序 隐藏如果快捷方式的目标是则创建的控制台窗口emacs.exe(就 Windows 而言,这是一个控制台程序)。如果使用此方法,Emacs 将在快捷方式指定的目录中启动。要控制其位置,请右键单击快捷方式,选择“属性”,然后在“快捷方式”选项卡中根据您的喜好修改“开始于”字段。
  2. From the desktop shortcut icon: either double-click the left mouse button on the icon, or click once, then press RET. The desktop shortcut should specify as its “Target” (in the “Properties” of the shortcut) the full absolute file name of runemacs.exe, not of emacs.exe. This is because runemacs.exe hides the console window that would have been created if the target of the shortcut were emacs.exe (which is a console program, as far as Windows is concerned). If you use this method, Emacs starts in the directory specified by the shortcut. To control where that is, right-click on the shortcut, select “Properties”, and in the “Shortcut” tab modify the “Start in” field to your liking.
  3. 从任务栏快捷方式图标中,单击鼠标左键。自 Vista 以来的 Windows 版本允许您通过固定任务栏中显示的正在运行的程序的图标来创建此类快捷方式 。您可以使用 Emacs 执行此操作,但之后您必须更改固定快捷方式的属性才能运行 运行程序属于emacs.exe。您还可以通过在“开始”菜单中的 Emacs 图标上单击鼠标右键,然后选择“将 Emacs 固定到任务栏”固定到任务栏'。再次强调,一定要明确运行程序作为要运行的程序。您可以通过设置快捷方式属性的“开始于”字段来控制 Emacs 的启动位置。
  4. From a task-bar shortcut icon, by clicking once the left mouse button. Windows versions since Vista allow you to create such shortcuts by pinning the icon of a running program that appears in the task bar. You can do that with Emacs, but afterwards you will have to change the properties of the pinned shortcut to run runemacs.exe, not of emacs.exe. You can also pin Emacs to the task bar by clicking the right mouse button on its icon in the Start menu, then selecting ‘Pin to taskbar’. Once again, be sure to specify runemacs.exe as the program to run. You can control where Emacs starts by setting the “Start in” field of the shortcut’s Properties.
  5. 在命令提示符窗口中,通过在提示符处键入。在 Emacs 退出之前,您执行此操作的命令提示符窗口将无法调用其他命令。在这种情况下,Emacs 将在 Windows shell 的当前目录中启动。 emacs RET
  6. From the Command Prompt window, by typing emacs RET at the prompt. The Command Prompt window where you did that will not be available for invoking other commands until Emacs exits. In this case, Emacs will start in the current directory of the Windows shell.
  7. 在命令提示符窗口中,通过在提示符处键入。您执行此操作的命令提示符窗口将立即可用于调用其他命令。在这种情况下,Emacs 将在 Windows shell 的当前目录中启动。 runemacs RET
  8. From the Command Prompt window, by typing runemacs RET at the prompt. The Command Prompt window where you did that will be immediately available for invoking other commands. In this case, Emacs will start in the current directory of the Windows shell.
  9. 从 WindowsRun对话框(通常通过单击 按钮来访问 Start)。在对话框中键入内容将在相当于用户目录的 Windows 父目录中启动 Emacs ,请参阅MS-Windows 上的主目录和启动目录runemacs RETHOME
  10. From the Windows Run dialog (normally reached by clicking the Start button). Typing runemacs RET into the dialog will start Emacs in the parent directory of the Windows equivalent of your user’s HOME directory, see HOME and Startup Directories on MS-Windows.
  11. 通过emacsclient.exe或者emacsclientw.exe,它允许您从其他程序调用 Emacs,并重用正在运行的 Emacs 进程来服务其他程序所需的编辑作业。请参阅使用 Emacs 作为服务器。和...之间的不同emacsclient.exeemacsclientw.exe区别在于前者是控制台程序,而后者是Windows GUI程序。这两个程序都会等待 Emacs 发出编辑作业完成的信号,然后退出并将控制权返回给调用它们的程序。在每种情况下使用哪一种取决于需要编辑服务的程序的期望。如果该程序本身是控制台(文本模式)程序,您应该使用emacsclient.exe,以便其任何消息和提示都出现在与调用程序相同的命令窗口中。相比之下,如果调用程序是 GUI 程序,那么最好使用emacsclientw.exe, 因为 emacsclient.exe如果从 GUI 程序调用,将弹出一个命令窗口。您想要的一个值得注意的情况 emacsclientw.exe当您在 Windows 资源管理器中右键单击文件并从弹出菜单中选择“打开方式”时。使用 '--备用编辑器=' 或者 '-Aemacsclient' 选项,如果调用时 Emacs 可能未运行(或未作为服务器运行) ,这将始终为您提供一个编辑器。当通过调用时 emacsclient,Emacs 将在调用的程序的当前目录中启动emacsclient
  12. Via emacsclient.exe or emacsclientw.exe, which allow you to invoke Emacs from other programs, and to reuse a running Emacs process for serving editing jobs required by other programs. See Using Emacs as a Server. The difference between emacsclient.exe and emacsclientw.exe is that the former is a console program, while the latter is a Windows GUI program. Both programs wait for Emacs to signal that the editing job is finished, before they exit and return control to the program that invoked them. Which one of them to use in each case depends on the expectations of the program that needs editing services. If that program is itself a console (text-mode) program, you should use emacsclient.exe, so that any of its messages and prompts appear in the same command window as those of the invoking program. By contrast, if the invoking program is a GUI program, you will be better off using emacsclientw.exe, because emacsclient.exe will pop up a command window if it is invoked from a GUI program. A notable situation where you would want emacsclientw.exe is when you right-click on a file in the Windows Explorer and select “Open With” from the pop-up menu. Use the ‘--alternate-editor=’ or ‘-a’ options if Emacs might not be running (or not running as a server) when emacsclient is invoked—that will always give you an editor. When invoked via emacsclient, Emacs will start in the current directory of the program that invoked emacsclient.

请注意,由于 MS-Windows 的限制,Emacs 无法在同一会话中同时拥有 GUI 和文本模式框架。它还无法在多个命令提示符窗口上打开文本模式框架,因为每个 Windows 程序在任何给定时间只能有一个控制台。由于这些原因,如果您emacsclient使用 -C选项,并且 Emacs 服务器在文本模式会话中运行,Emacs 将始终 在启动它的同一命令提示符窗口中创建一个新的文本模式框架;仅当服务器在 GUI 会话中运行时才会创建 GUI 框架。同样,如果您emacsclient使用-t选项,如果服务器在 GUI 会话中运行,Emacs 将创建一个 GUI 框架,或者当会话在命令提示符 窗口中以文本模式运行时,Emacs 将创建文本模式框架。请参阅emacsclient选项

Note that, due to limitations of MS-Windows, Emacs cannot have both GUI and text-mode frames in the same session. It also cannot open text-mode frames on more than a single Command Prompt window, because each Windows program can have only one console at any given time. For these reasons, if you invoke emacsclient with the -c option, and the Emacs server runs in a text-mode session, Emacs will always create a new text-mode frame in the same Command Prompt window where it was started; a GUI frame will be created only if the server runs in a GUI session. Similarly, if you invoke emacsclient with the -t option, Emacs will create a GUI frame if the server runs in a GUI session, or a text-mode frame when the session runs in text mode in a Command Prompt window. See emacsclient Options.


H.2 文本文件和二进制文件

H.2 Text Files and Binary Files

GNU Emacs 使用换行符来分隔文本行。这是 GNU、Unix 和其他 POSIX 兼容系统上使用的约定。

GNU Emacs uses newline characters to separate text lines. This is the convention used on GNU, Unix, and other POSIX-compliant systems.

相比之下,MS-DOS 和 MS-Windows 通常使用回车符和换行符(两个字符序列)来分隔文本行。 (换行符与换行符相同。)因此,为了使用 Emacs 方便地编辑典型文件,需要转换这些行尾 (EOL) 序列。这就是 Emacs 通常所做的:读取文件时将回车换行转换为换行符,写入文件时将换行符转换为回车换行。处理国际字符代码转换的相同机制也执行此转换(请参阅编码系统)。

By contrast, MS-DOS and MS-Windows normally use carriage return followed by linefeed, a two-character sequence, to separate text lines. (Linefeed is the same character as newline.) Therefore, convenient editing of typical files with Emacs requires conversion of these end-of-line (EOL) sequences. And that is what Emacs normally does: it converts carriage return followed by linefeed into newline when reading files, and converts newline into carriage return followed by linefeed when writing files. The same mechanism that handles conversion of international character codes does this conversion also (see Coding Systems).

大多数文件的这种特殊格式转换的一个后果是 Emacs 报告的字符位置(请参阅光标位置信息)与操作系统已知的文件大小信息不一致。

One consequence of this special format-conversion of most files is that character positions as reported by Emacs (see Cursor Position Information) do not agree with the file size information known to the operating system.

此外,如果 Emacs 从文件内容中识别出它使用换行符而不是回车符后跟换行符作为其行分隔符,则在读取或写入该文件时,它不会执行 EOL 转换。因此,您可以在 MS-DOS 上读取和编辑来自 GNU 和 Unix 系统的文件,而无需付出特别的努力,并且在您编辑它们后,它们将保留其 Unix 风格的行尾约定。

In addition, if Emacs recognizes from a file’s contents that it uses newline rather than carriage return followed by linefeed as its line separator, it does not perform EOL conversion when reading or writing that file. Thus, you can read and edit files from GNU and Unix systems on MS-DOS with no special effort, and they will retain their Unix-style end-of-line convention after you edit them.

模式行指示当前缓冲区是否使用行尾转换。如果缓冲区使用 MS-DOS 行尾转换,则 Emacs 的 MS-Windows 版本会显示反斜杠 '\' 在模式行开头附近的编码系统助记符之后(请参阅模式行)。如果未执行 EOL 翻译,则字符串 '(Unix)显示 ' 而不是反斜杠,以提醒您文件的 EOL 格式不是通常的回车符后跟换行符。

The mode line indicates whether end-of-line translation was used for the current buffer. If MS-DOS end-of-line translation is in use for the buffer, the MS-Windows build of Emacs displays a backslash ‘\’ after the coding system mnemonic near the beginning of the mode line (see The Mode Line). If no EOL translation was performed, the string ‘(Unix)’ is displayed instead of the backslash, to alert you that the file’s EOL format is not the usual carriage return followed by linefeed.

要访问文件并指定它是使用 DOS 样式还是 Unix 样式行结束符,请指定编码系统(请参阅指定文件文本的编码系统)。例如 访问文件C-x RET c unix RET C-x C-f foobar.txtfoob​​ar.txt无需转换 EOL;如果某行以回车符后跟换行符对结尾,Emacs 将显示 '^M' 在该行的末尾。同样,您可以使用该命令指示 Emacs 以指定的 EOL 格式保存缓冲区。例如,要以 Unix EOL 格式保存缓冲区,请键入。如果您访问经过 DOS EOL 转换的文件,然后将其保存为 Unix EOL 格式,这样可以有效地将文件转换为 Unix EOL 样式,就像程序一样 。 C-x RET fC-x RET f unix RET C-x C-sdos2unix

To visit a file and specify whether it uses DOS-style or Unix-style end-of-line, specify a coding system (see Specifying a Coding System for File Text). For example, C-x RET c unix RET C-x C-f foobar.txt visits the file foobar.txt without converting the EOLs; if some line ends with a carriage return followed by linefeed pair, Emacs will display ‘^M’ at the end of that line. Similarly, you can direct Emacs to save a buffer in a specified EOL format with the C-x RET f command. For example, to save a buffer with Unix EOL format, type C-x RET f unix RET C-x C-s. If you visit a file with DOS EOL conversion, then save it with Unix EOL format, that effectively converts the file to Unix EOL style, like the dos2unix program.

当您使用 NFS、Samba 或其他类似方法访问驻留在使用 GNU 或 Unix 系统的计算机上的文件系统时,Emacs 不应对这些文件系统中的任何文件执行行尾转换 — 即使您创建了一个新文件。要请求此操作,请通过调用函数将这些文件系统指定为未翻译的w32-add-untranslated-filesystem文件系统。它需要一个参数:文件系统名称,包括驱动器号和可选的目录。例如,

When you use NFS, Samba, or some other similar method to access file systems that reside on computers using GNU or Unix systems, Emacs should not perform end-of-line translation on any files in these file systems—not even when you create a new file. To request this, designate these file systems as untranslated file systems by calling the function w32-add-untranslated-filesystem. It takes one argument: the file system name, including a drive letter and optionally a directory. For example,

(w32-add-untranslated-filesystem "Z:")
(w32-add-untranslated-filesystem "Z:")

将驱动器 Z 指定为未翻译的文件系统,并且

designates drive Z as an untranslated file system, and

(w32-add-untranslated-filesystem "Z:\\foo")
(w32-add-untranslated-filesystem "Z:\\foo")

指定目录\foo在驱动器 Z 上作为未翻译的文件系统。

designates directory \foo on drive Z as an untranslated file system.

最常见的是你会w32-add-untranslated-filesystem在你的 .emacs或者初始化程序初始化文件,或在站点启动.el 以便您网站上的所有用户都能从中受益。

Most often you would use w32-add-untranslated-filesystem in your .emacs or init.el init file, or in site-start.el so that all the users at your site get the benefit of it.

要取消 的效果w32-add-untranslated-filesystem,请使用该功能w32-remove-untranslated-filesystem。该函数采用一个参数,该参数应该是一个字符串,就像之前在w32-add-untranslated-filesystem.

To countermand the effect of w32-add-untranslated-filesystem, use the function w32-remove-untranslated-filesystem. This function takes one argument, which should be a string just like the one that was used previously with w32-add-untranslated-filesystem.

将文件系统指定为未翻译不会影响字符集转换,只会影响行尾转换。本质上,它指示 Emacs 默认使用在行尾使用换行符的 Unix 风格约定创建新文件。请参阅编码系统

Designating a file system as untranslated does not affect character set conversion, only end-of-line conversion. Essentially, it directs Emacs to default to creating new files with the Unix-style convention of using newline at the end of a line. See Coding Systems.


MS-Windows 上的 H.3 文件名

H.3 File Names on MS-Windows

MS-Windows 和 MS-DOS 通常使用反斜杠,'\',用于分隔文件名中的名称单元,而不是其他系统上使用的斜杠。 MS-DOS/MS-Windows 上的 Emacs 允许使用斜杠或反斜杠,并且还知道文件名中的驱动器号。

MS-Windows and MS-DOS normally use a backslash, ‘\’, to separate name units within a file name, instead of the slash used on other systems. Emacs on MS-DOS/MS-Windows permits use of either slash or backslash, and also knows about drive letters in file names.

在 MS-DOS/MS-Windows 上,文件名不区分大小写,因此 Emacs 默认情况下会在完成过程中忽略文件名中的字母大小写。为此,在 MS-DOS/MS-Windows 上的默认值为read-file-name-completion-ignore-case non- 。nil请参阅完成选项

On MS-DOS/MS-Windows, file names are case-insensitive, so Emacs by default ignores letter-case in file names during completion. To this end, the default value of read-file-name-completion-ignore-case is non-nil on MS-DOS/MS-Windows. See Completion Options.

该变量w32-get-true-file-attributes控制 Emacs 是否应该发出额外的系统调用来更准确地确定file-attributes 和等原语中的文件属性directory-files-and-attributes。需要这些额外的调用来报告特殊文件(例如管道)的正确文件所有权、链接计数和文件类型。如果没有这些系统调用,文件所有权将归属于当前用户,链接计数将始终报告为 1,特殊文件将报告为常规文件。

The variable w32-get-true-file-attributes controls whether Emacs should issue additional system calls to determine more accurately file attributes in primitives like file-attributes and directory-files-and-attributes. These additional calls are needed to report correct file ownership, link counts and file types for special files such as pipes. Without these system calls, file ownership will be attributed to the current user, link counts will be always reported as 1, and special files will be reported as regular files.

如果此变量的值为local(默认值),Emacs 将仅对本地固定驱动器上的文件发出这些附加系统调用。任何其他非nil值意味着即使对于可移动卷和远程卷也会执行此操作,这可能会减慢 Dired 和其他相关功能的速度。 means的值nil永远不会发出那些系统调用。非nil值在支持硬链接和文件安全性的 NTFS 卷上比在 FAT、FAT32 和 exFAT 卷上更有用。

If the value of this variable is local (the default), Emacs will issue these additional system calls only for files on local fixed drives. Any other non-nil value means do this even for removable and remote volumes, where this could potentially slow down Dired and other related features. The value of nil means never issue those system calls. Non-nil values are more useful on NTFS volumes, which support hard links and file security, than on FAT, FAT32, and exFAT volumes.

与 Unix 不同,MS-Windows 文件系统限制文件名中可以​​使用的字符集。不允许使用以下字符:

Unlike Unix, MS-Windows file systems restrict the set of characters that can be used in a file name. The following characters are not allowed:

  • shell 重定向符号 '<','>', 和 '|'。
  • Shell redirection symbols ‘<’, ‘>’, and ‘|’.
  • 冒号 ':'(驱动器号后面除外)。
  • Colon ‘:’ (except after the drive letter).
  • 正斜杠'/' 和反斜杠 '\'(作为目录分隔符除外)。
  • Forward slash ‘/’ and backslash ‘\’ (except as directory separators).
  • 通配符 '*' 和 ''。
  • Wildcard characters ‘*’ and ‘?’.
  • 代码点为十进制 1 到 31 的控制字符。特别是,文件名中不允许出现换行符。
  • Control characters whose codepoints are 1 through 31 decimal. In particular, newlines in file names are not allowed.
  • 空字符,其代码点为零(Unix 文件系统上也存在此限制)。
  • The null character, whose codepoint is zero (this limitation exists on Unix filesystems as well).

此外,引用任何名称与 DOS 字符设备匹配的文件,例如零点或者脂蛋白T1或者PRN或者无论有或没有任何文件扩展名,都将始终解析为任何目录中的那些字符设备。因此,只有当您想使用相应的字符设备时才使用此类文件名。

In addition, referencing any file whose name matches a DOS character device, such as NUL or LPT1 or PRN or CON, with or without any file-name extension, will always resolve to those character devices, in any directory. Therefore, only use such file names when you want to use the corresponding character device.


lsH.4 MS-Windows 上的仿真

H.4 Emulation of ls on MS-Windows

Dired 通常使用外部程序ls 来生成显示在 Dired 缓冲区中的目录列表(请参阅Dired,目录编辑器)。然而,尽管GNU ls的多个端口 可用,但 MS-Windows 和 MS-DOS 系统并未附带这样的程序。因此,这些系统上的 Emacs通过使用 Lisp进行模拟 lsls-lisp.el包裹。尽管 ls-lisp.el提供了相当完整的模拟ls,有一些该模拟特有的选项和功能;本节对它们进行了描述。

Dired normally uses the external program ls to produce the directory listing displayed in Dired buffers (see Dired, the Directory Editor). However, MS-Windows and MS-DOS systems don’t come with such a program, although several ports of GNU ls are available. Therefore, Emacs on those systems emulates ls in Lisp, by using the ls-lisp.el package. While ls-lisp.el provides a reasonably full emulation of ls, there are some options and features peculiar to that emulation; they are described in this section.

ls仿真支持许多交换机ls,但并不支持所有交换机。以下是它支持的开关列表:-A,-A,-B,-C, -C,-G,-G,-H,-我,-n, -R,-r,-S,-s,-t,-U, -u,-v, 和-X。这-Fswitch 受到部分支持(它附加对文件进行分类的字符,但不会阻止符号链接跟随)。

The ls emulation supports many of the ls switches, but it doesn’t support all of them. Here’s the list of the switches it does support: -A, -a, -B, -C, -c, -G, -g, -h, -i, -n, -R, -r, -S, -s, -t, -U, -u, -v, and -X. The -F switch is partially supported (it appends the character that classifies the file, but does not prevent symlink following).

在 MS-Windows 和 MS-DOS 上,ls-lisp.ells在构建 Emacs 时预加载,因此在这些平台上始终使用Lisp 模拟。如果您有移植ls,设置 ls-lisp-use-insert-directory-program为非值nil将恢复为使用由该变量命名的外部程序 insert-directory-program

On MS-Windows and MS-DOS, ls-lisp.el is preloaded when Emacs is built, so the Lisp emulation of ls is always used on those platforms. If you have a ported ls, setting ls-lisp-use-insert-directory-program to a non-nil value will revert to using an external program named by the variable insert-directory-program.

其中的顺序ls-lisp.el对文件进行排序取决于下面描述的几个可自定义选项。

The order in which ls-lisp.el sorts files depends on several customizable options described below.

默认排序顺序遵循从系统区域设置派生的特定于区域设置的规则。您可以通过自定义ls-lisp-use-string-collate一个值来使订单与区域设置无关nil

The default sorting order follows locale-specific rules derived from your system locale. You can make the order locale-independent by customizing ls-lisp-use-string-collate to a nil value.

在 GNU 和 Unix 系统上,当区域设置的编码为 UTF-8 时,排序规则遵循 Unicode 排序算法 ( UCA )。为了在 MS-Windows 上产生类似的效果,该变量 ls-lisp-UCA-like-collation应该具有非值nil(这是默认值)。生成的排序顺序会忽略标点符号、符号字符和空白字符,因此 .foobar,富巴富酒吧会一起出现而不是分开。

On GNU and Unix systems, when the locale’s encoding is UTF-8, the collation order follows the Unicode Collation Algorithm (UCA). To have a similar effect on MS-Windows, the variable ls-lisp-UCA-like-collation should have a non-nil value (this is the default). The resulting sorting order ignores punctuation, symbol characters, and whitespace characters, so .foobar, foobar and foo bar will appear together rather than far apart.

默认情况下,ls-lisp.el对它生成的目录列表使用区分大小写的排序顺序;这样列表看起来与其他平台上的相同。如果您希望文件按不区分大小写的顺序排序,请将变量设置ls-lisp-ignore-case为非值nil

By default, ls-lisp.el uses a case-sensitive sort order for the directory listing it produces; this is so the listing looks the same as on other platforms. If you wish that the files be sorted in case-insensitive order, set the variable ls-lisp-ignore-case to a non-nil value.

默认情况下,文件和子目录一起排序,以模拟ls.然而,本机 MS-Windows/MS-DOS 文件管理器在文件之前列出目录;如果您想要这种行为,请将该选项自定义ls-lisp-dirs-first为非值nil

By default, files and subdirectories are sorted together, to emulate the behavior of ls. However, native MS-Windows/MS-DOS file managers list the directories before the files; if you want that behavior, customize the option ls-lisp-dirs-first to a non-nil value.

该变量ls-lisp-verbosity控制文件属性ls-lisp.el显示。该值应该是或者 nil包含一个或多个符号 linksuid和的列表gid。 表示显示与文件数据关联(也称为链接links)的不同文件名的计数 ;这仅对 NTFS 卷有用。 表示显示拥有该文件的用户的数字标识符。 表示显示文件所有者组的数字标识符。默认值为ie,显示所有 3 个可选属性。该值 意味着不显示任何这些属性。 uidgid(links uid gid)nil

The variable ls-lisp-verbosity controls the file attributes that ls-lisp.el displays. The value should be either nil or a list that contains one or more of the symbols links, uid, and gid. links means display the count of different file names that are associated with (a.k.a. links to) the file’s data; this is only useful on NTFS volumes. uid means display the numerical identifier of the user who owns the file. gid means display the numerical identifier of the file owner’s group. The default value is (links uid gid) i.e., all the 3 optional attributes are displayed. The value nil means not to display any of these attributes.

该变量通过设置上述 3 个选项的默认值来ls-lisp-emulation控制仿真的风格 : 、 和。该选项的值可以是以下符号之一: lsls-lisp-ignore-casels-lisp-dirs-firstls-lisp-verbosity

The variable ls-lisp-emulation controls the flavor of the ls emulation by setting the defaults for the 3 options described above: ls-lisp-ignore-case, ls-lisp-dirs-first, and ls-lisp-verbosity. The value of this option can be one of the following symbols:

GNU
GNU
nil
nil

模拟GNU系统;这是默认设置。这设置 ls-lisp-ignore-casels-lisp-dirs-firstnills-lisp-verbosity(links uid gid)

Emulate GNU systems; this is the default. This sets ls-lisp-ignore-case and ls-lisp-dirs-first to nil, and ls-lisp-verbosity to (links uid gid).

UNIX
UNIX

模拟 Unix 系统。喜欢GNU,但设定 ls-lisp-verbosity(links uid)

Emulate Unix systems. Like GNU, but sets ls-lisp-verbosity to (links uid).

MacOS
MacOS

模拟 macOS。设置ls-lisp-ignore-caset、 和ls-lisp-dirs-first以及。 ls-lisp-verbositynil

Emulate macOS. Sets ls-lisp-ignore-case to t, and ls-lisp-dirs-first and ls-lisp-verbosity to nil.

MS-Windows
MS-Windows

模拟 MS-Windows。在 Windows 9X 上将ls-lisp-ignore-case和 设置ls-lisp-dirs-firstt、 ,在现代版本的 Windows 上设置ls-lisp-verbosity为 。请注意,即使在 Windows 上,默认模拟也不是,因为这些平台上的许多 Emacs 用户更喜欢GNU默认值。 nilt MS-Windows

Emulate MS-Windows. Sets ls-lisp-ignore-case and ls-lisp-dirs-first to t, and ls-lisp-verbosity to nil on Windows 9X and to t on modern versions of Windows. Note that the default emulation is not MS-Windows, even on Windows, since many users of Emacs on those platforms prefer the GNU defaults.

的任何其他值ls-lisp-emulation均与 相同GNU。自定义此选项会调用该函数ls-lisp-set-options来根据需要更新 3 个从属选项。如果您更改此变量的值后没有使用自定义ls-lisp.el已加载(请注意,它在 MS-Windows 和 MS-DOS 上预加载),您可以手动调用该函数以获得相同的结果。

Any other value of ls-lisp-emulation means the same as GNU. Customizing this option calls the function ls-lisp-set-options to update the 3 dependent options as needed. If you change the value of this variable without using customize after ls-lisp.el is loaded (note that it is preloaded on MS-Windows and MS-DOS), you can call that function manually for the same result.

该变量ls-lisp-support-shell-wildcards控制如何支持文件名模式:如果是非nil(默认),则它们被视为 shell 样式通配符;否则它们将被视为 Emacs 正则表达式。

The variable ls-lisp-support-shell-wildcards controls how file-name patterns are supported: if it is non-nil (the default), they are treated as shell-style wildcards; otherwise they are treated as Emacs regular expressions.

该变量ls-lisp-format-time-list定义如何格式化文件的日期和时间。 除非 Emacs 无法确定当前区域设置,否则该变量的值将被忽略。 (但是,如果 的值为ls-lisp-use-localized-time-format非 - ,即使当前语言环境可用, nilEmacs 也会遵循;请参见下文。)ls-lisp-format-time-list

The variable ls-lisp-format-time-list defines how to format the date and time of files. The value of this variable is ignored, unless Emacs cannot determine the current locale. (However, if the value of ls-lisp-use-localized-time-format is non-nil, Emacs obeys ls-lisp-format-time-list even if the current locale is available; see below.)

的值ls-lisp-format-time-list是一个包含 2 个字符串的列表。如果文件在当年被修改,则使用第一个字符串,而第二个字符串用于较旧的文件。在这两个字符串中,您可以使用 '%'-替换部分时间的序列。例如:

The value of ls-lisp-format-time-list is a list of 2 strings. The first string is used if the file was modified within the current year, while the second string is used for older files. In each of these two strings you can use ‘%’-sequences to substitute parts of the time. For example:

(“%b %e %H:%M”“%b %e %Y”)
("%b %e %H:%M" "%b %e  %Y")

请注意,替换这些 ' 的字符串%'-序列取决于当前区域设置。有关格式时间规范的更多信息, 请参阅Emacs Lisp 参考手册中的时间解析。

Note that the strings substituted for these ‘%’-sequences depend on the current locale. See Time Parsing in The Emacs Lisp Reference Manual, for more about format time specs.

通常,Emacs 使用传统或 ISO 风格的时间格式来格式化文件时间戳。但是,如果变量的值为 ls-lisp-use-localized-time-format非 - nil,Emacs 将根据指定的内容格式化文件时间戳 ls-lisp-format-time-list。这 '%'-序列 ls-lisp-format-time-list生成与区域设置相关的月份和日期名称,这可能会导致 Dired 显示中的列未对齐。ls-lisp-use-localized-time-format的 默认值为nil

Normally, Emacs formats the file time stamps in either traditional or ISO-style time format. However, if the value of the variable ls-lisp-use-localized-time-format is non-nil, Emacs formats file time stamps according to what ls-lisp-format-time-list specifies. The ‘%’-sequences in ls-lisp-format-time-list produce locale-dependent month and day names, which might cause misalignment of columns in Dired display. The default value of ls-lisp-use-localized-time-format is nil.


MS-Windows 上的 H.5 主目录和启动目录

H.5 HOME and Startup Directories on MS-Windows

Windows 中的 等效项HOME用户特定的应用程序数据目录。实际位置取决于Windows版本;典型值为C:\Documents and Settings\用户名\Application Data在 Windows 2000 到 XP 上, C:\Users\用户名\AppData\Roaming在 Windows Vista 及更高版本上,以及C:\WINDOWS\应用程序数据或者 C:\WINDOWS\Profiles\用户名\Application Data在 Windows 9X/ME 上。如果该目录不存在或无法访问,Emacs 会回退到C:\作为 的默认值HOME

The Windows equivalent of HOME is the user-specific application data directory. The actual location depends on the Windows version; typical values are C:\Documents and Settings\username\Application Data on Windows 2000 up to XP, C:\Users\username\AppData\Roaming on Windows Vista and later, and either C:\WINDOWS\Application Data or C:\WINDOWS\Profiles\username\Application Data on Windows 9X/ME. If this directory does not exist or cannot be accessed, Emacs falls back to C:\ as the default value of HOME.

HOME您可以通过显式设置环境变量HOME以指向系统上的任何目录来 覆盖此默认值。HOME可以从命令 shell 提示符或从 '特性' 的对话框我的电脑'。 HOME也可以在系统注册表中设置,请参阅MS-Windows 系统注册表

You can override this default value of HOME by explicitly setting the environment variable HOME to point to any directory on your system. HOME can be set either from the command shell prompt or from ‘Properties’ dialog of ‘My Computer’. HOME can also be set in the system registry, see The MS-Windows System Registry.

为了与旧版本的 Emacs 28兼容,如果有一个名为.emacsC:\, 驱动器根目录C:,并且HOME既不在环境中也不在注册表中设置,Emacs 将视为C:\作为默认HOME位置,并且不会查找应用程序数据目录,即使它存在。请注意,仅.emacs正在寻找C:\;旧名字_emacs(见下文)不是。这种使用C:\.emacs不推荐使用定义HOME; Emacs 将在启动期间显示有关其使用的警告。

For compatibility with older versions of Emacs28, if there is a file named .emacs in C:\, the root directory of drive C:, and HOME is set neither in the environment nor in the Registry, Emacs will treat C:\ as the default HOME location, and will not look in the application data directory, even if it exists. Note that only .emacs is looked for in C:\; the older name _emacs (see below) is not. This use of C:\.emacs to define HOME is deprecated; Emacs will display a warning about its use during startup.

无论最终位置是什么,Emacs 都会设置环境变量的内部值 HOME来指向它,并且它将将该位置用于通常在主目录中查找或创建的其他文件和目录。

Whatever the final place is, Emacs sets the internal value of the HOME environment variable to point to it, and it will use that location for other files and directories it normally looks for or creates in your home directory.

您始终可以通过键入 来了解 Emacs 认为您的主目录的位置。这应该显示主目录中的文件列表,并在第一行显示其全名。同样,要访问您的初始化文件,请键入(假设文件名是C-x d ~/ RETC-x C-f ~/.emacs RET.emacs)。

You can always find out what Emacs thinks is your home directory’s location by typing C-x d ~/ RET. This should present the list of files in the home directory, and show its full name on the first line. Likewise, to visit your init file, type C-x C-f ~/.emacs RET (assuming the file’s name is .emacs).

您的 init 文件可以具有Emacs 初始化文件中提到的任何名称。

Your init file can have any name mentioned in The Emacs Initialization File.

由于 MS-DOS 不允许文件名带有前导点,并且较旧的 Windows 系统很难创建具有此类名称的文件,因此 Emacs 的 Windows 端口支持 init 文件名_emacs,如果这样的文件存在于主目录中并且.emacs才不是。该名称已被视为已过时,因此如果使用该名称,Emacs 将显示警告。

Because MS-DOS does not allow file names with leading dots, and older Windows systems made it hard to create files with such names, the Windows port of Emacs supports an init file name _emacs, if such a file exists in the home directory and .emacs does not. This name is considered obsolete, so Emacs will display a warning if it is used.


H.6 MS-Windows 上的键盘使用

H.6 Keyboard Usage on MS-Windows

本节介绍与 Emacs 中键盘输入相关的 Windows 特定功能。

This section describes the Windows-specific features related to keyboard input in Emacs.

许多在 MS-Windows 程序中常规使用的组合键(称为“键盘快捷键”)与传统的 Emacs 键绑定发生冲突。 (这些 Emacs 键绑定是在 Microsoft 成立前几年建立的。)冲突的示例包括 C-cC-xC-zC-a。您可以通过启用 CUA 模式(请参阅CUA 绑定)来重新定义其中一些,使其含义更像 MS-Windows 含义。另一个可选功能是删除选择模式(请参阅在区域上操作), 它将使 Emacs 的行为像其他 Windows 应用程序一样。

Many key combinations (known as “keyboard shortcuts”) that have conventional uses in MS-Windows programs conflict with traditional Emacs key bindings. (These Emacs key bindings were established years before Microsoft was founded.) Examples of conflicts include C-c, C-x, C-z, and C-a. You can redefine some of them with meanings more like the MS-Windows meanings by enabling CUA Mode (see CUA Bindings). Another optional feature which will make Emacs behave like other Windows applications is Delete Selection mode (see Operating on the Region).

默认情况下,标记的键Alt将映射为Meta 键。如果您希望它生成Alt修饰符,请将变量设置w32-alt-is-meta为一个nil值。

By default, the key labeled Alt is mapped as the Meta key. If you wish it to produce the Alt modifier instead, set the variable w32-alt-is-meta to a nil value.

MS-Windows 保留某些组合键,例如 和一些 Windows 组合键,供其自己使用。这些组合键在 Emacs 看到之前就被系统截获。此外,在 Windows 10 上,所有 Windows 按键组合均由系统保留,即使系统当前没有为特定组合定义热键,它们也永远不会传播到应用程序。您可以使用该函数允许 Emacs 看到按键序列,而不是被 Windows 抓取。当注册为热键时,组合键会在 Windows 处理之前从系统的输入队列中拉出,从而有效地覆盖 Windows 中该键序列的特殊含义。该覆盖仅在 Emacs 处于活动状态时有效;对于前台的其他应用程序,按键行为正常。 Alt-TABw32-register-hot-key

MS-Windows reserves certain key combinations, such as Alt-TAB and a number of Windows key combinations, for its own use. These key combinations are intercepted by the system before Emacs can see them. Also, on Windows 10, all Windows key combinations are reserved by the system in such a way that they are never propagated to applications, even if the system does not currently define a hotkey on the specific combination. You can use the w32-register-hot-key function to allow a key sequence to be seen by Emacs instead of being grabbed by Windows. When registered as a hot key, the key combination is pulled out of the system’s input queue before it is handled by Windows, effectively overriding the special meaning of that key sequence for Windows. The override is only effective when Emacs is active; with other applications on the foreground the keys behave normally.

的参数w32-register-hot-key必须是带有单个修饰符的单个键,采用 可以接受的向量形式 define-key。 control 和 shift 修饰符对参数没有影响。Alt如果 w32-alt-is-metais t(默认),则 meta 修饰符被解释为键,而 super 和 hyper 修饰符则根据w32-lwindow-modifier和的绑定进行解释w32-rwindow-modifier。此外,带有尾部破折号但没有键的修饰符表示该修饰符的所有 Windows 定义的热键都将被覆盖以支持 Emacs。

The argument to w32-register-hot-key must be a single key with a single modifier, in vector form that would be acceptable to define-key. The control and shift modifiers have no effect on the argument. The meta modifier is interpreted as the Alt key if w32-alt-is-meta is t (the default), and the super and hyper modifiers are interpreted according to the bindings of w32-lwindow-modifier and w32-rwindow-modifier. Additionally, a modifier with the trailing dash but with no key indicates that all Windows defined hotkeys for that modifier are to be overridden in the favor of Emacs.

比如(w32-register-hot-key [M-tab])让你 在Emacs中正常使用;例如,完成顶层点处的单词或符号,或者在增量搜索期间根据先前查找的字符串完成当前搜索字符串。 with 绑定到禁用所有 Windows 自己的基于 Windows 键的快捷方式。29M-TAB(w32-register-hot-key [s-])w32-lwindow-modifiersuper

For example, (w32-register-hot-key [M-tab]) lets you use M-TAB normally in Emacs; for instance, to complete the word or symbol at point at top level, or to complete the current search string against previously sought strings during incremental search. (w32-register-hot-key [s-]) with w32-lwindow-modifier bound to super disables all the Windows’ own Windows key based shortcuts.29

请注意,w32-register-hot-key检查 w32-[lr]window-modifier函数调用时的值。因此,您可以先设置w32-lwindow-modifieras super,然后调用(w32-register-hot-key [s-r]),最后 也w32-rwindow-modifier设置。super结果是,左 Windows 键将调用R您在 Emacs 中为该组合绑定的任何功能,而右 Windows 键将调用并R打开 WindowsRun对话框。

Note that w32-register-hot-key checks the w32-[lr]window-modifier values at the time of the function call. Thus, you can set w32-lwindow-modifier as super, then call (w32-register-hot-key [s-r]), and finally set w32-rwindow-modifier as super as well. The result is that the left Windows key together with R invokes whichever function you have bound for the combination in Emacs, and the right Windows key and R opens the Windows Run dialog.

热键注册始终还包括给定热键的所有 Shift 和 Control 修饰符组合;也就是说,注册s-a为热键还可以为您提供S-s-aC-s-aC-S-s-a

The hotkey registrations always also include all the shift and control modifier combinations for the given hotkey; that is, registering s-a as a hotkey gives you S-s-a, C-s-a and C-S-s-a as well.

在Windows 98 和ME 上,热键注册受到更多限制。所需的热键必须始终完全指定,并且 w32-phantom-key-code可以进行自定义以实现所需的结果。

On Windows 98 and ME, the hotkey registration is more restricted. The desired hotkey must always be fully specified, and w32-phantom-key-code can be customized to achieve desired results.

该函数反转其参数键序列 w32-unregister-hot-key的效果 。w32-register-hot-key

The function w32-unregister-hot-key reverses the effect of w32-register-hot-key for its argument key sequence.

默认情况下,该CapsLock键仅影响普通字符键(它将小写字符转换为其大写变体)。但是,如果将变量设置 w32-capslock-is-shiftlock为非nil值,则该 CapsLock键也会影响非字符键,就像您SHIFT在键入非字符键时按下该键一样。

By default, the CapsLock key only affects normal character keys (it converts lower-case characters to their upper-case variants). However, if you set the variable w32-capslock-is-shiftlock to a non-nil value, the CapsLock key will affect non-character keys as well, as if you pressed the SHIFT key while typing the non-character key.

如果变量w32-enable-caps-lock被设置为一个nil 值,则CapsLock按键会生成符号,capslock 而不是键入按键的移位版本。默认值为 t

If the variable w32-enable-caps-lock is set to a nil value, the CapsLock key produces the symbol capslock instead of the shifted version of typed keys. The default value is t.

类似地,如果w32-enable-num-locknil,则 NumLock密钥将产生符号kp-numlock。默认值为t,这会NumLock按预期工作:切换数字键盘上按键的含义。

Similarly, if w32-enable-num-lock is nil, the NumLock key will produce the symbol kp-numlock. The default is t, which causes NumLock to work as expected: toggle the meaning of the keys on the numeric keypad.

该变量w32-apps-modifier控制按键的效果 Apps(通常位于左右Alt键之间Ctrl)。它的值可以是符号 hypersupermetaaltcontrol、 或shift相应修饰符之一,或者nil显示为键apps。默认为nil.

The variable w32-apps-modifier controls the effect of the Apps key (usually located between the right Alt and the right Ctrl keys). Its value can be one of the symbols hyper, super, meta, alt, control, or shift for the respective modifier, or nil to appear as the key apps. The default is nil.

该变量确定左 Windows 键(通常标有和 Windows 徽标)w32-lwindow-modifier的效果。start如果其值为nil(默认值),则该键将生成符号lwindow。将其设置为符号 hypersupermetaaltcontrol、 或之一shift将产生相应的修饰符。类似的变量w32-rwindow-modifier控制右 Windows 键的效果,并且w32-scroll-lock-modifier对该 ScrLock键执行相同的操作。如果这些变量设置为nil,则右 Windows 键将产生 符号rwindowScrLock 产生 符号scroll。如果您想ScrLock产生与其他应用程序中相同的效果,即切换键盘上的 Scroll Lock LEDw32-scroll-lock-modifier指示,请设置为或 除上述修饰符号之外的 t任何非值。nil

The variable w32-lwindow-modifier determines the effect of the left Windows key (usually labeled with start and the Windows logo). If its value is nil (the default), the key will produce the symbol lwindow. Setting it to one of the symbols hyper, super, meta, alt, control, or shift will produce the respective modifier. A similar variable w32-rwindow-modifier controls the effect of the right Windows key, and w32-scroll-lock-modifier does the same for the ScrLock key. If these variables are set to nil, the right Windows key produces the symbol rwindow and ScrLock produces the symbol scroll. If you want ScrLock to produce the same effect as in other applications, i.e. toggle the Scroll Lock LED indication on the keyboard, set w32-scroll-lock-modifier to t or any non-nil value other than the above modifier symbols.

编译为本机 Windows 应用程序的 Emacs 通常会关闭按按键调用AltWindows 菜单的 Windows 功能。原因是Emacs 中Alt的服务Meta。在使用 Emacs 时,用户经常会Meta暂时按下某个键,然后又改变主意;如果这具有调出 Windows 菜单的效果,则会改变后续命令的含义。许多用户对此感到沮丧。

Emacs compiled as a native Windows application normally turns off the Windows feature that tapping the Alt key invokes the Windows menu. The reason is that the Alt serves as Meta in Emacs. When using Emacs, users often press the Meta key temporarily and then change their minds; if this has the effect of bringing up the Windows menu, it alters the meaning of subsequent commands. Many users find this frustrating.

Alt 您可以通过设置w32-pass-alt-to-system为非值来重新启用 Windows 对点击按键的默认处理nil

You can re-enable Windows’s default handling of tapping the Alt key by setting w32-pass-alt-to-system to a non-nil value.

变量w32-pass-lwindow-to-systemw32-pass-rwindow-to-system确定相应的键是传递给 Windows 还是被 Emacs 吞没。如果值为 nil,则相应的键将被 Emacs 默默吞下,否则将传递给 Windows。默认值适用t于这两个变量。将这些键中的每一个传递给 Windows 都会产生其正常效果:例如,Lwindow打开 Start菜单等。

The variables w32-pass-lwindow-to-system and w32-pass-rwindow-to-system determine whether the respective keys are passed to Windows or swallowed by Emacs. If the value is nil, the respective key is silently swallowed by Emacs, otherwise it is passed to Windows. The default is t for both of these variables. Passing each of these keys to Windows produces its normal effect: for example, Lwindow opens the Start menu, etc.

该变量w32-recognize-altgr控制是否将该 AltGr键(如果键盘上存在)或其等效项(同时按下的Alt左右Ctrl键的组合)识别为该AltGr键。默认为t,这意味着这些键产生AltGr;将其设置为nil导致AltGr或等效的组合键被解释为CtrlMeta 修饰符的组合。

The variable w32-recognize-altgr controls whether the AltGr key (if it exists on your keyboard), or its equivalent, the combination of the right Alt and left Ctrl keys pressed together, is recognized as the AltGr key. The default is t, which means these keys produce AltGr; setting it to nil causes AltGr or the equivalent key combination to be interpreted as the combination of Ctrl and Meta modifiers.

MS-Windows 的某些版本(通常是东亚本地化 Windows)启用输入法管理器 ( IMM ),允许应用程序与本机 Windows 输入法服务输入法编辑器 ( IME ) 进行通信。 Emacs 使用可用的IME来允许用户输入东亚非ASCII字符,类似于 Emacs 的内置输入法(请参阅输入法)。但是,在某些情况下, 如果 IME 将您输入的简单ASCII键解释为指定非ASCII字符的按键序列的一部分,则IME可能会产生妨碍。 使用该功能可以暂时关闭 IME,然后 再打开w32-set-ime-open-status

Some versions of MS-Windows, typically East Asian localized Windows, enable the Input Method Manager (IMM) that allows applications to communicate with the Input Method Editor (IME), the native Windows input method service. Emacs uses the IME when available to allow users to input East Asian non-ASCII characters, similarly to Emacs’s built-in input methods (see Input Methods). However, in some situations the IME can get in the way if it interprets simple ASCII keys you input as part of a key sequence that designates a non-ASCII character. The IME can be temporarily turned off and then on again by using the w32-set-ime-open-status function.


H.7 MS-Windows 上的鼠标使用

H.7 Mouse Usage on MS-Windows

本节介绍与鼠标相关的 Windows 特定变量。

This section describes the Windows-specific variables related to the mouse.

该变量w32-mouse-button-tolerance指定在两键鼠标上假装按下鼠标中键的时间间隔(以毫秒为单位)。如果在此时间间隔内按下两个鼠标按钮,Emacs 会生成鼠标中键单击事​​件,而不是双击其中一个按钮。

The variable w32-mouse-button-tolerance specifies the time interval, in milliseconds, for faking middle mouse button press on 2-button mice. If both mouse buttons are depressed within this time interval, Emacs generates a middle mouse button click event instead of a double click on one of the buttons.

如果变量w32-pass-extra-mouse-buttons-to-system为非nil,Emacs 将第四个和第五个鼠标按钮传递给 Windows。

If the variable w32-pass-extra-mouse-buttons-to-system is non-nil, Emacs passes the fourth and fifth mouse buttons to Windows.

该变量w32-swap-mouse-buttons控制 3 个鼠标按钮中的哪一个生成mouse-2事件。当它是 nil(默认)时,中间按钮生成事件mouse-2 ,右侧按钮生成mouse-3事件。如果该变量为非nil,则这两个按钮的作用相反。

The variable w32-swap-mouse-buttons controls which of the 3 mouse buttons generates the mouse-2 events. When it is nil (the default), the middle button generates mouse-2 and the right button generates mouse-3 events. If this variable is non-nil, the roles of these two buttons are reversed.


Windows 9X/ME 和 Windows NT/2K/XP/Vista/7/8/10 上的 H.8 子进程

H.8 Subprocesses on Windows 9X/ME and Windows NT/2K/XP/Vista/7/8/10

编译为本机 Windows 应用程序(而不是 DOS 版本)的 Emacs 完全支持异步子进程。在 Windows 版本中,只要您仅运行 32 位或 64 位 Windows 应用程序,同步和异步子进程就可以在所有版本的 MS-Windows 上正常工作。然而,当您在子进程中运行DOS应用程序时,您可能会遇到问题或根本无法运行该应用程序;如果您在两个子进程中同时运行两个 DOS 应用程序,则可能需要重新启动系统。

Emacs compiled as a native Windows application (as opposed to the DOS version) includes full support for asynchronous subprocesses. In the Windows version, synchronous and asynchronous subprocesses work fine on all versions of MS-Windows, as long as you run only 32-bit or 64-bit Windows applications. However, when you run a DOS application in a subprocess, you may encounter problems or be unable to run the application at all; and if you run two DOS applications at the same time in two subprocesses, you may have to reboot your system.

由于 Windows 9X 上的标准命令解释器(以及大多数命令行实用程序)是 DOS 应用程序,因此在使用该系统时这些问题非常严重。但我们对此无能为力;只有微软可以修复它们。

Since the standard command interpreter (and most command line utilities) on Windows 9X are DOS applications, these problems are significant when using that system. But there’s nothing we can do about them; only Microsoft can fix them.

如果您只运行一个 DOS 应用程序子进程,则只要该子进程“行为良好”并且不执行直接屏幕访问或其他异常操作,它就应该按预期工作。如果您有 CPU 监视器应用程序,即使 DOS 应用程序空闲,您的计算机也会显示为 100% 繁忙,但这只是 CPU 监视器测量处理器负载的方式的产物。

If you run just one DOS application subprocess, the subprocess should work as expected as long as it is “well-behaved” and does not perform direct screen access or other unusual actions. If you have a CPU monitor application, your machine will appear to be 100% busy even when the DOS application is idle, but this is only an artifact of the way CPU monitors measure processor load.

在启动不同子进程中的任何其他 DOS 应用程序之前,必须终止该 DOS 应用程序。 Emacs 无法中断或终止 DOS 子进程。终止此类子进程的唯一方法是给它一个命令,告诉其程序退出。

You must terminate the DOS application before you start any other DOS application in a different subprocess. Emacs is unable to interrupt or terminate a DOS subprocess. The only way you can terminate such a subprocess is by giving it a command that tells its program to exit.

如果您尝试在单独的子进程中同时运行两个 DOS 应用程序,则启动的第二个应用程序将挂起,直到第一个应用程序完成,即使其中一个或两个是异步的。

If you attempt to run two DOS applications at the same time in separate subprocesses, the second one that is started will be suspended until the first one finishes, even if either or both of them are asynchronous.

如果您可以转到第一个子进程并告诉它退出,则第二个子进程应该正常继续。但是,如果第二个子进程是同步的,则 Emacs 本身将挂起,直到第一个子进程完成。如果在没有用户输入的情况下它无法完成,那么如果您运行的是 Windows 9X,则您别无选择,只能重新启动。如果您在 Windows NT 及更高版本上运行,则可以使用进程查看器应用程序来终止 NTVDM 的相应实例(这将终止两个 DOS 子进程)。

If you can go to the first subprocess, and tell it to exit, the second subprocess should continue normally. However, if the second subprocess is synchronous, Emacs itself will be hung until the first subprocess finishes. If it will not finish without user input, then you have no choice but to reboot if you are running on Windows 9X. If you are running on Windows NT and later, you can use a process viewer application to kill the appropriate instance of NTVDM instead (this will terminate both DOS subprocesses).

如果在这种情况下必须重新启动 Windows 9X,请不要使用 菜单Shutdown上的命令Start;通常会挂起系统。相反,请键入然后选择 。这通常是有效的,尽管可能需要几分钟才能完成工作。 Ctrl-Alt-DELShutdown

If you have to reboot Windows 9X in this situation, do not use the Shutdown command on the Start menu; that usually hangs the system. Instead, type Ctrl-Alt-DEL and then choose Shutdown. That usually works, although it may take a few minutes to do its job.

该变量w32-quote-process-args控制 Emacs 如何引用进程参数。非nil表示带" 字符的引用。如果该值是一个字符,Emacs 使用该字符来转义出现的任何引号字符;否则它会根据程序的类型选择合适的转义字符。

The variable w32-quote-process-args controls how Emacs quotes the process arguments. Non-nil means quote with the " character. If the value is a character, Emacs uses that character to escape any quote characters that appear; otherwise it chooses a suitable escape character based on the type of the program.

当 Emacs 创建与子进程通信的管道时,该变量w32-pipe-buffer-size控制 Emacs 向系统请求的缓冲区大小。默认值为零,这让操作系统选择大小。任何有效的正值都将请求该大小(以字节为单位)的缓冲区。这可用于定制与子进程的通信,以适应在缓冲管道 I/O 方面表现出异常行为的程序。

The variable w32-pipe-buffer-size controls the size of the buffer Emacs requests from the system when it creates pipes for communications with subprocesses. The default value is zero, which lets the OS choose the size. Any valid positive value will request a buffer of that size in bytes. This can be used to tailor communications with subprocesses to programs that exhibit unusual behavior with respect to buffering pipe I/O.

如果您需要将 MS-DOS 程序作为 Emacs 子进程调用,您可能会发现从此类程序读取数据的速度较低。在这些情况下,将变量设置 w32-pipe-read-delay为非零值可能会提高吞吐量;对于这种情况,我们建议使用 50 的值。默认为零。

If you need to invoke MS-DOS programs as Emacs subprocesses, you may see low rate of reading data from such programs. Setting the variable w32-pipe-read-delay to a non-zero value may improve throughput in these cases; we suggest the value of 50 for such situations. The default is zero.

该函数w32-shell-execute可用于编写运行 MS-Windows 应用程序的自定义命令,这些应用程序注册为处理特定类型文档或文件的特定标准 Windows 操作。该函数是 Windows ShellExecuteAPI 的包装器。有关详细信息,请参阅 MS-Windows API 文档。

The function w32-shell-execute can be useful for writing customized commands that run MS-Windows applications registered to handle a certain standard Windows operation for a specific type of document or file. This function is a wrapper around the Windows ShellExecute API. See the MS-Windows API documentation for more details.


H.9 打印和 MS-Windows

H.9 Printing and MS-Windows

如果 POSIX 样式程序不可用,打印命令(例如,lpr-buffer请参阅打印硬拷贝)和 ps-print-buffer(请参阅PostScript 硬拷贝)可以在 MS-DOS 和 MS-Windows 中工作,将输出发送到打印机端口之一。lpr相同的 Emacs 变量控制所有系统上的打印,但在某些情况下,它们在 MS-DOS 和 MS-Windows 上具有不同的默认值。

Printing commands, such as lpr-buffer (see Printing Hard Copies) and ps-print-buffer (see PostScript Hardcopy) work in MS-DOS and MS-Windows by sending the output to one of the printer ports, if a POSIX-style lpr program is unavailable. The same Emacs variables control printing on all systems, but in some cases they have different default values on MS-DOS and MS-Windows.

MS Windows 上的 Emacs 尝试自动确定默认打印机(使用 函数default-printer-name)。但在极少数情况下,这可能会失败,或者您可能希望在 Emacs 中使用不同的打印机。本节的其余部分解释如何告诉 Emacs 使用哪台打印机。

Emacs on MS Windows attempts to determine your default printer automatically (using the function default-printer-name). But in some rare cases this can fail, or you may wish to use a different printer from within Emacs. The rest of this section explains how to tell Emacs which printer to use.

如果您想使用本地打印机,请将 Lisp 变量设置 lpr-command""(Windows 上的默认值)和 printer-name打印机端口的名称,例如, "PRN",通常的本地打印机端口,或"LPT2", 或 "COM1"表示串行打印机。您还可以设置 printer-name文件名,在这种情况下,“打印”输出实际上会附加到该文件。如果设置printer-name"NUL",则打印输出将被静默丢弃(发送到系统空设备)。

If you want to use your local printer, then set the Lisp variable lpr-command to "" (its default value on Windows) and printer-name to the name of the printer port—for example, "PRN", the usual local printer port, or "LPT2", or "COM1" for a serial printer. You can also set printer-name to a file name, in which case “printed” output is actually appended to that file. If you set printer-name to "NUL", printed output is silently discarded (sent to the system null device).

您还可以通过设置该打印机的 UNC 共享名称来使用另一台计算机共享的打印机 printer-name,例如"//joes_pc/hp4si". (这里使用正斜杠还是反斜杠并不重要。)要查找共享打印机的名称,请运行命令“网络视图' 从命令提示符获取服务器列表,并且 'net view服务器名称' 查看该服务器共享的打印机(和目录)的名称。或者,单击“网上邻居” 桌面上的图标,然后查找通过网络共享打印机的计算机。

You can also use a printer shared by another machine by setting printer-name to the UNC share name for that printer—for example, "//joes_pc/hp4si". (It doesn’t matter whether you use forward slashes or backslashes here.) To find out the names of shared printers, run the command ‘net view’ from the command prompt to obtain a list of servers, and ‘net view server-name’ to see the names of printers (and directories) shared by that server. Alternatively, click the ‘Network Neighborhood’ icon on your desktop, and look for machines that share their printers via the network.

如果打印机没有出现在 ' 的输出中网络视图',或者如果设置printer-nameUNC 共享名不会在该打印机上生成硬拷贝,您可以使用 '净使用' 命令连接本地打印端口,例如"LPT2"连接到网络打印机。例如,键入net use LPT2: \\joes_pc\hp4si30 会使 Windows捕获端口LPT2并将打印材料重定向到连接到计算机的打印机joes_pc。执行此命令后,设置printer-name"LPT2" 应在联网打印机上生成硬拷贝。

If the printer doesn’t appear in the output of ‘net view’, or if setting printer-name to the UNC share name doesn’t produce a hardcopy on that printer, you can use the ‘net use’ command to connect a local print port such as "LPT2" to the networked printer. For example, typing net use LPT2: \\joes_pc\hp4si30 causes Windows to capture the LPT2 port and redirect the printed material to the printer connected to the machine joes_pc. After this command, setting printer-name to "LPT2" should produce the hardcopy on the networked printer.

使用某些类型的 Windows 网络软件,您可以指示 Windows 捕获特定的打印机端口(例如 ) ,并通过小程序(而不是“”)"LPT2"将其重定向到网络打印机。Control Panel->Printers净使用'。

With some varieties of Windows network software, you can instruct Windows to capture a specific printer port such as "LPT2", and redirect it to a networked printer via the Control Panel->Printers applet instead of ‘net use’.

如果设置printer-name为文件名,最好使用绝对文件名。 Emacs 根据当前缓冲区的默认目录更改工作目录,因此如果 in 中的文件名 printer-name是相对的,您最终将得到几个这样的文件,每个文件都位于完成打印的缓冲区的目录中。

If you set printer-name to a file name, it’s best to use an absolute file name. Emacs changes the working directory according to the default directory of the current buffer, so if the file name in printer-name is relative, you will end up with several such files, each one in the directory of the buffer from which the printing was done.

如果 的值printer-name正确,但在您的打印机上打印时未生成硬拷贝,则您的打印机可能不支持打印纯文本(某些廉价打印机忽略此功能)。在这种情况下,请尝试如下所述的 PostScript 打印命令。

If the value of printer-name is correct, but printing does not produce the hardcopy on your printer, it is possible that your printer does not support printing plain text (some cheap printers omit this functionality). In that case, try the PostScript print commands, described below.

命令print-bufferprint-region调用 pr程序,或使用程序的特殊开关lpr,在每个打印页面上生成标题。 MS-DOS 和 MS-Windows 通常没有这些程序,因此默认情况下, lpr-headers-switches设置该变量,以便打印页眉的请求被静默忽略。因此,print-buffer和 分别产生与和 print-region相同的输出。如果您确实有合适的 程序(例如,来自 GNU Coreutils),请设置 为;然后,Emacs 将调用 以生成页眉,并按照 指定的方式打印结果输出。 lpr-bufferlpr-regionprlpr-headers-switchesnilprprinter-name

The commands print-buffer and print-region call the pr program, or use special switches to the lpr program, to produce headers on each printed page. MS-DOS and MS-Windows don’t normally have these programs, so by default, the variable lpr-headers-switches is set so that the requests to print page headers are silently ignored. Thus, print-buffer and print-region produce the same output as lpr-buffer and lpr-region, respectively. If you do have a suitable pr program (for example, from GNU Coreutils), set lpr-headers-switches to nil; Emacs will then call pr to produce the page headers, and print the resulting output as specified by printer-name.

最后,如果您确实有lpr类似的工作,则可以将该变量设置lpr-command"lpr"。然后 Emacs 将用于 lpr打印,就像在其他系统上一样。 (如果程序名称不是lpr,则设置lpr-command为适当的值。)当不是时,该变量lpr-switches具有其标准含义。如果变量 具有字符串值,则将其用作选项的值 ,如 Unix 上一样。 lpr-command""printer-name-Plpr

Finally, if you do have an lpr work-alike, you can set the variable lpr-command to "lpr". Then Emacs will use lpr for printing, as on other systems. (If the name of the program isn’t lpr, set lpr-command to the appropriate value.) The variable lpr-switches has its standard meaning when lpr-command is not "". If the variable printer-name has a string value, it is used as the value for the -P option to lpr, as on Unix.

一组并行变量 、ps-lpr-commandps-lpr-switchesps-printer-name(请参阅PostScript 硬拷贝的变量)定义如何打印 PostScript 文件。这些变量的使用方式与上述非 PostScript 打印的相应变量的使用方式相同。因此, 的值 ps-printer-name用作 PostScript 输出发送到的设备(或文件)的名称,就像printer-name用于非 PostScript 打印一样。 (如果您有两台打印机连接到两个不同的端口,并且其中只有一台是 PostScript 打印机,则有两组不同的变量。)

A parallel set of variables, ps-lpr-command, ps-lpr-switches, and ps-printer-name (see Variables for PostScript Hardcopy), defines how PostScript files should be printed. These variables are used in the same way as the corresponding variables described above for non-PostScript printing. Thus, the value of ps-printer-name is used as the name of the device (or file) to which PostScript output is sent, just as printer-name is used for non-PostScript printing. (There are two distinct sets of variables in case you have two printers attached to two different ports, and only one of them is a PostScript printer.)

该变量的默认值为ps-lpr-command""这会导致 PostScript 输出发送到由 指定的打印机端口ps-printer-name;但ps-lpr-command也可以设置为接受 PostScript 文件的程序的名称。因此,如果您有非 PostScript 打印机,则可以将此变量设置为 PostScript 解释程序的名称(例如 Ghostscript)。任何需要传递给解释器程序的开关都使用 指定 ps-lpr-switches。 (如果 的值ps-printer-name是字符串,它将作为选项的值添加到开关列表中 -P。这可能仅在您使用 时才有用 lpr,因此在使用解释器时通常您会设置 ps-printer-name为字符串以外的值所以它被忽略了。)

The default value of the variable ps-lpr-command is "", which causes PostScript output to be sent to the printer port specified by ps-printer-name; but ps-lpr-command can also be set to the name of a program which will accept PostScript files. Thus, if you have a non-PostScript printer, you can set this variable to the name of a PostScript interpreter program (such as Ghostscript). Any switches that need to be passed to the interpreter program are specified using ps-lpr-switches. (If the value of ps-printer-name is a string, it will be added to the list of switches as the value for the -P option. This is probably only useful if you are using lpr, so when using an interpreter typically you would set ps-printer-name to something other than a string so it is ignored.)

例如,要使用 Ghostscript 在系统默认打印机上进行打印,请将其放入您的.emacs文件:

For example, to use Ghostscript for printing on the system’s default printer, put this in your .emacs file:

(setq ps-打印机名称 t)
(setq ps-lpr-命令“D:/gs6.01/bin/gswin32c.exe”)
(setq ps-lpr-开关'(“-q”“-dNOPAUSE”“-dBATCH”
                        “-sDEVICE=mswinpr2”
                        “-sPAPERSIZE=a4”))
(setq ps-printer-name t)
(setq ps-lpr-command "D:/gs6.01/bin/gswin32c.exe")
(setq ps-lpr-switches '("-q" "-dNOPAUSE" "-dBATCH"
                        "-sDEVICE=mswinpr2"
                        "-sPAPERSIZE=a4"))

(这假设 Ghostscript 安装在 D:/gs6.01目录。)

(This assumes that Ghostscript is installed in the D:/gs6.01 directory.)


H.10 在 MS-Windows 上指定字体

H.10 Specifying Fonts on MS-Windows

字体由其名称、大小和可选属性指定。指定字体的格式来自现代免费桌面中使用的 fontconfig 库:

Fonts are specified by their name, size and optional properties. The format for specifying fonts comes from the fontconfig library used in modern Free desktops:

  [族[-PointSize]][:选项1=值1[:选项2=值2[...]]]
  [Family[-PointSize]][:Option1=Value1[:Option2=Value2[...]]]

还支持基于旧 XLFD 的格式以实现向后兼容性。

The old XLFD based format is also supported for backwards compatibility.

MS-Windows 上的 Emacs 支持多种字体后端。目前,gdiuniscribeharfbuzz后端可用。字体gdi后端可在所有版本的 Windows 上使用,并支持 Windows 本机支持的所有字体。字体uniscribe后端可在 Windows 2000 及更高版本上使用,并支持 TrueType 和 OpenType 字体。如果 Emacs 是使用 HarfBuzz 支持构建的,并且您的系统上安装了 HarfBuzz DLL,则字体 harfbuzz后端可用;例如uniscribe,该后端仅支持 TrueType 和 OpenType 字体。某些需要复杂布局的语言只能由 Uniscribe 或 HarfBuzz 后端正确支持。默认情况下,为每个帧启用两个后端:gdiharfbuzzuniscribe,具体取决于哪一个可用(如果两者都可用,则harfbuzz默认情况下仅启用)。当 Emacs 寻找合适的字体时,harfbuzz和后端uniscribe优先。gdi要覆盖该设置并使用 GDI 后端(即使 Uniscribe 可用),请使用-xrm Emacs.fontBackend:gdi命令行参数调用 Emacs,或者在“注册表”下添加一个Emacs.fontBackend具有该值的资源 。gdiHKEY_CURRENT_USER\SOFTWARE\GNU\Emacs' 或者 'HKEY_LOCAL_MACHINE\SOFTWARE\GNU\Emacs' 键(参见X 资源)。同样,即使 HarfBuzz 可用,也要使用 Uniscribe 后端,请-xrm Emacs.fontBackend:uniscribe在调用 Emacs 的命令行上使用。您还可以通过 font-backend框架参数请求所有 3 个后端,但请注意,在这种情况下,字体搜索系统上没有可用字体的字符将花费更长的时间。

Emacs on MS-Windows supports a number of font backends. Currently, the gdi, uniscribe, and harfbuzz backends are available. The gdi font backend is available on all versions of Windows, and supports all fonts that are natively supported by Windows. The uniscribe font backend is available on Windows 2000 and later, and supports TrueType and OpenType fonts. The harfbuzz font backend is available if Emacs was built with HarfBuzz support, and if the HarfBuzz DLL is installed on your system; like uniscribe, this backend supports only TrueType and OpenType fonts. Some languages requiring complex layout can only be properly supported by the Uniscribe or HarfBuzz backends. By default, two backends are enabled for each frame: gdi and either harfbuzz or uniscribe, depending on which one is available (if both are available, only harfbuzz is enabled by default). The harfbuzz and uniscribe backends take priority over gdi when Emacs looks for a suitable font. To override that and use the GDI backend even if Uniscribe is available, invoke Emacs with the -xrm Emacs.fontBackend:gdi command-line argument, or add a Emacs.fontBackend resource with the value gdi in the Registry under either the ‘HKEY_CURRENT_USER\SOFTWARE\GNU\Emacs’ or the ‘HKEY_LOCAL_MACHINE\SOFTWARE\GNU\Emacs’ key (see X Resources). Similarly, to use the Uniscribe backend even if HarfBuzz is available, use -xrm Emacs.fontBackend:uniscribe on the command line that invokes Emacs. You can also request all the 3 backends via the font-backend frame parameter, but be warned that in that case font searches for characters for which no fonts are available on the system will take longer.

或者,您可以通过框架参数指定框架的字体后端 font-backend,使用 modify-frame-parameters(请参阅Emacs Lisp 参考手册中的参数访问)。您还可以通过和 为所有框架请求特定的字体后端(请参阅框架参数)。请注意,参数的值应该是符号列表,如或中。 default-frame-alistinitial-frame-alistfont-backend(uniscribe)(harfbuzz uniscribe gdi)

Alternatively, you could specify a font backend for a frame via the font-backend frame parameter, using modify-frame-parameters (see Parameter Access in The Emacs Lisp Reference Manual). You can also request specific font backend(s) for all your frames via default-frame-alist and initial-frame-alist (see Frame Parameters). Note that the value of the font-backend parameter should be a list of symbols, as in (uniscribe) or (harfbuzz uniscribe gdi).

MS-Windows 支持的可选字体属性有:

Optional font properties supported on MS-Windows are:

weight
weight

指定字体的粗细。特殊值lightmediumdemiboldbold、 和black可以不指定weight=(例如,Courier New-12:bold)。否则,权重应该是 100 到 900 之间的数值,或者 中指定的权重之一font-weight-table。如果未指定,则假定为常规字体。

Specifies the weight of the font. Special values light, medium, demibold, bold, and black can be specified without weight= (e.g., Courier New-12:bold). Otherwise, the weight should be a numeric value between 100 and 900, or one of the named weights in font-weight-table. If unspecified, a regular font is assumed.

slant
slant

指定字体是否为斜体。特殊值 roman,italicoblique可以不指定slant=(例如,Courier New-12:italic)。否则,倾斜应该是一个数值,或者是font-slant-table.在 Windows 上,任何高于 150 的倾斜都被视为斜体,低于 150 的任何倾斜都被视为罗马字体。

Specifies whether the font is italic. Special values roman, italic and oblique can be specified without slant= (e.g., Courier New-12:italic). Otherwise, the slant should be a numeric value, or one of the named slants in font-slant-table. On Windows, any slant above 150 is treated as italics, and anything below as roman.

family
family

指定字体系列,但通常会在字体名称的开头指定。

Specifies the font family, but normally this will be specified at the start of the font name.

pixelsize
pixelsize

指定字体大小(以像素为单位)。这可以用来代替姓氏后面指定的磅值。

Specifies the font size in pixels. This can be used instead of the point size specified after the family name.

adstyle
adstyle

指定字体的附加样式信息。在 MS-Windows 上,可识别值monosansserif和 。这些作为未指定字体系列的后备是最有用的。 scriptdecorative

Specifies additional style information for the font. On MS-Windows, the values mono, sans, serif, script and decorative are recognized. These are most useful as a fallback with the font family left unspecified.

registry
registry

指定字体预期覆盖的字符集注册表。大多数 TrueType 和 OpenType 字体都是涵盖多个国家字符集的 Unicode 字体,但您可以使用此处的特定注册表将字体选择范围缩小到支持特定字符集的字体w32-charset-info-alist

Specifies the character set registry that the font is expected to cover. Most TrueType and OpenType fonts will be Unicode fonts that cover several national character sets, but you can narrow down the selection of fonts to those that support a particular character set by using a specific registry from w32-charset-info-alist here.

spacing
spacing

指定字体的间距。间距p指定比例字体,和m/或c指定等宽字体。

Specifies how the font is spaced. The p spacing specifies a proportional font, and m or c specify a monospaced font.

foundry
foundry

不在 Windows 上使用,但出于提供信息的目的并防止希望设置它的代码出现问题,在内部设置 raster为位图字体、outline可缩放字体,或者unknown如果无法将类型确定为其中之一。

Not used on Windows, but for informational purposes and to prevent problems with code that expects it to be set, is set internally to raster for bitmapped fonts, outline for scalable fonts, or unknown if the type cannot be determined as one of those.

script
script

指定字体应支持的 Unicode 子范围。

Emacs 已知的所有脚本(通常意味着最新 Unicode 标准定义的所有脚本)都可以在 MS-Windows 上识别。但是,GDI字体仅支持已知脚本的子集: greekhangulkanakanbunbopomofotibetanyimongolianhebrewarabicthai

Specifies a Unicode subrange the font should support.

All the scripts known to Emacs (which generally means all the scripts defined by the latest Unicode Standard) are recognized on MS-Windows. However, GDI fonts support only a subset of the known scripts: greek, hangul, kana, kanbun, bopomofo, tibetan, yi, mongolian, hebrew, arabic, and thai.

antialias
antialias

指定抗锯齿方法。该值none表示无抗锯齿,standard表示使用标准抗锯齿, 表示使用子像素抗锯齿(在 Windows 上subpixel称为 Cleartypenatural ),表示使用调整字母间距的子像素抗锯齿。如果未指定,字体将使用系统默认的抗锯齿功能。

Specifies the antialiasing method. The value none means no antialiasing, standard means use standard antialiasing, subpixel means use subpixel antialiasing (known as Cleartype on Windows), and natural means use subpixel antialiasing with adjusted spacing between letters. If unspecified, the font will use the system default antialiasing.

MS-Windows 上的 Emacs 用于查找适合显示给定非ASCII字符的字体的方法对于某些罕见的脚本(特别是最近由 Unicode 添加的脚本)可能会失败,即使您的系统上安装了支持这些脚本的字体。这是因为这些脚本在 MS-Windows 上的 Emacs 用于查找字体的信息中没有为其定义 Unicode 子范围位 (USB)。您可以使用该w32-find-non-USB-fonts 功能来克服这些问题。它需要在 Emacs 会话开始时运行一次,如果安装新字体则需要再次运行。您可以将以下行添加到 init 文件中,以便在每次启动 Emacs 时运行此函数:

The method used by Emacs on MS-Windows to look for fonts suitable for displaying a given non-ASCII character might fail for some rare scripts, specifically those added by Unicode relatively recently, even if you have fonts installed on your system that support those scripts. That is because these scripts have no Unicode Subrange Bits (USBs) defined for them in the information used by Emacs on MS-Windows to look for fonts. You can use the w32-find-non-USB-fonts function to overcome these problems. It needs to be run once at the beginning of the Emacs session, and again if you install new fonts. You can add the following line to your init file to have this function run every time you start Emacs:

(w32-查找非 USB 字体)
(w32-find-non-USB-fonts)

或者,您可以随时通过手动运行此函数M-: (请参阅评估 Emacs Lisp 表达式)。在安装了多种字体的系统上,运行w32-find-non-USB-fonts可能需要几秒钟;如果您认为启动过程中运行时间太长,并且很少安装新字体,请通过 运行此函数一次M-:,然后将其返回的值(如果不是)分配给init 文件中的nil变量。 w32-non-USB-fonts(如果该函数返回nil,则表明您没有安装可以显示需要此功能的脚本中的字符的字体。)

Alternatively, you can run this function manually via M-: (see Evaluating Emacs Lisp Expressions) at any time. On a system that has many fonts installed, running w32-find-non-USB-fonts might take a couple of seconds; if you consider that to be too long to be run during startup, and if you install new fonts only rarely, run this function once via M-:, and then assign the value it returns, if non-nil, to the variable w32-non-USB-fonts in your init file. (If the function returns nil, you have no fonts installed that can display characters from the scripts which need this facility.)

该变量控制通过( )w32-use-w32-font-dialog选择字体的方式。如果值为,默认情况下,Emacs 使用标准 Windows 字体选择对话框。如果值为,Emacs 会弹出一组固定字体的菜单。菜单中显示的字体由 确定。 S-mouse-1mouse-appearance-menutnilw32-fixed-font-alist

The variable w32-use-w32-font-dialog controls the way fonts can be selected via S-mouse-1 (mouse-appearance-menu). If the value is t, the default, Emacs uses the standard Windows font selection dialog. If the value is nil, Emacs instead pops a menu of a fixed set of fonts. The fonts to appear in the menu are determined by w32-fixed-font-alist.


H.11 其他特定于 Windows 的功能

H.11 Miscellaneous Windows-specific features

本节介绍了 Windows 特定的功能,这些功能不适用于其他任何地方。

This section describes Windows-specific features that don’t fit anywhere else.

该变量w32-use-visible-system-caret是一个标志,用于确定是否使系统插入符可见。不使用屏幕阅读器软件时默认为nil,这意味着 Emacs 绘制自己的光标来指示点的位置。非值nil意味着 Emacs 将使用系统插入符指示点位置;这有利于屏幕阅读器软件的使用,并且是运行 Emacs 时检测到此类软件时的默认设置。当该变量为非时nil,影响光标显示的其他变量不起作用。

The variable w32-use-visible-system-caret is a flag that determines whether to make the system caret visible. The default when no screen reader software is in use is nil, which means Emacs draws its own cursor to indicate the position of point. A non-nil value means Emacs will indicate point location with the system caret; this facilitates use of screen reader software, and is the default when such software is detected when running Emacs. When this variable is non-nil, other variables affecting the cursor display have no effect.

如果该变量w32-grab-focus-on-raise设置为非值,nil则会导致框架在抬起时捕获焦点。默认值为t,这非常适合 Windows 默认的点击焦点策略。

The variable w32-grab-focus-on-raise, if set to a non-nil value causes a frame to grab focus when it is raised. The default is t, which fits well with the Windows default click-to-focus policy.

在 Windows 10(版本 1809 及更高版本)和 Windows 11 上,Emacs 标题栏和滚动条将遵循系统的浅色或深色模式,类似于资源管理器和命令提示符等其他程序。要更改颜色模式,请选择PersonalizationWindows Settings然后 选择Colors->Choose your color(或Choose your default app mode);然后重新启动 Emacs。

On Windows 10 (version 1809 and higher) and Windows 11, Emacs title bars and scroll bars will follow the system’s Light or Dark mode, similar to other programs such as Explorer and Command Prompt. To change the color mode, select Personalization from Windows Settings, then Colors->Choose your color (or Choose your default app mode); then restart Emacs.


H.12 Emacs 和 MS-DOS

H.12 Emacs and MS-DOS

本节简要描述在 MS-DOS 上使用 Emacs 的特性。有关 MS-DOS 和 Microsoft 当前操作系统 Windows 的共同特性的信息位于 Emacs 和 Microsoft Windows/MS-DOS中。

This section briefly describes the peculiarities of using Emacs on MS-DOS. Information about peculiarities common to MS-DOS and Microsoft’s current operating systems Windows is in Emacs and Microsoft Windows/MS-DOS.

如果您为 MS-DOS 构建 Emacs,则二进制文件也可以作为 DOS 应用程序在 Windows 3.X、Windows NT、Windows 9X/ME 或 Windows 2000/XP 上运行;如果您使用为 MS-DOS 构建的 Emacs,那么本章的所有内容都适用于所有这些系统。

If you build Emacs for MS-DOS, the binary will also run on Windows 3.X, Windows NT, Windows 9X/ME, or Windows 2000/XP as a DOS application; all of this chapter applies for all of those systems, if you use an Emacs that was built for MS-DOS.

有关 Emacs 在 MS-DOS(和 Windows)下对文本文件的特殊处理的信息, 请参阅文本文件和二进制文件。

See Text Files and Binary Files, for information about Emacs’s special handling of text files under MS-DOS (and Windows).


H.12.1 MS-DOS 上的键盘使用

H.12.1 Keyboard Usage on MS-DOS

在 Emacs 中调用的键(因为大多数工作站上都​​是这样指定的)在 PC 上DEL称为(退格键)。BS这就是为什么 PC 特定的终端初始化将 BS密钥重新映射为DEL;出于同样的原因, 密钥Delete被重新映射为。C-d

The key that is called DEL in Emacs (because that’s how it is designated on most workstations) is known as BS (backspace) on a PC. That is why the PC-specific terminal initialization remaps the BS key to act as DEL; the Delete key is remapped to act as C-d for the same reasons.

为 MS-DOS 构建的 Emacs 识别为退出字符,就像.这是因为 Emacs在准备好接受更多输入之前无法检测到您已键入。因此,您不能用来停止正在运行的命令(请参阅退出和中止)。相比之下,一旦您键入它就会被检测到(就像在其他系统上一样),因此它可以用于停止正在运行的命令和紧急逃生(请参阅紧急逃生)。 C-BreakC-gC-gC-gC-Break C-g

Emacs built for MS-DOS recognizes C-Break as a quit character, just like C-g. This is because Emacs cannot detect that you have typed C-g until it is ready for more input. As a consequence, you cannot use C-g to stop a running command (see Quitting and Aborting). By contrast, C-Break is detected as soon as you type it (as C-g is on other systems), so it can be used to stop a running command and for emergency escape (see Emergency Escape).

PC 键盘映射使用左键Alt作为Meta键。您有两种选择来模拟SUPERHyper键:选择正确的键或通过将变量和分别设置为 1 或 2 来选择Ctrl正确的键。如果 和 都不为 1,则默认情况下右键也会映射到该键。但是,如果 MS-DOS 国际键盘支持程序Altdos-hyper-keydos-super-keydos-super-keydos-hyper-keyAltMetaKEYB.COM安装后,Emacs 不会 权限映射AltMeta,因为它用于访问非美国键盘布局上的字符,如~和;@在这种情况下,您只能使用左键Alt作为Meta 键。

The PC keyboard maps use the left Alt key as the Meta key. You have two choices for emulating the SUPER and Hyper keys: choose either the right Ctrl key or the right Alt key by setting the variables dos-hyper-key and dos-super-key to 1 or 2 respectively. If neither dos-super-key nor dos-hyper-key is 1, then by default the right Alt key is also mapped to the Meta key. However, if the MS-DOS international keyboard support program KEYB.COM is installed, Emacs will not map the right Alt to Meta, since it is used for accessing characters like ~ and @ on non-US keyboard layouts; in this case, you may only use the left Alt as Meta key.

该变量dos-keypad-mode是一个标志变量,用于控制数字键盘中的按键返回哪些键代码。您还可以通过将以下行放入您ENTERC-j_emacs文件:

The variable dos-keypad-mode is a flag variable that controls what key codes are returned by keys in the numeric keypad. You can also define the keypad ENTER key to act like C-j, by putting the following line into your _emacs file:

;;使ENTER数字键盘上的键充当C-j
(键映射设置功能键映射“<kp-enter>”“Cj”)
;; Make the ENTER key from the numeric keypad act as C-j.
(keymap-set function-key-map "<kp-enter>" "C-j")

H.12.2 MS-DOS 上的鼠标使用

H.12.2 Mouse Usage on MS-DOS

MS-DOS 上的 Emacs 支持鼠标(仅在默认终端上)。鼠标命令按照记录的方式工作,包括使用菜单和菜单栏的命令(请参阅菜单栏)。滚动条在 MS-DOS Emacs 中不起作用。 PC 鼠标通常只有两个按钮;它们的作用相当于mouse-1mouse-2,但如果将它们两个按在一起,就会产生 的效果mouse-3。如果鼠标确实有 3 个按钮,Emacs 会在启动时检测到这一点,并且所有 3 个按钮都正常工作,就像在 X 上一样。

Emacs on MS-DOS supports a mouse (on the default terminal only). The mouse commands work as documented, including those that use menus and the menu bar (see The Menu Bar). Scroll bars don’t work in MS-DOS Emacs. PC mice usually have only two buttons; these act as mouse-1 and mouse-2, but if you press both of them together, that has the effect of mouse-3. If the mouse does have 3 buttons, Emacs detects that at startup, and all the 3 buttons function normally, as on X.

当鼠标指针在菜单项上移动时,菜单栏和弹出菜单的帮助字符串将显示在回显区域中。还支持 突出显示鼠标敏感文本(请参阅使用鼠标跟随参考)。

Help strings for menu-bar and pop-up menus are displayed in the echo area when the mouse pointer moves across the menu items. Highlighting of mouse-sensitive text (see Following References with the Mouse) is also supported.

某些版本的鼠标驱动程序无法正确报告鼠标按钮的数量。例如,有轮子的鼠标报告它们有 3 个按钮,但只有其中 2 个传递给 Emacs;作为中间按钮的滚轮上的点击不会被传递。在这些情况下,您可以使用该M-x msdos-set-mouse-buttons命令告诉 Emacs 需要多少个鼠标按钮。您可以通过将此片段添加到您的_emacs初始化文件:

Some versions of mouse drivers don’t report the number of mouse buttons correctly. For example, mice with a wheel report that they have 3 buttons, but only 2 of them are passed to Emacs; the clicks on the wheel, which serves as the middle button, are not passed. In these cases, you can use the M-x msdos-set-mouse-buttons command to tell Emacs how many mouse buttons to expect. You could make such a setting permanent by adding this fragment to your _emacs init file:

;;将鼠标视为 2 键鼠标。
(msdos-设置-鼠标按钮 2)
;; Treat the mouse like a 2-button mouse.
(msdos-set-mouse-buttons 2)

为 MS-DOS 构建的 Emacs 在 Windows 上运行时支持剪贴板操作。将文本放在终止环上或从环中拉出文本的命令,首先检查 Windows 剪贴板,就像 Emacs 在 X Window 系统上所做的那样(请参阅用于编辑的鼠标命令)。 Windows 上的 MS-DOS Emacs 仅支持主选择和剪切缓冲区;辅助选择始终显示为空。

Emacs built for MS-DOS supports clipboard operations when it runs on Windows. Commands that put text on the kill ring, or yank text from the ring, check the Windows clipboard first, just as Emacs does on the X Window System (see Mouse Commands for Editing). Only the primary selection and the cut buffer are supported by MS-DOS Emacs on Windows; the secondary selection always appears as empty.

由于 Windows 实现剪贴板访问的方式,可以放入剪贴板的文本长度受到 Emacs 可用的空闲 DOS 内存量的限制。通常,剪贴板最多可以放入 620KB 的文本,但此限制取决于系统配置,如果将 Emacs 作为另一个程序的子进程运行,则此限制会更低。如果被删除的文本不适合,Emacs 会输出一条消息说明这一点,并且不会将文本放入剪贴板。

Due to the way clipboard access is implemented by Windows, the length of text you can put into the clipboard is limited by the amount of free DOS memory that is available to Emacs. Usually, up to 620KB of text can be put into the clipboard, but this limit depends on the system configuration and is lower if you run Emacs as a subprocess of another program. If the killed text does not fit, Emacs outputs a message saying so, and does not put the text into the clipboard.

空字符也不能放入 Windows 剪贴板中。如果被删除的文本包含空字符,Emacs 不会将此类文本放入剪贴板,并在回显区域中显示一条消息来说明这一点。

Null characters also cannot be put into the Windows clipboard. If the killed text includes null characters, Emacs does not put such text into the clipboard, and displays in the echo area a message to that effect.

变量dos-display-scancodes,当非 时nil,指示 Emacs 显示每次击键的ASCII值和键盘扫描码;此功能可作为命令的补充 view-lossage,用于调试。

The variable dos-display-scancodes, when non-nil, directs Emacs to display the ASCII value and the keyboard scan code of each keystroke; this feature serves as a complement to the view-lossage command, for debugging.


H.12.3 MS-DOS 上的显示

H.12.3 Display on MS-DOS

MS-DOS 上的显示不能使用字体变体,例如粗体或斜体,但它支持多个字体,每个字体都可以指定前景色和背景色。因此,您可以font-lock通过定义相关面以使用不同的颜色来获得使用字体(例如 、丰富文本模式等)的 Emacs 包的完整功能。使用list-colors-display命令(请参阅面的颜色)和list-faces-display命令(请参阅文本面)来查看可用的颜色和面以及它们的外观。

Display on MS-DOS cannot use font variants, like bold or italic, but it does support multiple faces, each of which can specify a foreground and a background color. Therefore, you can get the full functionality of Emacs packages that use fonts (such as font-lock, Enriched Text mode, and others) by defining the relevant faces to use different colors. Use the list-colors-display command (see Colors for Faces) and the list-faces-display command (see Text Faces) to see what colors and faces are available and what they look like.

有关 Emacs 如何显示 DOS 显示中内置的本机字体不支持的字形和字符的信息, 请参阅本章后面的MS-DOS 上的国际支持。

See International Support on MS-DOS, later in this chapter, for information on how Emacs displays glyphs and characters that aren’t supported by the native font built into the DOS display.

当 Emacs 启动时,它将光标形状更改为实心框。这是为了与其他系统兼容,其中框光标是 Emacs 中的默认设置。通过指定cursor-type变量中的参数, 可以将此默认形状更改为条形default-frame-alist (请参阅创建框架)。 MS-DOS 终端不支持垂直条形光标,因此条形光标是水平的,并且该width参数(如果由框架参数指定)实际上决定了其高度。因此,barhbar光标类型在 MS-DOS 上产生相同的效果。作为扩展,条形光标规范可以包括光标的起始扫描线及其宽度,如下所示:

When Emacs starts, it changes the cursor shape to a solid box. This is for compatibility with other systems, where the box cursor is the default in Emacs. This default shape can be changed to a bar by specifying the cursor-type parameter in the variable default-frame-alist (see Creating Frames). The MS-DOS terminal doesn’t support a vertical-bar cursor, so the bar cursor is horizontal, and the width parameter, if specified by the frame parameters, actually determines its height. For this reason, the bar and hbar cursor types produce the same effect on MS-DOS. As an extension, the bar cursor specification can include the starting scan line of the cursor as well as its width, like this:

'(光标类型条宽度. start
 '(cursor-type bar width . start)

此外,如果宽度参数为负数,则光标栏从字符单元格的顶部开始。

In addition, if the width parameter is negative, the cursor bar begins at the top of the character cell.

MS-DOS 终端一次只能显示一帧。 Emacs 框架工具在 MS-DOS 上的工作方式与在文本终端上的工作方式非常相似(请参阅框架和图形显示)。当您从 MS-Windows 上的 DOS 窗口运行 Emacs 时,您可以使可见框架小于全屏,但 Emacs 仍然无法一次显示多个框架。

The MS-DOS terminal can only display a single frame at a time. The Emacs frame facilities work on MS-DOS much as they do on text terminals (see Frames and Graphical Displays). When you run Emacs from a DOS window on MS-Windows, you can make the visible frame smaller than the full screen, but Emacs still cannot display more than a single frame at a time.

dos-mode4350命令将显示切换为 43 或 50 行,具体取决于您的硬件;该dos-mode25命令切换到默认的 80x25 屏幕尺寸。

The dos-mode4350 command switches the display to 43 or 50 lines, depending on your hardware; the dos-mode25 command switches to the default 80x25 screen size.

默认情况下,Emacs 只知道如何设置 80 列 x 25、28、35、40、43 或 50 行的屏幕尺寸。但是,如果您的视频适配器具有特殊的视频模式,可以将显示切换为其他尺寸,那么您也可以让 Emacs 支持这些模式。当您要求 Emacs 将帧切换到 n行 x m列维度时,它会检查是否存在名为 的变量,如果存在,则使用其值(必须是整数)作为要切换到的视频模式。 (Emacs 通过使用寄存器中的值 调用 BIOS 函数来切换到该视频模式。)例如,假设您的适配器在进入视频模式 85 时将切换到 66x80 尺寸。然后您可以通过输入将以下内容添加到您的screen-dimensions-nxmSet Video Modescreen-dimensions-nxmAL_emacs文件:

By default, Emacs only knows how to set screen sizes of 80 columns by 25, 28, 35, 40, 43 or 50 rows. However, if your video adapter has special video modes that will switch the display to other sizes, you can have Emacs support those too. When you ask Emacs to switch the frame to n rows by m columns dimensions, it checks if there is a variable called screen-dimensions-nxm, and if so, uses its value (which must be an integer) as the video mode to switch to. (Emacs switches to that video mode by calling the BIOS Set Video Mode function with the value of screen-dimensions-nxm in the AL register.) For example, suppose your adapter will switch to 66x80 dimensions when put into video mode 85. Then you can make Emacs support this screen size by putting the following into your _emacs file:

(setq 屏幕尺寸-66x80 85)
(setq screen-dimensions-66x80 85)

由于 MS-DOS 上的 Emacs 只能将帧大小设置为特定支持的尺寸,因此它无法满足每个可能的帧大小调整请求。当请求不支持的大小时,Emacs 将选择指定大小之外的下一个更大的受支持大小。例如,如果您要求 36x80 帧,您将得到 40x80。

Since Emacs on MS-DOS can only set the frame size to specific supported dimensions, it cannot honor every possible frame resizing request. When an unsupported size is requested, Emacs chooses the next larger supported size beyond the specified size. For example, if you ask for 36x80 frame, you will get 40x80 instead.

仅当变量与指定的大小完全匹配时才使用它们;搜索下一个更大的受支持大小时会忽略它们。在上面的示例中,即使您的 VGA 支持 38x80 尺寸并且您定义了一个 具有合适值的变量,当您请求 36x80 帧时,您仍然会得到 40x80 屏幕。如果您想在这种情况下获得 38x80 大小,可以通过设置 与 相同视频模式值 命名的变量来实现。 screen-dimensions-nxmscreen-dimensions-38x80screen-dimensions-36x80screen-dimensions-38x80

The variables screen-dimensions-nxm are used only when they exactly match the specified size; the search for the next larger supported size ignores them. In the above example, even if your VGA supports 38x80 dimensions and you define a variable screen-dimensions-38x80 with a suitable value, you will still get 40x80 screen when you ask for a 36x80 frame. If you want to get the 38x80 size in this case, you can do it by setting the variable named screen-dimensions-36x80 with the same video mode value as screen-dimensions-38x80.

在 MS-DOS 上更改框架尺寸会将所有其他框架更改为新尺寸。

Changing frame dimensions on MS-DOS has the effect of changing all the other frames to the new dimensions.


H.12.4 MS-DOS 上的文件名

H.12.4 File Names on MS-DOS

在 MS-DOS 上,文件名不区分大小写,并且限制为八个字符,还可以选择添加一个句点和另外三个字符。 Emacs 对这些限制有足够的了解,可以处理适用于其他操作系统的文件名。例如,前导点 '文件名中的 ' 在 MS-DOS 中无效,因此 Emacs 透明地将它们转换为下划线 '_';因此,您的默认初始化文件(请参阅Emacs 初始化文件)被称为_emacs在 MS-DOS 上。 MS-DOS 本身通常会忽略句号之前或之后的多余字符;因此,如果您访问该文件LongFileName.EvenLongerExtension,你会默默得到长文件.eve,但 Emacs 仍会在模式行上显示长文件名。除此之外,您可以指定在 MS-DOS 下有效的文件名;如上所述的透明转换仅适用于 Emacs 内置的文件名。

On MS-DOS, file names are case-insensitive and limited to eight characters, plus optionally a period and three more characters. Emacs knows enough about these limitations to handle file names that were meant for other operating systems. For instance, leading dots ‘.’ in file names are invalid in MS-DOS, so Emacs transparently converts them to underscores ‘_’; thus your default init file (see The Emacs Initialization File) is called _emacs on MS-DOS. Excess characters before or after the period are generally ignored by MS-DOS itself; thus, if you visit the file LongFileName.EvenLongerExtension, you will silently get longfile.eve, but Emacs will still display the long file name on the mode line. Other than that, it’s up to you to specify file names which are valid under MS-DOS; the transparent conversion as described above only works on file names built into Emacs.

MS-DOS 上对文件名的上述限制使得几乎不可能在不丢失某些原始文件名字符的情况下构建备份文件的名称(请参阅单个备份或编号备份)。例如,备份文件的名称文档.txt文档.tx~即使使用单个备份。

The above restrictions on the file names on MS-DOS make it almost impossible to construct the name of a backup file (see Single or Numbered Backups) without losing some of the original file name characters. For example, the name of a backup file for docs.txt is docs.tx~ even if single backup is used.

如果您在 Windows 9X、Windows ME 或 Windows 2000/XP 下将 Emacs 作为 DOS 应用程序运行,则可以打开对长文件名的支持。如果您这样做,Emacs 不会截断文件名或将其转换为小写;而是会截断文件名。相反,它逐字使用您指定的文件名。要启用长文件名支持,请将环境变量设置LFN为 'y' 在启动 Emacs 之前。不幸的是,Windows NT 不允许 DOS 程序访问长文件名,因此为 MS-DOS 构建的 Emacs 只能看到它们的短 8+3 别名。

If you run Emacs as a DOS application under Windows 9X, Windows ME, or Windows 2000/XP, you can turn on support for long file names. If you do that, Emacs doesn’t truncate file names or convert them to lower case; instead, it uses the file names that you specify, verbatim. To enable long file name support, set the environment variable LFN to ‘y’ before starting Emacs. Unfortunately, Windows NT doesn’t allow DOS programs to access long file names, so Emacs built for MS-DOS will only see their short 8+3 aliases.

MS-DOS 没有主目录的概念,因此 MS-DOS 上的 Emacs 假装它的安装目录是HOME 环境变量的值。也就是说,如果您的 Emacs 二进制文件, emacs.exe,在目录中c:/utils/emacs/bin,那么 Emacs 的行为就像HOME设置为 'c:/utils/emacs'。特别是,这是 Emacs 查找 init 文件的地方_emacs。考虑到这一点,您可以使用 '' 在文件名中作为主目录的别名,就像在 GNU 或 Unix 上一样。您还可以 HOME在启动 Emacs 之前在环境中设置变量;然后它的值将覆盖上面的默认行为。

MS-DOS has no notion of home directory, so Emacs on MS-DOS pretends that the directory where it is installed is the value of the HOME environment variable. That is, if your Emacs binary, emacs.exe, is in the directory c:/utils/emacs/bin, then Emacs acts as if HOME were set to ‘c:/utils/emacs’. In particular, that is where Emacs looks for the init file _emacs. With this in mind, you can use ‘~’ in file names as an alias for the home directory, as you would on GNU or Unix. You can also set HOME variable in the environment before starting Emacs; its value will then override the above default behavior.

MS-DOS 上的 Emacs 处理名称/dev特别是,因为 DJGPP 模拟器库中的一个功能假装 I/O 设备在该目录中具有名称。我们建议您避免使用名为的实际目录/dev在任何磁盘上。

Emacs on MS-DOS handles the name /dev specially, because of a feature in the emulator libraries of DJGPP that pretends I/O devices have names in that directory. We recommend that you avoid using an actual directory named /dev on any disk.


H.12.5 打印和 MS-DOS

H.12.5 Printing and MS-DOS

如果 POSIX 样式的程序不可用,打印命令(例如,lpr-buffer 请参阅打印硬拷贝)和ps-print-buffer(请参阅PostScript 硬拷贝)可以通过将输出发送到打印机端口之一在 MS-DOS 上运行。lpr相同的 Emacs 变量控制所有系统上的打印,但在某些情况下,它们在 MS-DOS 上具有不同的默认值。

Printing commands, such as lpr-buffer (see Printing Hard Copies) and ps-print-buffer (see PostScript Hardcopy) can work on MS-DOS by sending the output to one of the printer ports, if a POSIX-style lpr program is unavailable. The same Emacs variables control printing on all systems, but in some cases they have different default values on MS-DOS.

有关设置打印到网络打印机的详细信息, 请参阅打印和 MS-Windows 。

See Printing and MS-Windows, for details about setting up printing to a networked printer.

某些打印机期望非ASCII文本的 DOS 代码页编码,即使它们连接到对同一区域设置使用不同编码的 Windows 计算机也是如此。例如,在 Latin-1 语言环境中,DOS 使用代码页 850,而 Windows 使用代码页 1252。请参阅MS-DOS 上的国际支持。当您从 Windows 打印到此类打印机时,您可以在 ; 之前使用( ) 命令;然后,Emacs 会将文本转换为您指定的 DOS 代码页。例如, 将打印该区域,同时将其转换为代码页 850 编码。 C-x RET cuniversal-coding-system-argumentM-x lpr-bufferC-x RET c cp850-dos RET M-x lpr-region RET

Some printers expect DOS codepage encoding of non-ASCII text, even though they are connected to a Windows machine that uses a different encoding for the same locale. For example, in the Latin-1 locale, DOS uses codepage 850 whereas Windows uses codepage 1252. See International Support on MS-DOS. When you print to such printers from Windows, you can use the C-x RET c (universal-coding-system-argument) command before M-x lpr-buffer; Emacs will then convert the text to the DOS codepage that you specify. For example, C-x RET c cp850-dos RET M-x lpr-region RET will print the region while converting it to the codepage 850 encoding.

为了向后兼容,在 MS-DOS 上, dos-printer ( )的值dos-ps-printer(如果有值)将覆盖 printer-name( ) 的值。ps-printer-name

For backwards compatibility, the value of dos-printer (dos-ps-printer), if it has a value, overrides the value of printer-name (ps-printer-name), on MS-DOS.


H.12.6 MS-DOS 上的国际支持

H.12.6 International Support on MS-DOS

MS-DOS 上的 Emacs 支持与 GNU、Unix 和其他平台上相同的国际字符集(请参阅国际字符集支持),包括用于在不同字符集之间进行转换的编码系统。但是,由于 MS-DOS/MS-Windows 和其他系统之间不兼容,因此您应该注意此支持的几个特定于 DOS 的方面。本节介绍这些方面。

Emacs on MS-DOS supports the same international character sets as it does on GNU, Unix and other platforms (see International Character Set Support), including coding systems for converting between the different character sets. However, due to incompatibilities between MS-DOS/MS-Windows and other systems, there are several DOS-specific aspects of this support that you should be aware of. This section describes these aspects.

下面的描述主要针对 Emacs 的 MS-DOS 端口,特别是在讨论对 Emacs 用户的实际影响的地方。

The description below is largely specific to the MS-DOS port of Emacs, especially where it talks about practical implications for Emacs users.

M-x dos-codepage-setup
M-x dos-codepage-setup

设置适合当前 DOS 代码页的 Emacs 显示和编码系统。

Set up Emacs display and coding systems as appropriate for the current DOS codepage.

MS-DOS 设计为在任何给定时间都支持 256 个字符的字符集,但也提供了多种字符集可供选择。替代字符集称为DOS 代码页。每个代码页都包含全部 128 个ASCII字符,但其他 128 个字符(代码 128 到 255)因代码页而异。每个 DOS 代码页都由 3 位数字标识,例如 850、862 等。

MS-DOS is designed to support one character set of 256 characters at any given time, but gives you a variety of character sets to choose from. The alternative character sets are known as DOS codepages. Each codepage includes all 128 ASCII characters, but the other 128 characters (codes 128 through 255) vary from one codepage to another. Each DOS codepage is identified by a 3-digit number, such as 850, 862, etc.

与允许您同时使用多种字体的 X 不同,MS-DOS 通常不允许在单个会话中使用多个代码页。 MS-DOS 被设计为在系统启动时加载单个代码页,并要求您重新启动才能更改它31。当您在其他系统(例如 MS-Windows)上运行 DOS 可执行文件时,同样的限制也适用。

In contrast to X, which lets you use several fonts at the same time, MS-DOS normally doesn’t allow use of several codepages in a single session. MS-DOS was designed to load a single codepage at system startup, and require you to reboot in order to change it31. Much the same limitation applies when you run DOS executables on other systems such as MS-Windows.

对于 MS-DOS 上的多字节操作,Emacs 需要知道所选的 DOS 代码页可以显示哪些字符。因此,它在启动后不久就会查询系统以获取所选的代码页编号,并将该编号存储在变量 中dos-codepage。某些系统返回当前代码页的默认值 437,即使实际代码页不同。 (当您使用显示硬件中内置的代码页时,通常会发生这种情况。)您可以通过dos-codepage在 init 文件中 设置变量来指定 Emacs 使用的不同代码页。

For multibyte operation on MS-DOS, Emacs needs to know which characters the chosen DOS codepage can display. So it queries the system shortly after startup to get the chosen codepage number, and stores the number in the variable dos-codepage. Some systems return the default value 437 for the current codepage, even though the actual codepage is different. (This typically happens when you use the codepage built into the display hardware.) You can specify a different codepage for Emacs to use by setting the variable dos-codepage in your init file.

多字节 Emacs 仅支持某些 DOS 代码页:那些可以显示远东脚本的代码页,例如日语代码页 932,以及那些编码单个 ISO 8859 字符集的代码页。

Multibyte Emacs supports only certain DOS codepages: those which can display Far-Eastern scripts, like the Japanese codepage 932, and those that encode a single ISO 8859 character set.

远东代码页可以直接显示这些国家/地区的 MULE 字符集之一,因此 Emacs 只需设置为使用代码页支持的适当终端编码系统即可。本节其余部分描述的特殊功能主要与编码 ISO 8859 字符集的代码页有关。

The Far-Eastern codepages can directly display one of the MULE character sets for these countries, so Emacs simply sets up to use the appropriate terminal coding system that is supported by the codepage. The special features described in the rest of this section mostly pertain to codepages that encode ISO 8859 character sets.

对于与 ISO 字符集之一对应的代码页,Emacs 根据代码页编号了解字符集。 Emacs 自动创建一个编码系统来支持读写使用当前代码页的文件,并且默认使用这个编码系统。该编码系统的名称是,其中 nnn是代码页编号。32cpnnn

For the codepages that correspond to one of the ISO character sets, Emacs knows the character set based on the codepage number. Emacs automatically creates a coding system to support reading and writing files that use the current codepage, and uses this coding system by default. The name of this coding system is cpnnn, where nnn is the codepage number.32

所有编码系统都使用字母 'cpnnnD'(“DOS”)作为它们的模式行助记符。由于终端编码系统和文件 I/O 的默认编码系统在启动时都设置为正确的编码系统,因此 MS-DOS 上的模式行以 ' 开头是正常的。cpnnn-DD\-'。请参阅模式行。远东 DOS 终端不使用编码系统,因此它们的初始模式行看起来像 Emacs 默认值。 cpnnn

All the cpnnn coding systems use the letter ‘D’ (for “DOS”) as their mode-line mnemonic. Since both the terminal coding system and the default coding system for file I/O are set to the proper cpnnn coding system at startup, it is normal for the mode line on MS-DOS to begin with ‘-DD\-’. See The Mode Line. Far-Eastern DOS terminals do not use the cpnnn coding systems, and thus their initial mode line looks like the Emacs default.

由于代码页编号还指示您正在使用哪个脚本,因此 Emacs 会自动运行set-language-environment来选择该脚本的语言环境(请参阅语言环境)。

Since the codepage number also indicates which script you are using, Emacs automatically runs set-language-environment to select the language environment for that script (see Language Environments).

如果缓冲区包含属于其他 ISO 8859 字符集的字符,而不是所选 DOS 代码页支持的字符集,Emacs 将使用一系列ASCII字符来显示它。例如,如果当前代码页没有字母 ' 的字形ò' (小的 '' 带有重音),它显示为 '{`o}',其中大括号作为视觉指示,表明这是单个字符。 (这对于某些非拉丁字符(例如希腊语或希伯来语字母表中的字符)来说可能看起来很尴尬,但了解该语言的人仍然可以阅读。)尽管该字符可能占据屏幕上的几列,但它实际上是仍然只是一个字符,所有 Emacs 命令都将其视为一个字符。

If a buffer contains a character belonging to some other ISO 8859 character set, not the one that the chosen DOS codepage supports, Emacs displays it using a sequence of ASCII characters. For example, if the current codepage doesn’t have a glyph for the letter ‘ò’ (small ‘o’ with a grave accent), it is displayed as ‘{`o}’, where the braces serve as a visual indication that this is a single character. (This may look awkward for some non-Latin characters, such as those from Greek or Hebrew alphabets, but it is still readable by a person who knows the language.) Even though the character may occupy several columns on the screen, it is really still just a single character, and all Emacs commands treat it as one.

MS-Windows 提供了自己的代码页,与相同语言环境的 DOS 代码页不同。例如,DOS代码页850支持与Windows代码页1252相同的字符集; DOS 代码页 855 支持与 Windows 代码页 1251 等相同的字符集。MS-Windows 版本的 Emacs 在使用 ' 调用时使用当前代码页进行显示。-西北' 选项。

MS-Windows provides its own codepages, which are different from the DOS codepages for the same locale. For example, DOS codepage 850 supports the same character set as Windows codepage 1252; DOS codepage 855 supports the same character set as Windows codepage 1251, etc. The MS-Windows version of Emacs uses the current codepage for display when invoked with the ‘-nw’ option.


H.12.7 MS-DOS 上的子进程

H.12.7 Subprocesses on MS-DOS

由于MS-DOS是单进程“操作系统”,因此异步子进程不可用。特别是,Shell 模式及其变体不起作用。大多数使用异步子进程的 Emacs 功能也无法在 MS-DOS 上运行,包括 Shell 模式和 GUD。如有疑问,请尝试看看;不起作用的命令会输出一条错误消息,指出不支持异步进程。

Because MS-DOS is a single-process “operating system”, asynchronous subprocesses are not available. In particular, Shell mode and its variants do not work. Most Emacs features that use asynchronous subprocesses also don’t work on MS-DOS, including Shell mode and GUD. When in doubt, try and see; commands that don’t work output an error message saying that asynchronous processes aren’t supported.

通过同步运行下级进程,在 Emacs 下进行编译M-x compile、搜索文件 M-x grep并显示文件之间的差异确实有效。M-x diff这意味着在下级进程完成之前您无法进行任何编辑。

Compilation under Emacs with M-x compile, searching files with M-x grep and displaying differences between files with M-x diff do work, by running the inferior processes synchronously. This means you cannot do any more editing until the inferior process finishes.

通过对程序同步调用的特殊支持,拼写检查也可以工作ispell。这比其他平台上的异步调用慢。

Spell checking also works, by means of special support for synchronous invocation of the ispell program. This is slower than the asynchronous invocation on other platforms.

您可以使用该命令,而不是在 MS-DOS 上运行的 Shell 模式M-x eshell。这会调用 Eshell 包,该包完全在 Emacs Lisp 中实现类似 POSIX 的 shell。

Instead of the Shell mode, which doesn’t work on MS-DOS, you can use the M-x eshell command. This invokes the Eshell package that implements a POSIX-like shell entirely in Emacs Lisp.

相比之下,编译为本机 Windows 应用程序的 Emacs 确实支持异步子进程。请参阅Windows 9X/ME 和 Windows NT/2K/XP/Vista/7/8/10 上的子进程

By contrast, Emacs compiled as a native Windows application does support asynchronous subprocesses. See Subprocesses on Windows 9X/ME and Windows NT/2K/XP/Vista/7/8/10.

打印命令(例如,lpr-buffer 请参阅打印硬拷贝)和ps-print-buffer(请参阅PostScript 硬拷贝)在 MS-DOS 中通过将输出发送到打印机端口之一来工作。请参阅打印和 MS-DOS

Printing commands, such as lpr-buffer (see Printing Hard Copies) and ps-print-buffer (see PostScript Hardcopy), work in MS-DOS by sending the output to one of the printer ports. See Printing and MS-DOS.

当您在 MS-DOS 上同步运行子进程时,请确保程序终止并且不会尝试读取键盘输入。如果程序不自行终止,您将无法终止它,因为 MS-DOS 没有提供终止进程的通用方法。在这些情况下, 按C-c或有时可能会有所帮助。C-Break

When you run a subprocess synchronously on MS-DOS, make sure the program terminates and does not try to read keyboard input. If the program does not terminate on its own, you will be unable to terminate it, because MS-DOS provides no general way to terminate a process. Pressing C-c or C-Break might sometimes help in these cases.

MS-DOS 不支持访问其他计算机上的文件。其他面向网络的命令(例如发送邮件、Web 浏览、远程登录等)也不起作用,除非 MS-DOS 中内置了带有网络重定向器的网络访问功能。

Accessing files on other machines is not supported on MS-DOS. Other network-oriented commands such as sending mail, Web browsing, remote login, etc., don’t work either, unless network access is built into MS-DOS with some network redirector.

MS-DOS 上的 Dired 使用该ls-lisp包(请参阅MS-Windows 上的仿真ls)。因此,MS-DOS 上的 Dired 仅支持您可以在变量中提及的一些可能选项dired-listing-switches。有效的选项是'-A','-A','-C','-我','-r','-S','-s','-t', 和 '-u'。

Dired on MS-DOS uses the ls-lisp package (see Emulation of ls on MS-Windows). Therefore, Dired on MS-DOS supports only some of the possible options you can mention in the dired-listing-switches variable. The options that work are ‘-A’, ‘-a’, ‘-c’, ‘-i’, ‘-r’, ‘-S’, ‘-s’, ‘-t’, and ‘-u’.


GNU 宣言

The GNU Manifesto

下面出现的 GNU 宣言是 Richard Stallman 在 GNU 项目开始时撰写的,旨在寻求参与和支持。在最初的几年里,它进行了一些小的更新以适应发展,但现在似乎最好保持不变,正如大多数人所看到的那样。

从那时起,我们了解到一些常见的误解,不同的措辞可以帮助避免。 1993 年添加的脚注有助于澄清这些要点。

有关可用 GNU 软件的最新信息,请访问我们的网站https://www.gnu.org。有关软件任务和其他贡献方式,请参阅https://www.gnu.org/help

The GNU Manifesto which appears below was written by Richard Stallman at the beginning of the GNU project, to ask for participation and support. For the first few years, it was updated in minor ways to account for developments, but now it seems best to leave it unchanged as most people have seen it.

Since that time, we have learned about certain common misunderstandings that different wording could help avoid. Footnotes added in 1993 help clarify these points.

For up-to-date information about available GNU software, please see our web site, https://www.gnu.org. For software tasks and other ways to contribute, see https://www.gnu.org/help.

什么是 GNU? Gnu 不是 Unix!

What’s GNU? Gnu’s Not Unix!

GNU 代表 Gnu's Not Unix,是我正在编写的完整的 Unix 兼容软件系统的名称,这样我就可以将它免费提供给每个可以使用它的人。33其他几位志愿者正在帮助我。非常需要时间、金钱、计划和设备的贡献。

GNU, which stands for Gnu’s Not Unix, is the name for the complete Unix-compatible software system which I am writing so that I can give it away free to everyone who can use it.33 Several other volunteers are helping me. Contributions of time, money, programs and equipment are greatly needed.

到目前为止,我们有一个使用 Lisp 编写编辑器命令的 Emacs 文本编辑器、一个源代码级调试器、一个与 yacc 兼容的解析器生成器、一个链接器和大约 35 个实用程序。 shell(命令解释器)即将完成。新的可移植优化 C 编译器已经自行编译并可能于今年发布。初始内核已经存在,但需要更多功能来模拟 Unix。当内核和编译器完成后,就可以分发适合程序开发的GNU系统。我们将使用 TeX 作为我们的文本格式化程序,但 nroff 正在开发中。我们还将使用免费的、便携式的 X 窗口系统。之后,我们将添加一个可移植的 Common Lisp、一个 Empire 游戏、一个电子表格和数百个其他东西,以及在线文档。我们希望最终能够提供 Unix 系统通常附带的一切有用的东西,甚至更多。

So far we have an Emacs text editor with Lisp for writing editor commands, a source level debugger, a yacc-compatible parser generator, a linker, and around 35 utilities. A shell (command interpreter) is nearly completed. A new portable optimizing C compiler has compiled itself and may be released this year. An initial kernel exists but many more features are needed to emulate Unix. When the kernel and compiler are finished, it will be possible to distribute a GNU system suitable for program development. We will use TeX as our text formatter, but an nroff is being worked on. We will use the free, portable X window system as well. After this we will add a portable Common Lisp, an Empire game, a spreadsheet, and hundreds of other things, plus on-line documentation. We hope to supply, eventually, everything useful that normally comes with a Unix system, and more.

GNU 将能够运行 Unix 程序,但与 Unix 不同。我们将根据我们在其他操作系统方面的经验,进行所有方便的改进。特别是,我们计划拥有更长的文件名、文件版本号、防崩溃文件系统、文件名补全、独立于终端的显示支持,也许最终有一个基于 Lisp 的窗口系统,通过该系统,多个 Lisp 程序和普通 Unix 程序可以共享屏幕。 C 和 Lisp 都将作为系统编程语言提供。我们将尝试支持 UUCP、MIT Chaosnet 和 Internet 协议进行通信。

GNU will be able to run Unix programs, but will not be identical to Unix. We will make all improvements that are convenient, based on our experience with other operating systems. In particular, we plan to have longer file names, file version numbers, a crashproof file system, file name completion perhaps, terminal-independent display support, and perhaps eventually a Lisp-based window system through which several Lisp programs and ordinary Unix programs can share a screen. Both C and Lisp will be available as system programming languages. We will try to support UUCP, MIT Chaosnet, and Internet protocols for communication.

GNU 最初的目标是具有虚拟内存的 68000/16000 级别的机器,因为它们是最容易运行 GNU 的机器。让它在较小的机器上运行的额外工作将留给那些想要在较小的机器上使用它的人。

GNU is aimed initially at machines in the 68000/16000 class with virtual memory, because they are the easiest machines to make it run on. The extra effort to make it run on smaller machines will be left to someone who wants to use it on them.

为了避免可怕的混乱,当“GNU”是这个项目的名称时,请发音“G”。

To avoid horrible confusion, please pronounce the “G” in the word “GNU” when it is the name of this project.

为什么我必须编写 GNU

Why I Must Write GNU

我认为黄金法则要求,如果我喜欢一个程序,我必须与其他喜欢它的人分享它。软件销售商想要分化用户并征服用户,让每个用户都同意不与他人共享。我拒绝以这种方式破坏与其他用户的团结。我无法凭良心签署保密协议或软件许可协议。多年来,我在人工智能实验室工作,抵制这种倾向和其他冷漠态度,但最终他们做得太过分了:我不能留在一个违背我意愿为我做这些事情的机构里。

I consider that the golden rule requires that if I like a program I must share it with other people who like it. Software sellers want to divide the users and conquer them, making each user agree not to share with others. I refuse to break solidarity with other users in this way. I cannot in good conscience sign a nondisclosure agreement or a software license agreement. For years I worked within the Artificial Intelligence Lab to resist such tendencies and other inhospitalities, but eventually they had gone too far: I could not remain in an institution where such things are done for me against my will.

为了让我能够继续无耻地使用计算机,我决定整合足够多的免费软件,这样我就能够在没有任何非免费软件的情况下相处。我已经从人工智能实验室辞职,麻省理工学院没有任何合法借口阻止我放弃 GNU。

So that I can continue to use computers without dishonor, I have decided to put together a sufficient body of free software so that I will be able to get along without any software that is not free. I have resigned from the AI lab to deny MIT any legal excuse to prevent me from giving GNU away.

为什么 GNU 将与 Unix 兼容

Why GNU Will Be Compatible with Unix

Unix 不是我理想的系统,但也还不错。 Unix 的本质特性似乎都不错,我想我可以在不破坏它们的情况下弥补 Unix 所缺乏的东西。与 Unix 兼容的系统将方便许多其他人采用。

Unix is not my ideal system, but it is not too bad. The essential features of Unix seem to be good ones, and I think I can fill in what Unix lacks without spoiling them. And a system compatible with Unix would be convenient for many other people to adopt.

GNU 将如何可用

How GNU Will Be Available

GNU 不属于公共领域。每个人都被允许修改和重新分发 GNU,但不允许任何分发者限制其进一步的重新分发。也就是说,不允许进行专有修改。我想确保所有版本的 GNU 都保持免费。

GNU is not in the public domain. Everyone will be permitted to modify and redistribute GNU, but no distributor will be allowed to restrict its further redistribution. That is to say, proprietary modifications will not be allowed. I want to make sure that all versions of GNU remain free.

为什么许多其他程序员想要提供帮助

Why Many Other Programmers Want to Help

我发现许多其他程序员对 GNU 很感兴趣并希望提供帮助。

I have found many other programmers who are excited about GNU and want to help.

许多程序员对系统软件的商业化感到不满。这可能会让他们赚更多的钱,但这要求他们感觉与其他程序员总体上存在冲突,而不是感觉自己是同志。程序员之间友谊的根本行为就是程序的共享;现在通常使用的营销安排基本上禁止程序员将他人视为朋友。软件购买者必须在友谊和遵守法律之间做出选择。当然,许多人认为友谊更重要。但那些相信法律的人往往对这两种选择都感到不安。他们变得愤世嫉俗,认为编程只是一种赚钱的方式。

Many programmers are unhappy about the commercialization of system software. It may enable them to make more money, but it requires them to feel in conflict with other programmers in general rather than feel as comrades. The fundamental act of friendship among programmers is the sharing of programs; marketing arrangements now typically used essentially forbid programmers to treat others as friends. The purchaser of software must choose between friendship and obeying the law. Naturally, many decide that friendship is more important. But those who believe in law often do not feel at ease with either choice. They become cynical and think that programming is just a way of making money.

通过开发和使用 GNU 而不是专有程序,我们可以热情好客并遵守法律。此外,GNU 还充当了激励的榜样和团结其他人一起分享的旗帜。这可以给我们一种和谐的感觉,如果我们使用非免费软件,这是不可能的。对于我交谈过的大约一半的程序员来说,这是金钱无法替代的重要幸福。

By working on and using GNU rather than proprietary programs, we can be hospitable to everyone and obey the law. In addition, GNU serves as an example to inspire and a banner to rally others to join us in sharing. This can give us a feeling of harmony which is impossible if we use software that is not free. For about half the programmers I talk to, this is an important happiness that money cannot replace.

您如何做出贡献

How You Can Contribute

我正在请求计算机制造商捐赠机器和资金。我正在请求个人捐赠项目和工作。

I am asking computer manufacturers for donations of machines and money. I’m asking individuals for donations of programs and work.

如果您捐赠机器,您可以预期的一个后果是 GNU 将尽早在它们上运行。这些机器应该是完整的、随时可用的系统,批准在住宅区使用,并且不需要复杂的冷却或电力。

One consequence you can expect if you donate machines is that GNU will run on them at an early date. The machines should be complete, ready to use systems, approved for use in a residential area, and not in need of sophisticated cooling or power.

我发现很多程序员都渴望为 GNU 贡献兼职工作。对于大多数项目来说,这种兼职分散的工作很难协调;独立编写的部分无法协同工作。但对于取代 Unix 的特定任务来说,这个问题就不存在了。一个完整的 Unix 系统包含数百个实用程序,每个实用程序都有单独的文档。大多数接口规范都是由 Unix 兼容性决定的。如果每个贡献者都可以为单个 Unix 实用程序编写兼容的替代品,并使其在 Unix 系统上代替原始实用程序正常工作,那么这些实用程序放在一起时就能正常工作。即使墨菲制造了一些意想不到的问题,组装这些组件也将是一项可行的任务。 (内核需要更密切的沟通,并且将由一个小而紧密的小组进行开发。)

I have found very many programmers eager to contribute part-time work for GNU. For most projects, such part-time distributed work would be very hard to coordinate; the independently-written parts would not work together. But for the particular task of replacing Unix, this problem is absent. A complete Unix system contains hundreds of utility programs, each of which is documented separately. Most interface specifications are fixed by Unix compatibility. If each contributor can write a compatible replacement for a single Unix utility, and make it work properly in place of the original on a Unix system, then these utilities will work right when put together. Even allowing for Murphy to create a few unexpected problems, assembling these components will be a feasible task. (The kernel will require closer communication and will be worked on by a small, tight group.)

如果我得到捐款,我也许可以雇用一些全职或兼职人员。按照程序员的标准,薪水不会很高,但我正在寻找那些将建立社区精神与赚钱同等重要的人。我认为这是一种让有奉献精神的人们能够将全部精力投入到 GNU 工作中的一种方式,这样他们就不用再以其他方式谋生了。

If I get donations of money, I may be able to hire a few people full or part time. The salary won’t be high by programmers’ standards, but I’m looking for people for whom building community spirit is as important as making money. I view this as a way of enabling dedicated people to devote their full energies to working on GNU by sparing them the need to make a living in another way.

为什么所有计算机用户都会受益

Why All Computer Users Will Benefit

一旦GNU被编写出来,每个人都可以免费获得好的系统软件,就像空气一样。34

Once GNU is written, everyone will be able to obtain good system software free, just like air.34

这不仅仅意味着为每个人节省 Unix 许可证的价格。这意味着将避免大量重复的系统编程工作。这种努力可以用来推进最先进的技术。

This means much more than just saving everyone the price of a Unix license. It means that much wasteful duplication of system programming effort will be avoided. This effort can go instead into advancing the state of the art.

完整的系统源代码将提供给所有人。因此,需要对系统进行更改的用户始终可以自由地自己进行更改,或者雇用任何可用的程序员或公司为他进行更改。用户将不再受到拥有源代码并有权进行更改的程序员或公司的摆布。

Complete system sources will be available to everyone. As a result, a user who needs changes in the system will always be free to make them himself, or hire any available programmer or company to make them for him. Users will no longer be at the mercy of one programmer or company which owns the sources and is in sole position to make changes.

学校将能够通过鼓励所有学生学习和改进系统代码来提供更多的教育环境。哈佛大学的计算机实验室曾经有这样的政策:如果其源代码未公开显示,则任何程序都不能安装在系统上,并通过实际上拒绝安装某些程序来维持这一政策。我受到了很大的启发。

Schools will be able to provide a much more educational environment by encouraging all students to study and improve the system code. Harvard’s computer lab used to have the policy that no program could be installed on the system if its sources were not on public display, and upheld it by actually refusing to install certain programs. I was very much inspired by this.

最后,考虑谁拥有系统软件以及有权或无权使用它做什么的开销将被取消。

Finally, the overhead of considering who owns the system software and what one is or is not entitled to do with it will be lifted.

使人们付费使用程序的安排(包括副本许可)总是会通过繁琐的机制来计算一个人必须支付多少费用(即哪些程序),从而给社会带来巨大的成本。只有警察国家才能强迫每个人都服从他们。考虑一个必须以高昂成本制造空气的空间站:按每升空气向每个呼吸者收取费用可能是公平的,但即使每个人都有能力支付空气费用,整天整夜戴着计量防毒面具也是无法忍受的。到处都有电视摄像机监视你是否摘下面具,这太令人震惊了。最好用人头税来支持航空工厂,然后扔掉口罩。

Arrangements to make people pay for using a program, including licensing of copies, always incur a tremendous cost to society through the cumbersome mechanisms necessary to figure out how much (that is, which programs) a person must pay for. And only a police state can force everyone to obey them. Consider a space station where air must be manufactured at great cost: charging each breather per liter of air may be fair, but wearing the metered gas mask all day and all night is intolerable even if everyone can afford to pay the air bill. And the TV cameras everywhere to see if you ever take the mask off are outrageous. It’s better to support the air plant with a head tax and chuck the masks.

复制全部或部分程序对于程序员来说就像呼吸一样自然,而且富有成效。它应该是免费的。

Copying all or parts of a program is as natural to a programmer as breathing, and as productive. It ought to be as free.

一些容易反驳的对 GNU 目标的反对意见

Some Easily Rebutted Objections to GNU’s Goals

“如果它是免费的,没有人会使用它,因为这意味着他们不能依赖任何支持。”

“你必须向该计划收费才能支付提供支持的费用。”

“Nobody will use it if it is free, because that means they can’t rely on any support.”

“You have to charge for the program to pay for providing the support.”

如果人们宁愿付费购买 GNU 加服务,也不愿获得没有服务的免费 G​​NU,那么一家为获得免费 GNU 的人提供公正服务的公司应该是有利可图的。35

If people would rather pay for GNU plus service than get GNU free without service, a company to provide just service to people who have obtained GNU free ought to be profitable.35

我们必须区分真正的编程工作形式的支持和纯粹的指导。前者不能依赖软件供应商。如果你的问题没有被足够多的人分享,供应商会告诉你滚蛋。

We must distinguish between support in the form of real programming work and mere handholding. The former is something one cannot rely on from a software vendor. If your problem is not shared by enough people, the vendor will tell you to get lost.

如果您的企业需要能够依赖支持,唯一的方法就是拥有所有必要的资源和工具。然后您可以聘请任何可用的人员来解决您的问题;你不受任何人的摆布。对于 Unix,源代码的价格使得大多数企业都没有考虑到这一点。有了 GNU,这将很容易。没有合适的人选还是有可能的,但这不能归咎于分配安排。 GNU 并不能消除世界上所有的问题,而只能消除其中的一些问题。

If your business needs to be able to rely on support, the only way is to have all the necessary sources and tools. Then you can hire any available person to fix your problem; you are not at the mercy of any individual. With Unix, the price of sources puts this out of consideration for most businesses. With GNU this will be easy. It is still possible for there to be no available competent person, but this problem cannot be blamed on distribution arrangements. GNU does not eliminate all the world’s problems, only some of them.

与此同时,对计算机一无所知的用户需要指导:为他们做一些他们自己可以轻松完成但不知道如何做的事情。

Meanwhile, the users who know nothing about computers need handholding: doing things for them which they could easily do themselves but don’t know how.

此类服务可以由仅销售手持和维修服务的公司提供。如果用户确实愿意花钱获得带服务的产品,那么他们也会愿意在免费获得产品的情况下购买服务。服务企业将在质量和价格上展开竞争;用户不会被任何特定的人束缚。同时,我们这些不需要该服务的人应该能够使用该程序而无需支付服务费用。

Such services could be provided by companies that sell just hand-holding and repair service. If it is true that users would rather spend money and get a product with service, they will also be willing to buy the service having got the product free. The service companies will compete in quality and price; users will not be tied to any particular one. Meanwhile, those of us who don’t need the service should be able to use the program without paying for the service.

“如果没有广告,你就无法接触到很多人,你必须为该计划收费来支持这一点。”

“为人们可以免费获得的程序做广告是没有用的。”

“You cannot reach many people without advertising, and you must charge for the program to support that.”

“It’s no use advertising a program people can get free.”

有多种形式的免费或非常便宜的宣传可以用来向大量计算机用户宣传 GNU 之类的东西。但通过广告确实可以接触到更多的微型计算机用户。如果情况确实如此,那么一家以收费复制和邮寄 GNU 服务为广告的企业应该足够成功,足以支付其广告费用和更多费用。这样,只有从广告中受益的用户才会付费。

There are various forms of free or very cheap publicity that can be used to inform numbers of computer users about something like GNU. But it may be true that one can reach more microcomputer users with advertising. If this is really so, a business which advertises the service of copying and mailing GNU for a fee ought to be successful enough to pay for its advertising and more. This way, only the users who benefit from the advertising pay for it.

另一方面,如果很多人从他们的朋友那里得到 GNU,而这些公司没有成功,这将表明广告对于传播 GNU 并不是真正必要的。为什么自由市场的倡导者不想让自由市场来决定这一点?36

On the other hand, if many people get GNU from their friends, and such companies don’t succeed, this will show that advertising was not really necessary to spread GNU. Why is it that free market advocates don’t want to let the free market decide this?36

“我的公司需要一个专有的操作系​​统来获得竞争优势。”

“My company needs a proprietary operating system to get a competitive edge.”

GNU 将把操作系统软件从竞争领域中剔除。你将无法在这个领域获得优势,但你的竞争对手也无法超越你。你和他们将在其他领域竞争,同时在这一领域互惠互利。如果您的企业销售操作系统,您将不会喜欢 GNU,但这对您来说很困难。如果您从事其他业务,GNU 可以帮助您避免陷入昂贵的操作系统销售业务。

GNU will remove operating system software from the realm of competition. You will not be able to get an edge in this area, but neither will your competitors be able to get an edge over you. You and they will compete in other areas, while benefiting mutually in this one. If your business is selling an operating system, you will not like GNU, but that’s tough on you. If your business is something else, GNU can save you from being pushed into the expensive business of selling operating systems.

我希望看到 GNU 的发展得到许多制造商和用户的捐赠的支持,从而降低每个人的成本。37

I would like to see GNU development supported by gifts from many manufacturers and users, reducing the cost to each.37

“程序员难道不应该因为他们的创造力而得到奖励吗?”

“Don’t programmers deserve a reward for their creativity?”

如果说有什么值得奖励的话,那就是社会贡献。创造力可以成为社会贡献,但前提是社会可以自由使用其成果。如果程序员应该因创建创新程序而获得奖励,那么同样,如果他们限制这些程序的使用,他们也应该受到惩罚。

If anything deserves a reward, it is social contribution. Creativity can be a social contribution, but only in so far as society is free to use the results. If programmers deserve to be rewarded for creating innovative programs, by the same token they deserve to be punished if they restrict the use of these programs.

“程序员难道不应该为他的创造力要求奖励吗?”

“Shouldn’t a programmer be able to ask for a reward for his creativity?”

只要不使用破坏性的手段,想要工作报酬或寻求收入最大化并没有什么错。但当今软件领域的惯用手段是基于破坏。

There is nothing wrong with wanting pay for work, or seeking to maximize one’s income, as long as one does not use means that are destructive. But the means customary in the field of software today are based on destruction.

通过限制程序的使用来从程序用户那里获取金钱具有破坏性,因为这些限制减少了程序的使用量和方式。这减少了人类从该计划中获得的财富。当刻意选择限制时,其有害后果就是刻意破坏。

Extracting money from users of a program by restricting their use of it is destructive because the restrictions reduce the amount and the ways that the program can be used. This reduces the amount of wealth that humanity derives from the program. When there is a deliberate choice to restrict, the harmful consequences are deliberate destruction.

一个好公民不会使用这种破坏性手段来变得更富有,因为如果每个人都这样做,我们都会因相互破坏而变得更穷。这就是康德伦理学;或者,黄金法则。由于我不喜欢每个人都囤积信息所带来的后果,因此我必须认为这样做是错误的。具体来说,渴望因自己的创造力而获得奖励并不能成为剥夺世界上全部或部分创造力的理由。

The reason a good citizen does not use such destructive means to become wealthier is that, if everyone did so, we would all become poorer from the mutual destructiveness. This is Kantian ethics; or, the Golden Rule. Since I do not like the consequences that result if everyone hoards information, I am required to consider it wrong for one to do so. Specifically, the desire to be rewarded for one’s creativity does not justify depriving the world in general of all or part of that creativity.

“程序员不会饿死吗?”

“Won’t programmers starve?”

我可以回答说,没有人被迫成为一名程序员。我们大多数人都无法靠站在街上做鬼脸来赚到钱。但我们并没有因此注定要一辈子站在街上做鬼脸、挨饿。我们做点别的事。

I could answer that nobody is forced to be a programmer. Most of us cannot manage to get any money for standing on the street and making faces. But we are not, as a result, condemned to spend our lives standing on the street making faces, and starving. We do something else.

但这是错误的答案,因为它接受了提问者隐含的假设:如果没有软件的所有权,程序员不可能获得一分钱。据说要么全有,要么全无。

But that is the wrong answer because it accepts the questioner’s implicit assumption: that without ownership of software, programmers cannot possibly be paid a cent. Supposedly it is all or nothing.

程序员不会挨饿的真正原因是他们仍然有可能通过编程获得报酬;只是没有像现在付那么多钱。

The real reason programmers will not starve is that it will still be possible for them to get paid for programming; just not paid as much as now.

限制复制并不是软件业务的唯一基础。这是最常见的基础,因为它带来的钱最多。如果被禁止或被客户拒绝,软件业务将转移到现在使用频率较低的其他组织基地。组织任何类型的业务总是有多种方法。

Restricting copying is not the only basis for business in software. It is the most common basis because it brings in the most money. If it were prohibited, or rejected by the customer, software business would move to other bases of organization which are now used less often. There are always numerous ways to organize any kind of business.

在新的基础上,编程可能不会像现在那样有利可图。但这并不是反对这一改变的理由。销售员现在的工资并没有被认为是不公平的。如果程序员也做出同样的事情,那也不是不公平的。 (实际上,他们的收入仍然远高于这个数字。)

Probably programming will not be as lucrative on the new basis as it is now. But that is not an argument against the change. It is not considered an injustice that sales clerks make the salaries that they now do. If programmers made the same, that would not be an injustice either. (In practice they would still make considerably more than that.)

“难道人们没有权利控制自己创造力的使用方式吗?”

“Don’t people have a right to control how their creativity is used?”

“控制自己的想法的使用”实际上就是控制他人的生活;它通常被用来让他们的生活变得更加困难。

“Control over the use of one’s ideas” really constitutes control over other people’s lives; and it is usually used to make their lives more difficult.

仔细研究过知识产权问题38的人(比如律师)说,知识产权并不存在固有的权利。政府承认的所谓知识产权是通过为特定目的而制定的特定立法行为而创建的。

People who have studied the issue of intellectual property rights38 carefully (such as lawyers) say that there is no intrinsic right to intellectual property. The kinds of supposed intellectual property rights that the government recognizes were created by specific acts of legislation for specific purposes.

例如,专利制度的建立是为了鼓励发明人披露其发明的细节。其目的是帮助社会而不是帮助发明家。当时,一项专利的寿命只有 17 年,与现有技术的进步速度相比还很短。由于专利只是制造商之间的问题,对于制造商来说,与建立生产相比,许可协议的成本和精力都很少,因此专利通常不会造成太大损害。它们并不妨碍大多数使用专利产品的人。

For example, the patent system was established to encourage inventors to disclose the details of their inventions. Its purpose was to help society rather than to help inventors. At the time, the life span of 17 years for a patent was short compared with the rate of advance of the state of the art. Since patents are an issue only among manufacturers, for whom the cost and effort of a license agreement are small compared with setting up production, the patents often do not do much harm. They do not obstruct most individuals who use patented products.

版权的概念在古代并不存在,当时作者经常在非小说作品中大量抄袭其他作者。这种做法很有用,也是许多作者的作品得以幸存的唯一途径,甚至是部分作品。版权制度的创建是为了鼓励作者创作。在它被发明的领域——书籍,只能在印刷机上经济地复制——它没有造成什么害处,也没有妨碍大多数读书的人。

The idea of copyright did not exist in ancient times, when authors frequently copied other authors at length in works of non-fiction. This practice was useful, and is the only way many authors’ works have survived even in part. The copyright system was created expressly for the purpose of encouraging authorship. In the domain for which it was invented—books, which could be copied economically only on a printing press—it did little harm, and did not obstruct most of the individuals who read the books.

所有知识产权都只是社会授予的许可证,因为人们认为,无论正确还是错误,整个社会都会通过授予它们而受益。但在任何特定情况下,我们都必须问:授予此类许可真的会更好吗?我们许可某人从事什么样的行为?

All intellectual property rights are just licenses granted by society because it was thought, rightly or wrongly, that society as a whole would benefit by granting them. But in any particular situation, we have to ask: are we really better off granting such license? What kind of act are we licensing a person to do?

今天的程序与一百年前的书籍有很大不同。复制程序最简单的方法是从一个邻居复制到另一个程序,程序同时具有不同的源代码和目标代码,以及程序是用于使用而不是阅读和欣赏的事实,这些事实结合在一起就可以创建版权执行者在物质和精神上损害整个社会的情况;无论法律是否允许,一个人都不应这样做。

The case of programs today is very different from that of books a hundred years ago. The fact that the easiest way to copy a program is from one neighbor to another, the fact that a program has both source code and object code which are distinct, and the fact that a program is used rather than read and enjoyed, combine to create a situation in which a person who enforces a copyright is harming society as a whole both materially and spiritually; in which a person should not do so regardless of whether the law enables him to.

“竞争使事情做得更好。”

“Competition makes things get done better.”

竞争的范式是一场赛跑:通过奖励获胜者,我们鼓励每个人跑得更快。当资本主义真的以这种方式运作时,它就会做得很好;但它的捍卫者错误地认为它总是这样运作。如果跑步者忘记了为什么提供奖励并一心想获胜,无论如何,他们可能会找到其他策略,例如攻击其他跑步者。如果赛跑者打起来,他们都会迟到。

The paradigm of competition is a race: by rewarding the winner, we encourage everyone to run faster. When capitalism really works this way, it does a good job; but its defenders are wrong in assuming it always works this way. If the runners forget why the reward is offered and become intent on winning, no matter how, they may find other strategies—such as, attacking other runners. If the runners get into a fist fight, they will all finish late.

专有和秘密软件在道德上相当于拳击比赛中的跑步者。遗憾的是,我们唯一的裁判似乎并不反对打架;他只是调节它们(“每跑十码,就可以开一枪”)。他真的应该驱散他们,并惩罚那些试图打架的跑步者。

Proprietary and secret software is the moral equivalent of runners in a fist fight. Sad to say, the only referee we’ve got does not seem to object to fights; he just regulates them (“For every ten yards you run, you can fire one shot”). He really ought to break them up, and penalize runners for even trying to fight.

“如果没有金钱激励,每个人都会停止编程吗?”

“Won’t everyone stop programming without a monetary incentive?”

事实上,很多人会在完全没有金钱激励的情况下进行编程。编程对某些人(通常是最擅长编程的人)具有不可抗拒的吸引力。尽管没有希望以这种方式谋生,但仍坚持不懈的专业音乐家并不缺乏。

Actually, many people will program with absolutely no monetary incentive. Programming has an irresistible fascination for some people, usually the people who are best at it. There is no shortage of professional musicians who keep at it even though they have no hope of making a living that way.

但事实上,这个问题虽然经常被问到,但并不适合这种情况。程序员的报酬不会消失,只会变得更少。所以正确的问题是,有人会在金钱激励减少的情况下进行编程吗?我的经验表明他们会的。

But really this question, though commonly asked, is not appropriate to the situation. Pay for programmers will not disappear, only become less. So the right question is, will anyone program with a reduced monetary incentive? My experience shows that they will.

十多年来,世界上许多最优秀的程序员在人工智能实验室工作,薪水远远低于在其他地方的薪水。他们获得了多种非金钱奖励:例如名誉和欣赏。而且创造力也很有趣,这本身就是一种奖励。

For more than ten years, many of the world’s best programmers worked at the Artificial Intelligence Lab for far less money than they could have had anywhere else. They got many kinds of non-monetary rewards: fame and appreciation, for example. And creativity is also fun, a reward in itself.

然后,当他们有机会做同样有趣的工作并赚很多钱时,他们中的大多数人就离开了。

Then most of them left when offered a chance to do the same interesting work for a lot of money.

事实表明,人们会出于财富以外的原因进行编程;但如果也有机会赚很多钱,他们就会期待并要求它。低薪组织在与高薪组织的竞争中表现不佳,但如果高薪组织被禁止,它们也不一定会表现得很差。

What the facts show is that people will program for reasons other than riches; but if given a chance to make a lot of money as well, they will come to expect and demand it. Low-paying organizations do poorly in competition with high-paying ones, but they do not have to do badly if the high-paying ones are banned.

“我们迫切需要程序员。如果他们要求我们停止帮助邻居,我们就必须服从。”

“We need the programmers desperately. If they demand that we stop helping our neighbors, we have to obey.”

你永远不会绝望到不得不服从这种要求。请记住:数以百万计的资金用于防御,但没有一分钱用于贡品!

You’re never so desperate that you have to obey this sort of demand. Remember: millions for defense, but not a cent for tribute!

“程序员需要以某种方式谋生。”

“Programmers need to make a living somehow.”

从短期来看,这是事实。然而,程序员可以通过多种方式谋生,而无需出售程序的使用权。这种方式现在很常见,因为它给程序员和商人带来了最多的钱,而不是因为它是唯一的谋生方式。如果你想找到其他方法,很容易找到。这里有一些例子。

In the short run, this is true. However, there are plenty of ways that programmers could make a living without selling the right to use a program. This way is customary now because it brings programmers and businessmen the most money, not because it is the only way to make a living. It is easy to find other ways if you want to find them. Here are a number of examples.

推出新计算机的制造商将支付将操作系统移植到新硬件上的费用。

A manufacturer introducing a new computer will pay for the porting of operating systems onto the new hardware.

教学、指导和维护服务的销售也可以雇用程序员。

The sale of teaching, hand-holding and maintenance services could also employ programmers.

有新想法的人可以将程序作为免费软件39分发,向满意的用户请求捐赠,或者出售手持服务。我遇到过一些人,他们已经成功地以这种方式工作了。

People with new ideas could distribute programs as freeware39, asking for donations from satisfied users, or selling hand-holding services. I have met people who are already working this way successfully.

有相关需求的用户可以组建用户群,并缴纳会费。一个团体将与编程公司签订合同,编写该团体成员想要使用的程序。

Users with related needs can form users’ groups, and pay dues. A group would contract with programming companies to write programs that the group’s members would like to use.

各种开发都可以通过软件税来资助:

All sorts of development can be funded with a Software Tax:

假设每个购买计算机的人都必须缴纳价格的 x% 作为软件税。政府将这笔钱交给 NSF 这样的机构用于软件开发。

但如果计算机购买者自己向软件开发捐款,他就可以抵免税收。他可以向自己选择的项目捐款——通常选择该项目是因为他希望在项目完成后使用其成果。他可以抵免任何金额的捐赠,最高可达他必须缴纳的税款总额。

总税率可以由纳税人投票决定,并根据应纳税额进行加权。

后果:

  • 计算机使用社区支持软件开发。
  • 该社区决定需要何种程度的支持。
  • 关心自己的份额花在哪些项目上的用户可以自行选择。

Suppose everyone who buys a computer has to pay x percent of the price as a software tax. The government gives this to an agency like the NSF to spend on software development.

But if the computer buyer makes a donation to software development himself, he can take a credit against the tax. He can donate to the project of his own choosing—often, chosen because he hopes to use the results when it is done. He can take a credit for any amount of donation up to the total tax he had to pay.

The total tax rate could be decided by a vote of the payers of the tax, weighted according to the amount they will be taxed on.

The consequences:

  • The computer-using community supports software development.
  • This community decides what level of support is needed.
  • Users who care which projects their share is spent on can choose this for themselves.

从长远来看,让程序免费是迈向后稀缺世界的一步,在这个世界里,没有人需要为了谋生而努力工作。人们每周花十个小时完成立法、家庭咨询、机器人维修和小行星勘探等必要任务后,可以自由地投入到编程等有趣的活动中。不再需要靠编程谋生。

In the long run, making programs free is a step toward the post-scarcity world, where nobody will have to work very hard just to make a living. People will be free to devote themselves to activities that are fun, such as programming, after spending the necessary ten hours a week on required tasks such as legislation, family counseling, robot repair and asteroid prospecting. There will be no need to be able to make a living from programming.

我们已经大大减少了整个社会为实现实际生产力而必须做的工作量,但其中只有一小部分转化为工人的闲暇,因为生产活动需要大量的非生产活动。其主要原因是官僚主义和反对竞争的等距斗争。自由软件将大大减少软件生产领域的这些消耗。我们必须这样做,以便将生产力方面的技术进步转化为更少的工作。

We have already greatly reduced the amount of work that the whole society must do for its actual productivity, but only a little of this has translated itself into leisure for workers because much nonproductive activity is required to accompany productive activity. The main causes of this are bureaucracy and isometric struggles against competition. Free software will greatly reduce these drains in the area of software production. We must do this, in order for technical gains in productivity to translate into less work for us.


词汇表

Glossary

缩写
Abbrev

缩写是一个文本字符串,当存在于缓冲区中时,它会扩展为不同的文本字符串。例如,您可以将几个字母定义为要经常插入的长短语的缩写。参见缩写

An abbrev is a text string that expands into a different text string when present in the buffer. For example, you might define a few letters as an abbrev for a long phrase that you want to insert frequently. See Abbrevs.

正在中止
Aborting

中止意味着退出递归编辑 (qv)。命令C-]M-x top-level用于此目的。请参阅退出和中止

Aborting means getting out of a recursive edit (q.v.). The commands C-] and M-x top-level are used for this. See Quitting and Aborting.

活动区域
Active Region

在文本中的某个位置设置标记 (qv) 也会激活它。当标记处于活动状态时,我们将该区域称为活动区域。请参阅“标记”和“区域”

Setting the mark (q.v.) at a position in the text also activates it. When the mark is active, we call the region an active region. See The Mark and the Region.

Alt
Alt

Alt 是键盘输入字符可能具有的修饰符位的名称。要创建字符 Alt,请在按住该Alt 键的同时键入该字符。这些字符的名称以Alt- (通常缩写A-为)开头。 (请注意,许多终端都有一个标记Alt为真正的Meta键的键。)请参阅Alt

Alt is the name of a modifier bit that a keyboard input character may have. To make a character Alt, type it while holding down the Alt key. Such characters are given names that start with Alt- (usually written A- for short). (Note that many terminals have a key labeled Alt that is really a Meta key.) See Alt.

争论
Argument

请参阅术语表---数字参数

See Glossary---Numeric Argument.

ASCII字符
ASCII character

ASCII字符可以是ASCII控制字符,也可以是ASCII打印字符。请参阅用户输入的类型

An ASCII character is either an ASCII control character or an ASCII printing character. See Kinds of User Input.

ASCII控制字符
ASCII control character

ASCII控制字符是大写字母的控制版本,或者字符 ' 之一的控制版本@[\]^_?'。

An ASCII control character is the Control version of an upper-case letter, or the Control version of one of the characters ‘@[\]^_?’.

ASCII打印字符
ASCII printing character

ASCII字母、数字、空格和以下标点字符:'!@#$%^&*()_-+=|\~`{}[]:;"'<>,.?/'。

ASCII letters, digits, space, and the following punctuation characters: ‘!@#$%^&*()_-+=|\~`{}[]:;"'<>,.?/’.

自动填充模式
Auto Fill Mode

自动填充模式是一种次要模式 (qv),在该模式下,您插入的文本会自动分成给定最大宽度的行。请参阅填充文本

Auto Fill mode is a minor mode (q.v.) in which text that you insert is automatically broken into lines of a given maximum width. See Filling Text.

自动保存
Auto Saving

自动保存是定期将 Emacs 缓冲区的内容保存在一个专门命名的文件中的做法,以便在由于系统错误或用户错误而丢失缓冲区时保留信息。请参阅自动保存:灾难防护

Auto saving is the practice of periodically saving the contents of an Emacs buffer in a specially-named file, so that the information will be preserved if the buffer is lost due to a system error or user error. See Auto-Saving: Protection Against Disasters.

自动加载
Autoloading

当 Lisp 程序请求 Lisp 库中的函数时,Emacs 可以自动加载 Lisp 库。这称为“自动加载”。请参阅Emacs 的 Lisp 代码库

Emacs can automatically load Lisp libraries when a Lisp program requests a function from those libraries. This is called “autoloading”. See Libraries of Lisp Code for Emacs.

回溯
Backtrace

回溯是一系列函数调用的跟踪,显示程序如何到达某个点。它主要用于查找和纠正错误(qv)。 Emacs 可以在发出错误信号或您键入时显示回溯C-g(请参阅术语表---退出)。请参阅错误报告清单

A backtrace is a trace of a series of function calls showing how a program arrived at a certain point. It is used mainly for finding and correcting bugs (q.v.). Emacs can display a backtrace when it signals an error or when you type C-g (see Glossary---Quitting). See Checklist for Bug Reports.

备份文件
Backup File

备份文件记录当前编辑会话之前文件的内容。 Emacs 自动创建备份文件,以帮助您追踪或取消您后来后悔所做的更改。请参阅备份文件

A backup file records the contents that a file had before the current editing session. Emacs makes backup files automatically to help you track down or cancel changes you later regret making. See Backup Files.

平衡括号
Balancing Parentheses

Emacs 可以手动或自动平衡括号(或其他匹配分隔符)。您可以使用在括号分组上移动的命令进行手动平衡(请参阅在括号结构中移动)。自动平衡的工作原理是闪烁或突出显示与您刚刚插入的分隔符相匹配的分隔符,或者为您插入匹配的分隔符(请参阅匹配括号)。

Emacs can balance parentheses (or other matching delimiters) either manually or automatically. You do manual balancing with the commands to move over parenthetical groupings (see Moving in the Parenthesis Structure). Automatic balancing works by blinking or highlighting the delimiter that matches the one you just inserted, or inserting the matching delimiter for you (see Matching Parens).

平衡的表达
Balanced Expressions

平衡表达式是语法上可识别的表达式,例如 C 中的符号 (qv)、数字、字符串常量、块或括号表达式。请参阅平衡表达式

A balanced expression is a syntactically recognizable expression, such as a symbol (q.v.), number, string constant, block, or parenthesized expression in C. See Balanced Expressions.

气球帮助
Balloon Help

请参阅术语表---工具提示

See Glossary---Tooltips.

基础缓冲区
Base Buffer

基本缓冲区是其文本由间接缓冲区 (qv) 共享的缓冲区。

A base buffer is a buffer whose text is shared by an indirect buffer (q.v.).

双向文本
Bidirectional Text

一些人类语言,例如英语,是从左到右书写的。其他语言,例如阿拉伯语,是从右向左书写的。 Emacs 支持这两种形式,以及它们的任意混合——这就是“双向文本”。请参阅双向编辑

Some human languages, such as English, are written from left to right. Others, such as Arabic, are written from right to left. Emacs supports both of these forms, as well as any mixture of them—this is “bidirectional text”. See Bidirectional Editing.

绑定
Bind

绑定键序列意味着给它一个绑定(qv)。请参阅交互更改键绑定

To bind a key sequence means to give it a binding (q.v.). See Changing Key Bindings Interactively.

捆绑
Binding

按键序列在 Emacs 中通过绑定来获取其含义,​​该绑定是一个命令 (qv)——一个在您键入该序列时运行的 Lisp 函数。请参阅绑定。定制通常涉及将角色重新绑定到不同的命令功能。所有键序列的绑定都记录在键映射 (qv) 中。请参阅键盘映射

A key sequence gets its meaning in Emacs by having a binding, which is a command (q.v.)—a Lisp function that is run when you type that sequence. See Binding. Customization often involves rebinding a character to a different command function. The bindings of all key sequences are recorded in the keymaps (q.v.). See Keymaps.

空行
Blank Lines

空行是只包含空格的行。 Emacs 有几个用于操作缓冲区中的空白行的命令。请参阅空行

Blank lines are lines that contain only whitespace. Emacs has several commands for operating on the blank lines in the buffer. See Blank Lines.

书签
Bookmark

书签类似于寄存器 (qv),因为它们记录缓冲区中的位置,以便稍后返回。与寄存器不同,书签在 Emacs 会话之间持续存在。请参阅书签

Bookmarks are akin to registers (q.v.) in that they record positions in buffers to which you can return later. Unlike registers, bookmarks persist between Emacs sessions. See Bookmarks.

边界
Border

边框是沿着框架边缘的细小空间,仅用于间隔,不用于显示任何内容。 Emacs 框架有一个普通的外部边框,位于包括菜单栏在内的所有内容之外,还有一个围绕文本窗口、滚动条和边缘的内部边框,并将它们与菜单栏和工具栏分开。您可以使用选项和资源自定义两个边框(请参阅内部和外部边框)。边框与边缘 (qv) 不同。

A border is a thin space along the edge of the frame, used just for spacing, not for displaying anything. An Emacs frame has an ordinary external border, outside of everything including the menu bar, plus an internal border that surrounds the text windows, their scroll bars and fringes, and separates them from the menu bar and tool bar. You can customize both borders with options and resources (see Internal and Outer Borders). Borders are not the same as fringes (q.v.).

缓冲
Buffer

缓冲区是基本的编辑单元;一个缓冲区对应一个正在编辑的文本。您通常有多个缓冲区,但在任何时候您都只编辑一个缓冲区,即当前缓冲区,尽管当您使用多个窗口或框架 (qv) 时可以看到多个缓冲区。大多数缓冲区正在访问(qv)某个文件。请参阅使用多个缓冲区

The buffer is the basic editing unit; one buffer corresponds to one text being edited. You normally have several buffers, but at any time you are editing only one, the current buffer, though several can be visible when you are using multiple windows or frames (q.v.). Most buffers are visiting (q.v.) some file. See Using Multiple Buffers.

缓冲器选择历史
Buffer Selection History

Emacs 保留缓冲区选择历史记录,记录每个 Emacs 缓冲区最近被选择的时间。这用于选择要选择的缓冲区。请参阅使用多个缓冲区

Emacs keeps a buffer selection history that records how recently each Emacs buffer has been selected. This is used for choosing which buffer to select. See Using Multiple Buffers.

漏洞
Bug

错误是程序的不正确或不合理的行为,或者是不准确或令人困惑的文档。 Emacs 开发人员非常认真地对待 Emacs 代码及其文档中的错误报告,并要求您报告发现的任何错误。请参阅报告错误

A bug is an incorrect or unreasonable behavior of a program, or inaccurate or confusing documentation. Emacs developers treat bug reports, both in Emacs code and its documentation, very seriously and ask you to report any bugs you find. See Reporting Bugs.

按钮按下事件
Button Down Event

按钮按下事件是当您按下鼠标按钮时立即生成的输入事件 (qv)。请参阅重新绑定鼠标按钮

A button down event is the kind of input event (q.v.) generated right away when you press down on a mouse button. See Rebinding Mouse Buttons.

默认情况下
By Default

请参阅术语表---默认

See Glossary---Default.

字节编译
Byte Compilation

参见术语表---编译

See Glossary---Compilation.

参见
cf.
比照
c.f.

拉丁语“confer”的缩写,意思是“比较”或“比较”。第二种变体“cf”是一个普遍存在的拼写错误。

Short for “confer” in Latin, which means “compare with” or “compare to”. The second variant, “c.f.”, is a widespread misspelling.

C-
C-

C-角色名称中的“Control”是“Control”的缩写。参见C-

C- in the name of a character is an abbreviation for Control. See C-.

C-M-
C-M-

C-M-角色名称中的 是 Control-Meta 的缩写。如果您的终端缺少真正的键,则可以通过键入然后键入相应的 Control 字符来Meta键入 Control-Meta 字符。ESC参见CM-

C-M- in the name of a character is an abbreviation for Control-Meta. If your terminal lacks a real Meta key, you type a Control-Meta character by typing ESC and then typing the corresponding Control character. See C-M-.

大小写转换
Case Conversion

大小写转换意味着将文本从大写更改为小写,反之亦然。请参阅大小写转换命令

Case conversion means changing text from upper case to lower case or vice versa. See Case Conversion Commands.

表壳折叠
Case Folding

大小写折叠意味着忽略同一字母的大小写变体之间的差异:大写、小写和标题大小写。 Emacs 在文本搜索中默认执行大小写折叠。请参阅搜索期间的宽松匹配

Case folding means ignoring the differences between case variants of the same letter: upper-case, lower-case, and title-case. Emacs performs case folding by default in text search. See Lax Matching During Searching.

特点
Character

字符构成 Emacs 缓冲区的内容。此外,按键序列 (qv) 通常由字符组成(尽管它们也可能包括其他输入事件)。请参阅用户输入的类型

Characters form the contents of an Emacs buffer. Also, key sequences (q.v.) are usually made up of characters (though they may include other input events as well). See Kinds of User Input.

人物折叠
Character Folding

字符折叠意味着忽略外观相似的字符之间的差异,例如a、 和ä之间的差异á。 Emacs 在文本搜索中默认执行字符折叠。请参阅搜索期间的宽松匹配

Character folding means ignoring differences between similarly looking characters, such as between a, and ä and á. Emacs performs character folding by default in text search. See Lax Matching During Searching.

字符集
Character Set

Emacs 支持多种字符集,每个字符集代表一个特定的字母表或脚本。请参阅国际字符集支持

Emacs supports a number of character sets, each of which represents a particular alphabet or script. See International Character Set Support.

字符终端
Character Terminal

请参阅术语表---文本终端

See Glossary---Text Terminal.

点击事件
Click Event

单击事件是按下鼠标按钮并在不移动鼠标的情况下释放它时生成的一种输入事件 (qv)。请参阅重新绑定鼠标按钮

A click event is the kind of input event (q.v.) generated when you press a mouse button and release it without moving the mouse. See Rebinding Mouse Buttons.

客户
Client

参见术语表---服务器

See Glossary---Server.

剪贴板
Clipboard

剪贴板是窗口系统提供的缓冲区,用于在应用程序之间传输文本。在 X Window 系统上,除了主选择 (qv) 之外,还提供剪贴板;在 MS-Windows 和 Mac 上,使用剪贴板而不是主要选择。请参阅使用剪贴板

A clipboard is a buffer provided by the window system for transferring text between applications. On the X Window System, the clipboard is provided in addition to the primary selection (q.v.); on MS-Windows and Mac, the clipboard is used instead of the primary selection. See Using the Clipboard.

编码系统
Coding System

编码系统是一种对文件或信息流中的文本字符进行编码的方法。 Emacs 能够在读取或写入文本时将文本与各种编码系统相互转换。请参阅编码系统

A coding system is a way to encode text characters in a file or in a stream of information. Emacs has the ability to convert text to or from a variety of coding systems when reading or writing it. See Coding Systems.

命令
Command

命令是专门定义的 Lisp 函数,可以用作 Emacs 中的键绑定或通过其名称调用(参见术语表---命令名称)。 (命令的另一个术语是 交互功能- 它们可以互换使用。)当您键入按键序列 (qv) 时,系统会在相关的键盘映射 (qv) 中查找其绑定 (qv) 以查找要运行的命令。请参阅按键和命令

A command is a Lisp function specially defined to be able to serve as a key binding in Emacs or to be invoked by its name (see Glossary---Command Name). (Another term for command is interactive function—they are used interchangeably.) When you type a key sequence (q.v.), its binding (q.v.) is looked up in the relevant keymaps (q.v.) to find the command to run. See Keys and Commands.

命令历史
Command History

请参阅术语表---迷你缓冲区历史

See Glossary---Minibuffer History.

命令名称
Command Name

命令名称是作为命令的 Lisp 符号 (qv) 的名称(请参阅键和命令)。您可以使用命令按名称调用任何命令 M-x(请参阅按名称运行命令)。

A command name is the name of a Lisp symbol (q.v.) that is a command (see Keys and Commands). You can invoke any command by its name using M-x (see Running Commands by Name).

评论
Comment

注释是程序中的文本,仅供阅读该程序的人使用,并且经过特殊标记,以便在加载或编译程序时将忽略它。 Emacs 提供了用于创建、对齐和删除注释的特殊命令。请参阅操纵评论

A comment is text in a program which is intended only for humans reading the program, and which is specially marked so that it will be ignored when the program is loaded or compiled. Emacs offers special commands for creating, aligning and killing comments. See Manipulating Comments.

通用语言
Common Lisp

Common Lisp 是 Lisp (qv) 的一种方言,比 Emacs Lisp 更大、更强大。 Emacs 在 CL 包中提供了 Common Lisp 的子集。请参阅Common Lisp 扩展中的概述

Common Lisp is a dialect of Lisp (q.v.) much larger and more powerful than Emacs Lisp. Emacs provides a subset of Common Lisp in the CL package. See Overview in Common Lisp Extensions.

汇编
Compilation

编译是从源代码创建可执行程序的过程。 Emacs 具有用于编译 Emacs Lisp 代码文件的命令(请参阅Emacs Lisp 参考手册中的字节编译)以及 C 和其他语言的程序(请参阅Emacs 下的运行编译)。字节编译的 Emacs Lisp 代码加载和执行速度更快。

Compilation is the process of creating an executable program from source code. Emacs has commands for compiling files of Emacs Lisp code (see Byte Compilation in the Emacs Lisp Reference Manual) and programs in C and other languages (see Running Compilations under Emacs). Byte-compiled Emacs Lisp code loads and executes faster.

完整钥匙
Complete Key

完整键是完全指定 Emacs 要执行的一个操作的键序列。例如,XC-fC-x m完整的键。完整的键的含义来自于与命令 (qv) 的绑定(参见词汇表---Bind )。因此,X通常绑定到命令来插入 'X' 在缓冲区中; C-x m通常绑定到开始撰写邮件消息的命令。请参阅

A complete key is a key sequence that fully specifies one action to be performed by Emacs. For example, X and C-f and C-x m are complete keys. Complete keys derive their meanings from being bound (see Glossary---Bind) to commands (q.v.). Thus, X is conventionally bound to a command to insert ‘X’ in the buffer; C-x m is conventionally bound to a command to begin composing a mail message. See Keys.

完成
Completion

完成是 Emacs 自动将名称缩写扩展为完整名称时所做的事情。当已知可能的有效输入集时,完成迷你缓冲区 (qv) 参数的完成;例如,命令名称、缓冲区名称和文件名称。通常在键入TAB,SPC或 时完成。RET请参阅完成

Completion is what Emacs does when it automatically expands an abbreviation for a name into the entire name. Completion is done for minibuffer (q.v.) arguments when the set of possible valid inputs is known; for example, on command names, buffer names, and file names. Completion usually occurs when TAB, SPC or RET is typed. See Completion.

延续线
Continuation Line

当一行文本比窗口宽度长时,它在显示时通常会占用多个屏幕行(但请参见 术语表---截断)。我们说文本行是连续的,并且第一行之后用于该文本行的所有屏幕行称为连续行。请参阅续行。一个相关的 Emacs 功能是填充 (qv)。

When a line of text is longer than the width of the window, it normally takes up more than one screen line when displayed (but see Glossary---Truncation). We say that the text line is continued, and all screen lines used for it after the first are called continuation lines. See Continuation Lines. A related Emacs feature is filling (q.v.).

控制字符
Control Character

控制字符是通过按住按键键入的字符 Ctrl。某些控制字符也有自己的键,因此您可以在不使用 的情况下键入它们Ctrl。例如, RETTABESCDEL都是控制字符。请参阅用户输入的类型

A control character is a character that you type by holding down the Ctrl key. Some control characters also have their own keys, so that you can type them without using Ctrl. For example, RET, TAB, ESC and DEL are all control characters. See Kinds of User Input.

版权左
Copyleft

Copyleft 是一种通知,给予公众重新分发和修改程序或其他艺术作品的法律许可,但要求修改后的版本带有类似的许可。版权通常被用来让用户分裂和无助;通过 Copyleft,我们扭转了这一局面,赋予用户权力并鼓励他们合作。

GNU 项目使用的 Copyleft 的特殊形式称为 GNU 通用公共许可证。请参阅GNU 通用公共许可证

A copyleft is a notice giving the public legal permission to redistribute and modify a program or other work of art, but requiring modified versions to carry similar permission. Copyright is normally used to keep users divided and helpless; with copyleft we turn that around to empower users and encourage them to cooperate.

The particular form of copyleft used by the GNU project is called the GNU General Public License. See GNU GENERAL PUBLIC LICENSE.

Ctrl
Ctrl

按住Ctrl或 控制键可输入控制字符 (qv)。参见术语表---C-

The Ctrl or control key is what you hold down in order to enter a control character (q.v.). See Glossary---C-.

当前缓冲区
Current Buffer

Emacs 中的当前缓冲区是大多数编辑命令操作的 Emacs 缓冲区。您可以选择任何 Emacs 缓冲区作为当前缓冲区。请参阅使用多个缓冲区

The current buffer in Emacs is the Emacs buffer on which most editing commands operate. You can select any Emacs buffer as the current one. See Using Multiple Buffers.

当前线路
Current Line

当前行是该点所在的行(请参阅Point)。

The current line is the line that point is on (see Point).

当前段落
Current Paragraph

当前段落是 point 所在的段落。如果 point 位于两个段落之间,则当前段落是 point 后面的段落。参见段落

The current paragraph is the paragraph that point is in. If point is between two paragraphs, the current paragraph is the one that follows point. See Paragraphs.

当前德芬
Current Defun

当前 defun 是 point 所在的 defun (qv)。如果 point 位于 defun 之间,则当前 defun 是 point 后面的那个 defun。请参阅顶级定义或 Defuns

The current defun is the defun (q.v.) that point is in. If point is between defuns, the current defun is the one that follows point. See Top-Level Definitions, or Defuns.

光标
Cursor

光标是屏幕上的矩形,指示发生插入和删除的位置(称为点;qv)。光标位于点后面的字符之上或之下。人们经常说“光标”,而严格来说,他们的意思是“点”。请参阅光标

The cursor is the rectangle on the screen which indicates the position (called point; q.v.) at which insertion and deletion takes place. The cursor is on or under the character that follows point. Often people speak of “the cursor” when, strictly speaking, they mean “point”. See Cursor.

定制化
Customization

定制是对 Emacs 的工作方式进行微小的改变,以反映您的偏好或需求。通常通过设置变量(请参阅变量)或面(请参阅自定义面)或重新绑定键序列(请参阅键映射) 来完成。

Customization is making minor changes in the way Emacs works, to reflect your preferences or needs. It is often done by setting variables (see Variables) or faces (see Customizing Faces), or by rebinding key sequences (see Keymaps).

剪切和粘贴
Cut and Paste

请参阅术语表---Killing术语表---Yanking

See Glossary---Killing, and Glossary---Yanking.

守护进程
Daemon

守护进程是在后台运行的系统级进程的标准术语。守护进程通常在系统首次启动时启动。当 Emacs 以守护进程模式运行时,它不会打开显示。您可以通过程序连接到它 emacsclient。请参阅使用 Emacs 作为服务器

A daemon is a standard term for a system-level process that runs in the background. Daemons are often started when the system first starts up. When Emacs runs in daemon-mode, it does not open a display. You connect to it with the emacsclient program. See Using Emacs as a Server.

默认参数
Default Argument

参数的默认值是在您未指定时采用的值。当使用迷你缓冲区读取参数时,如果您仅键入 ,则将使用默认参数RET。请参阅迷你缓冲区

The default for an argument is the value that will be assumed if you do not specify one. When the minibuffer is used to read an argument, the default argument is used if you just type RET. See The Minibuffer.

默认
Default

默认值是当您未明确指定要使用的值时用于特定目的的值。

A default is the value that is used for a certain purpose when you do not explicitly specify a value to use.

默认目录
Default Directory

当您指定不以 ' 开头的文件名时/' 或者 '',它是相对于当前缓冲区的默认目录进行解释的。 (在 MS 系统上,文件名以驱动器号 'X' 被视为绝对的,而不是相对的。)请参阅默认目录

When you specify a file name that does not start with ‘/’ or ‘~’, it is interpreted relative to the current buffer’s default directory. (On MS systems, file names that start with a drive letter ‘x:’ are treated as absolute, not relative.) See Default Directory.

德芬
Defun

defun 是程序顶层的主要定义。 “defun”这个名字来自 Lisp,其中大多数此类定义都使用构造 defun。请参阅顶级定义或 Defuns

A defun is a major definition at the top level in a program. The name “defun” comes from Lisp, where most such definitions use the construct defun. See Top-Level Definitions, or Defuns.

DEL
DEL

DEL是一个字符,运行命令以删除光标之前的文本字符。它通常是Delete key 或BACKSPACEkey,以易于键入的为准。参见删除

DEL is a character that runs the command to delete one character of text before the cursor. It is typically either the Delete key or the BACKSPACE key, whichever one is easy to type. See DEL.

删除
Deletion

删除意味着删除文本而不将其复制到 Kill Ring (qv) 中。另一种选择是杀戮(qv)。请参阅删除

Deletion means erasing text without copying it into the kill ring (q.v.). The alternative is killing (q.v.). See Deletion.

删除文件
Deletion of Files

删除文件意味着将其从文件系统中删除。 (请注意,某些系统使用垃圾桶或回收站的概念来允许您取消删除的文件。)请参阅其他文件操作

Deleting a file means erasing it from the file system. (Note that some systems use the concept of a trash can, or recycle bin, to allow you to undelete files.) See Miscellaneous File Operations.

删除消息
Deletion of Messages

删除邮件(在 Rmail 和其他邮件客户端中)意味着将其标记为从邮件文件中删除。在您清除 (qv) Rmail 文件之前,您仍然可以取消删除已删除的邮件。请参阅删除消息

Deleting a message (in Rmail, and other mail clients) means flagging it to be eliminated from your mail file. Until you expunge (q.v.) the Rmail file, you can still undelete the messages you have deleted. See Deleting Messages.

删除Windows
Deletion of Windows

删除窗口意味着将其从屏幕上消除。其他窗口会扩展以耗尽空间。窗口中的文本不会丢失,如果您愿意,您可以创建一个与旧窗口具有相同尺寸的新窗口。请参阅多个窗口

Deleting a window means eliminating it from the screen. Other windows expand to use up the space. The text that was in the window is not lost, and you can create a new window with the same dimensions as the old if you wish. See Multiple Windows.

目录
Directory

文件目录是文件系统中的命名集合,您可以在其中放置单个文件或子目录。它们有时被称为“文件夹”。请参阅文件目录

File directories are named collections in the file system, within which you can place individual files or subdirectories. They are sometimes referred to as “folders”. See File Directories.

目录局部变量
Directory Local Variable

目录局部变量是适用于某个目录中的所有文件的局部变量 (qv)。请参阅每目录局部变量

A directory local variable is a local variable (q.v.) that applies to all the files within a certain directory. See Per-Directory Local Variables.

目录名称
Directory Name

在 GNU 和其他类 Unix 系统上,目录名称是以 ' 结尾的字符串/'。例如,/没有这样的目录/是目录名称,而/tmp不是,尽管/tmp命名一个恰好是目录的文件。在 MS-Windows 上,关系更为复杂。请参阅Emacs Lisp 参考手册中的目录名称

On GNU and other Unix-like systems, directory names are strings that end in ‘/’. For example, /no-such-dir/ is a directory name whereas /tmp is not, even though /tmp names a file that happens to be a directory. On MS-Windows the relationship is more complicated. See Directory Names in the Emacs Lisp Reference Manual.

迪雷德
Dired

Dired 是 Emacs 的工具,它显示文件目录的内容并允许您“编辑目录”,对目录中的文件执行操作。请参阅Dired,目录编辑器

Dired is the Emacs facility that displays the contents of a file directory and allows you to “edit the directory”, performing operations on the files in the directory. See Dired, the Directory Editor.

禁用命令
Disabled Command

禁用命令是指未经特别确认不得运行的命令。禁用命令的常见原因是它会让初学者感到困惑。请参阅禁用命令

A disabled command is one that you may not run without special confirmation. The usual reason for disabling a command is that it is confusing for beginning users. See Disabling Commands.

向下事件
Down Event

“按钮按下事件”(qv) 的缩写。

Short for “button down event” (q.v.).

拖动事件
Drag Event

拖动事件是按下鼠标按钮、移动鼠标​​然后释放按钮时生成的一种输入事件 (qv)。请参阅重新绑定鼠标按钮

A drag event is the kind of input event (q.v.) generated when you press a mouse button, move the mouse, and then release the button. See Rebinding Mouse Buttons.

运球档案
Dribble File

dribble 文件是 Emacs 将您在键盘上键入的所有字符写入其中的文件。 Dribble 文件可以用来记录 Emacs 的 bug 调试。除非您指定,否则 Emacs 不会创建 dribble 文件。请参阅报告错误

A dribble file is a file into which Emacs writes all the characters that you type on the keyboard. Dribble files can be used to make a record for debugging Emacs bugs. Emacs does not make a dribble file unless you tell it to. See Reporting Bugs.

例如
e.g.

拉丁语“exempli gratia”的缩写,意思是“例如”。

Short for “exempli gratia” in Latin, which means “for example”.

回声区
Echo Area

回显区域是屏幕的底行,用于回显命令的参数、提出问题以及显示简短消息(包括错误消息)。消息存储在缓冲区中 *留言*以便您稍后查看。请参阅回声区域

The echo area is the bottom line of the screen, used for echoing the arguments to commands, for asking questions, and showing brief messages (including error messages). The messages are stored in the buffer *Messages* so you can review them later. See The Echo Area.

回声
Echoing

回显是通过显示输入事件(在回显区域中)来确认接收到输入事件。 Emacs 从不回显单字符按键序列;较长的按键序列仅在您键入时暂停时才会回显。

Echoing is acknowledging the receipt of input events by displaying them (in the echo area). Emacs never echoes single-character key sequences; longer key sequences echo only if you pause while typing them.

电的
Electric

如果一个角色通常是自插入的(qv),我们就说它是电动的,但当前的主要模式(qv)重新定义它也可以做其他事情。例如,某些编程语言主要模式定义特定的定界符来重新缩进行,或者除了自插入之外还插入一个或多个换行符。

We say that a character is electric if it is normally self-inserting (q.v.), but the current major mode (q.v.) redefines it to do something else as well. For example, some programming language major modes define particular delimiter characters to reindent the line, or insert one or more newlines in addition to self-insertion.

行结束
End Of Line

行尾是指示文本行结尾的字符或字符序列。在 GNU 和 Unix 系统上,这是换行符 (qv),但其他系统有其他约定。请参阅行尾。 Emacs 可以识别文件中的多种行尾约定并在它们之间进行转换。

End of line is a character or a sequence of characters that indicate the end of a text line. On GNU and Unix systems, this is a newline (q.v.), but other systems have other conventions. See end-of-line. Emacs can recognize several end-of-line conventions in files and convert between them.

环境变量
Environment Variable

环境变量是操作系统存储的变量集合之一,每个变量都有一个名称和一个值。 Emacs 可以访问其父 shell 设置的环境变量,并且可以在传递给它调用的程序的环境中设置变量。请参阅环境变量

An environment variable is one of a collection of variables stored by the operating system, each one having a name and a value. Emacs can access environment variables set by its parent shell, and it can set variables in the environment it passes to programs it invokes. See Environment Variables.

停产
EOL

请参阅术语表---行尾

See Glossary---End Of Line.

错误
Error

当 Emacs 命令在当前情况下无法执行时,就会发生错误。当发生错误时,命令的执行将停止(除非该命令已被编程为以其他方式执行),并且 Emacs 通过显示错误消息 (qv) 来报告错误。

An error occurs when an Emacs command cannot execute in the current circumstances. When an error occurs, execution of the command stops (unless the command has been programmed to do otherwise) and Emacs reports the error by displaying an error message (q.v.).

错误信息
Error Message

当您要求 Emacs 执行某些不可能的操作(例如,当点位于缓冲区末尾时向前终止文本)或命令以某种方式出现故障时,Emacs 会输出一条错误消息。此类消息出现在回波区域,并伴有蜂鸣声。

An error message is output displayed by Emacs when you ask it to do something impossible (such as, killing text forward when point is at the end of the buffer), or when a command malfunctions in some way. Such messages appear in the echo area, accompanied by a beep.

ESC
ESC

ESC是用作在缺少按键的键盘上键入元字符的前缀的字符Meta。与Meta键(与 键一样,SHIFT在键入另一个字符时按住该键)不同,按该ESC键就像按字母键一样,并且它适用于您键入的下一个字符。

ESC is a character used as a prefix for typing Meta characters on keyboards lacking a Meta key. Unlike the Meta key (which, like the SHIFT key, is held down while another character is typed), you press the ESC key as you would press a letter key, and it applies to the next character you type.

ETC。
etc.

拉丁语“et cetera”的缩写,意思是“等等”。

Short for “et cetera” in Latin, which means “and so on”.

表达
Expression

参见术语表---平衡表达

See Glossary---Balanced Expression.

删除
Expunging

清除 Rmail、Gnus 新闻组或 Dired 缓冲区是真正丢弃您之前标记为删除的消息或文件的操作。

Expunging an Rmail, Gnus newsgroup, or Dired buffer is an operation that truly discards the messages or files you have previously flagged for deletion.

Face

脸型是一种表现人物的风格。它指定诸如字体系列和大小、前景色和背景色、下划线和删除线、背景点画等属性。Emacs 提供将特定面与缓冲区文本部分相关联的功能,以便按照面指定的方式显示该文本属性。请参阅文本面孔

A face is a style of displaying characters. It specifies attributes such as font family and size, foreground and background colors, underline and strike-through, background stipple, etc. Emacs provides features to associate specific faces with portions of buffer text, in order to display that text as specified by the face attributes. See Text Faces.

文件局部变量
File Local Variable

文件局部变量是给定文件中指定的局部变量 (qv)。请参阅文件中的局部变量术语表---目录局部变量

A file local variable is a local variable (q.v.) specified in a given file. See Local Variables in Files, and Glossary---Directory Local Variable.

文件锁定
File Locking

Emacs 使用文件锁定来通知两个不同的用户何时开始同时编辑一个文件。请参阅防止同时编辑

Emacs uses file locking to notice when two different users start to edit one file at the same time. See Protection against Simultaneous Editing.

文件名
File Name

文件名是指一个文件的名称。文件名可以是相对的或绝对的;相对文件名的含义取决于当前目录,但绝对文件名无论当前目录是哪个目录都指同一个文件。在 GNU 和 Unix 系统上,绝对文件名以斜线(根目录)或 ' 开头〜/' 或者 '用户/'(主目录)。在 MS-Windows/MS-DOS 上,绝对文件名也可以以驱动器号和冒号开头,例如 'd'。

有些人使用术语“路径名”作为文件名,但我们不这样做;我们仅在术语“搜索路径”(qv) 中使用“路径”一词。

A file name is a name that refers to a file. File names may be relative or absolute; the meaning of a relative file name depends on the current directory, but an absolute file name refers to the same file regardless of which directory is current. On GNU and Unix systems, an absolute file name starts with a slash (the root directory) or with ‘~/’ or ‘~user/’ (a home directory). On MS-Windows/MS-DOS, an absolute file name can also start with a drive letter and a colon, e.g., ‘d:’.

Some people use the term “pathname” for file names, but we do not; we use the word “path” only in the term “search path” (q.v.).

文件名组件
File-Name Component

文件名组件直接在特定目录中命名文件。在 GNU 和 Unix 系统上,文件名是由斜杠分隔的文件名组成部分的序列。例如,富/酒吧 是包含两个组成部分的文件名,'' 和 '酒吧';它指的是名为 '酒吧' 在名为 ' 的目录中' 在当前目录中。 MS-DOS/MS-Windows 文件名也可以使用反斜杠来分隔组件,如富\酒吧

A file-name component names a file directly within a particular directory. On GNU and Unix systems, a file name is a sequence of file-name components, separated by slashes. For example, foo/bar is a file name containing two components, ‘foo’ and ‘bar’; it refers to the file named ‘bar’ in the directory named ‘foo’ in the current directory. MS-DOS/MS-Windows file names can also use backslashes to separate components, as in foo\bar.

填充前缀
Fill Prefix

填充前缀是一个字符串,填充完成后应该出现在每行的开头。它不被视为要填写的文本的一部分。请参阅填充文本

The fill prefix is a string that should be expected at the beginning of each line when filling is done. It is not regarded as part of the text to be filled. See Filling Text.

填充
Filling

填充文本意味着调整换行符的位置以在连续行之间移动文本,以便所有行的长度大致相同。请参阅填充文本。其他一些编辑将此功能称为“换行”。

Filling text means adjusting the position of line-breaks to shift text between consecutive lines, so that all the lines are approximately the same length. See Filling Text. Some other editors call this feature “line wrapping”.

字体锁定
Font Lock

字体锁定是一种根据语法以不同面突出显示缓冲区文本部分的模式。其他一些编辑将此称为“语法突出显示”。例如,所有评论 (qv) 可能会被涂成红色。请参阅字体锁定模式

Font Lock is a mode that highlights parts of buffer text in different faces, according to the syntax. Some other editors refer to this as “syntax highlighting”. For example, all comments (q.v.) might be colored red. See Font Lock mode.

字体集
Fontset

字体集是命名的字体集合。字体集规范列出了字符集以及用于显示每个字符集的字体。通过指定字体集的名称,字体集可以轻松地一次更改多种字体,而不是单独更改每种字体。请参阅字体集

A fontset is a named collection of fonts. A fontset specification lists character sets and which font to use to display each of them. Fontsets make it easy to change several fonts at once by specifying the name of a fontset, rather than changing each font separately. See Fontsets.

换页字符
Formfeed Character

参见术语表---页码

See Glossary---Page.

框架
Frame

框架是 Emacs 窗口的矩形簇。 Emacs 一开始只有一个框架,但您可以创建更多框架。您可以将每个框架细分为 Emacs 窗口 (qv)。当您使用窗口系统 (qv) 时,可以同时看到多个框架。请参阅框架和图形显示。其他一些编辑器使用术语“窗口”来表示此目的,但在 Emacs 中,窗口意味着其他含义。

A frame is a rectangular cluster of Emacs windows. Emacs starts out with one frame, but you can create more. You can subdivide each frame into Emacs windows (q.v.). When you are using a window system (q.v.), more than one frame can be visible at the same time. See Frames and Graphical Displays. Some other editors use the term “window” for this, but in Emacs a window means something else.

自由软件
Free Software

自由软件是让您可以自由共享、研究和修改的软件。 Emacs 是免费软件,是 GNU 项目 (qv) 的一部分,并根据称为 GNU 通用公共许可证的 Copyleft (qv) 许可证分发。请参阅GNU 通用公共许可证

Free software is software that gives you the freedom to share, study and modify it. Emacs is free software, part of the GNU project (q.v.), and distributed under a copyleft (q.v.) license called the GNU General Public License. See GNU GENERAL PUBLIC LICENSE.

自由软件基金会
Free Software Foundation

自由软件基金会(FSF)是一个致力于促进自由软件(qv)发展的慈善基金会。欲了解更多信息,请访问FSF 网站

The Free Software Foundation (FSF) is a charitable foundation dedicated to promoting the development of free software (q.v.). For more information, see the FSF website.

边缘
Fringe

在图形显示 (qv) 上,文本区域和窗口边框之间有一个较窄的框架部分 (qv)。这些“边缘”用于显示提供有关缓冲区文本信息的符号(请参阅窗口边缘)。 Emacs 使用称为 的特殊面 (qv) 显示边缘fringe。见流苏

On a graphical display (q.v.), there’s a narrow portion of the frame (q.v.) between the text area and the window’s border. These “fringes” are used to display symbols that provide information about the buffer text (see Window Fringes). Emacs displays the fringe using a special face (q.v.) called fringe. See fringe.

FSF
FSF

请参阅术语表---自由软件基金会

See Glossary---Free Software Foundation.

文件传输协议
FTP

FTP 是文件传输协议的缩写。这是检索远程文件 (qv) 的一种标准方法。

FTP is an acronym for File Transfer Protocol. This is one standard method for retrieving remote files (q.v.).

功能键
Function Key

功能键是键盘上发送输入但不对应任何字符的键。请参阅重新绑定功能键

A function key is a key on the keyboard that sends input but does not correspond to any character. See Rebinding Function Keys.

全球的
Global

全球意味着“独立于当前环境;在整个 Emacs 中有效”。它与本地 (qv) 相反。下面是使用“全局”的具体示例。

Global means “independent of the current environment; in effect throughout Emacs”. It is the opposite of local (q.v.). Particular examples of the use of “global” appear below.

全球缩写
Global Abbrev

缩写 (qv) 的全局定义在没有相同缩写的本地 (qv) 定义的所有主要模式中均有效。参见缩写

A global definition of an abbrev (q.v.) is effective in all major modes that do not have local (q.v.) definitions for the same abbrev. See Abbrevs.

全局键盘映射
Global Keymap

全局键映射 (qv) 包含在任何地方都有效的键绑定,除非被主要模式的本地键映射 (qv) 中的本地键绑定覆盖。请参阅键盘映射

The global keymap (q.v.) contains key bindings that are in effect everywhere, except when overridden by local key bindings in a major mode’s local keymap (q.v.). See Keymaps.

全球标志戒指
Global Mark Ring

全局标记环记录您最近在其中设置标记(qv)的一系列缓冲区。在许多情况下,您可以使用它来回溯您一直在编辑的缓冲区,或者在其中找到标签的缓冲区(请参阅术语表---标签)桌子)。请参阅全球标记环

The global mark ring records the series of buffers you have recently set a mark (q.v.) in. In many cases you can use this to backtrack through buffers you have been editing, or in which you have found tags (see Glossary---Tags Table). See The Global Mark Ring.

全球替代
Global Substitution

全局替换是指在大量文本中将每个出现的一个字符串替换为另一个字符串。请参阅替换命令

Global substitution means replacing each occurrence of one string by another string throughout a large amount of text. See Replacement Commands.

全局变量
Global Variable

变量 (qv) 的全局值在没有该变量自己的局部 (qv) 值的所有缓冲区中生效。请参阅变量

The global value of a variable (q.v.) takes effect in all buffers that do not have their own local (q.v.) values for the variable. See Variables.

GNU
GNU

GNU 是 GNU's Not Unix 的递归缩写,指的是与 Unix 兼容的操作系统,是自由软件(qv)。请参阅GNU 宣言。 GNU 通常与 Linux 一起使用作为内核,因为 Linux 比 GNU 内核工作得更好。有关详细信息,请参阅 GNU 网站

GNU is a recursive acronym for GNU’s Not Unix, and it refers to a Unix-compatible operating system which is free software (q.v.). See The GNU Manifesto. GNU is normally used with Linux as the kernel since Linux works better than the GNU kernel. For more information, see the GNU website.

图形字符
Graphic Character

图形字符是那些指定的图形图像而不仅仅是名称。除控制 (qv) 字符外的所有非元 (qv) 字符都是图形字符。其中包括字母、数字、标点符号和空格;它们不包括 RETESC。在 Emacs 中,键入图形字符会插入该字符(在普通编辑模式下)。请参阅插入文本

Graphic characters are those assigned pictorial images rather than just names. All the non-Meta (q.v.) characters except for the Control (q.v.) characters are graphic characters. These include letters, digits, punctuation, and spaces; they do not include RET or ESC. In Emacs, typing a graphic character inserts that character (in ordinary editing modes). See Inserting Text.

图形显示
Graphical Display

图形显示器是一种可以显示图像和多种字体的显示器。通常它还有一个窗口系统(qv)。

A graphical display is one that can display images and multiple fonts. Usually it also has a window system (q.v.).

突出显示
Highlighting

突出显示文本意味着使用不同的前景色和/或背景颜色显示它,以使其从缓冲区中的其余文本中脱颖而出。

Emacs 以多种方式使用突出显示。只要区域处于活动状态,它就会突出显示该区域(请参阅标记和区域)。增量搜索还突出显示匹配项(请参阅增量搜索)。请参见术语表---字体锁定

Highlighting text means displaying it with a different foreground and/or background color to make it stand out from the rest of the text in the buffer.

Emacs uses highlighting in several ways. It highlights the region whenever it is active (see The Mark and the Region). Incremental search also highlights matches (see Incremental Search). See Glossary---Font Lock.

硬拷贝
Hardcopy

硬拷贝是指打印输出。 Emacs 有多种命令用于打印 Emacs 缓冲区的内容。请参阅打印硬拷贝

Hardcopy means printed output. Emacs has various commands for printing the contents of Emacs buffers. See Printing Hard Copies.

HELP
HELP

HELPC-h是or的 Emacs 名称F1。您可以 HELP随时键入以询问您有哪些选项,或询问命令的作用。请参阅帮助

HELP is the Emacs name for C-h or F1. You can type HELP at any time to ask what options you have, or to ask what a command does. See Help.

帮助回声
Help Echo

帮助回显是当鼠标指针位于需要解释的显示部分时,在回显区域 (qv) 中显示的一条短消息。 Emacs 显示菜单项、部分模式行、工具栏按钮等的帮助回显。在图形显示器上,消息可以显示为工具提示 (qv)。请参阅工具提示

Help echo is a short message displayed in the echo area (q.v.) when the mouse pointer is located on portions of display that require some explanations. Emacs displays help echo for menu items, parts of the mode line, tool-bar buttons, etc. On graphical displays, the messages can be displayed as tooltips (q.v.). See Tooltips.

主目录
Home Directory

您的主目录包含您的个人文件。在多用户 GNU 或 Unix 系统上,每个用户都有自己的主目录。当您启动新的登录会话时,您的主目录是默认的启动目录。主目录的标准简写是 ''。相似地, '用户' 代表其他用户的主目录。

Your home directory contains your personal files. On a multi-user GNU or Unix system, each user has his or her own home directory. When you start a new login session, your home directory is the default directory in which to start. A standard shorthand for your home directory is ‘~’. Similarly, ‘~user’ represents the home directory of some other user.

Hook

钩子是在特定场合调用的函数列表,例如在文件中保存缓冲区、主模式激活等。通过自定义各种钩子,您可以修改 Emacs 的行为,而无需更改其任何代码。请参阅钩子

A hook is a list of functions to be called on specific occasions, such as saving a buffer in a file, major mode activation, etc. By customizing the various hooks, you can modify Emacs’s behavior without changing any of its code. See Hooks.

Hyper

Hyper 是键盘输入字符可能具有的修饰符位的名称。要创建一个 Hyper 字符,请在按住该 Hyper键的同时键入它。这些字符的名称以 Hyper-(通常缩写H-为)开头。请参阅修饰键

Hyper is the name of a modifier bit that a keyboard input character may have. To make a character Hyper, type it while holding down the Hyper key. Such characters are given names that start with Hyper- (usually written H- for short). See Modifier Keys.

IE
i.e.

拉丁语“id est”的缩写,意思是“那就是”。

Short for “id est” in Latin, which means “that is”.

伊夫
Iff

“If”的意思是“当且仅当”。这个术语来自数学。尽量避免在文档中使用这个术语,因为许多人不熟悉它,并将其误认为是拼写错误。

“Iff” means “if and only if”. This terminology comes from mathematics. Try to avoid using this term in documentation, since many are unfamiliar with it and mistake it for a typo.

收件箱
Inbox

收件箱是操作系统在其中传送邮件的文件。 Rmail 将邮件从收件箱传输到 Rmail 文件,然后将邮件永久存储在其中或直到明确删除为止。请参阅Rmail 文件和收件箱

An inbox is a file in which mail is delivered by the operating system. Rmail transfers mail from inboxes to Rmail files in which the mail is then stored permanently or until explicitly deleted. See Rmail Files and Inboxes.

增量搜索
Incremental Search

Emacs 提供增量搜索功能,一旦您键入第一个字符,Emacs 就开始搜索字符串。当您输入更多字符时,它会优化搜索。请参阅增量搜索

Emacs provides an incremental search facility, whereby Emacs begins searching for a string as soon as you type the first character. As you type more characters, it refines the search. See Incremental Search.

缩进
Indentation

缩进是指行首的空格。大多数编程语言都有使用缩进来阐明程序结构的约定,并且 Emacs 有特殊命令来调整缩进。请参阅缩进

Indentation means blank space at the beginning of a line. Most programming languages have conventions for using indentation to illuminate the structure of the program, and Emacs has special commands to adjust indentation. See Indentation.

间接缓冲区
Indirect Buffer

间接缓冲区是共享另一个缓冲区文本的缓冲区,称为其基本缓冲区 (qv)。请参阅间接缓冲区

An indirect buffer is a buffer that shares the text of another buffer, called its base buffer (q.v.). See Indirect Buffers.

信息
Info

Info 是 GNU 项目用于编写文档的超文本格式。

Info is the hypertext format used by the GNU project for writing documentation.

输入事件
Input Event

在 Emacs 中,输入事件表示用户在终端上执行的一项操作。输入事件包括键入字符、键入功能键、按下或释放鼠标按钮以及在 Emacs 框架之间切换。请参阅用户输入的类型

An input event represents, within Emacs, one action taken by the user on the terminal. Input events include typing characters, typing function keys, pressing or releasing mouse buttons, and switching between Emacs frames. See Kinds of User Input.

输入法
Input Method

输入法是一种通过键入ASCII字符序列(qv) 来输入非ASCII文本字符的系统。请参阅输入法

An input method is a system for entering non-ASCII text characters by typing sequences of ASCII characters (q.v.). See Input Methods.

插入
Insertion

插入意味着从键盘或 Emacs 中的其他位置将文本添加到缓冲区中。

Insertion means adding text into the buffer, either from the keyboard or from some other place in Emacs.

互动功能
Interactive Function

命令(qv) 的不同术语。

A different term for command (q.v.).

交互式调用
Interactive Invocation

函数可以从 Lisp 代码中调用,也可以作为用户级命令调用(通过M-x、键绑定或菜单)。在后一种情况下,该函数被称为交互式调用

A function can be called from Lisp code, or called as a user level command (via M-x, a key binding or a menu). In the latter case, the function is said to be called interactively.

联锁
Interlocking

请参阅术语表---文件锁定

See Glossary---File Locking.

我搜索
Isearch

请参见术语表---增量搜索

See Glossary---Incremental Search.

理由
Justification

对齐是指在文本行中添加额外的空格,以调整文本边缘的位置。请参阅显式填充命令

Justification means adding extra spaces within lines of text in order to adjust the position of the text edges. See Explicit Fill Commands.

按键绑定
Key Binding

请参见术语表---绑定

See Glossary---Binding.

键盘宏
Keyboard Macro

键盘宏是一种从现有命令序列定义新 Emacs 命令的方法,无需编写 Lisp 程序。您可以使用宏来记录一系列命令,然后根据需要多次回放它们。请参阅键盘宏

Keyboard macros are a way of defining new Emacs commands from sequences of existing ones, with no need to write a Lisp program. You can use a macro to record a sequence of commands, then play them back as many times as you like. See Keyboard Macros.

键盘快捷键
Keyboard Shortcut

键盘快捷键是调用命令的键序列 (qv)。有些程序称之为“分配键盘快捷键”,Emacs 称之为“绑定按键序列”。请参见术语表---绑定

A keyboard shortcut is a key sequence (q.v.) that invokes a command. What some programs call “assigning a keyboard shortcut”, Emacs calls “binding a key sequence”. See Glossary---Binding.

按键顺序
Key Sequence

键序列(简称 key)是作为单个单元有意义的输入事件 (qv) 序列。如果按键序列足以指定一个动作,则为完整按键(qv);如果还不够,那就是前缀键(qv)。请参阅

A key sequence (key, for short) is a sequence of input events (q.v.) that are meaningful as a single unit. If the key sequence is enough to specify one action, it is a complete key (q.v.); if it is not enough, it is a prefix key (q.v.). See Keys.

键位图
Keymap

键映射是记录键序列与其运行的命令的绑定 (qv) 的数据结构。例如,全局键盘映射将字符绑定C-n到命令功能 next-line。请参阅键盘映射

The keymap is the data structure that records the bindings (q.v.) of key sequences to the commands that they run. For example, the global keymap binds the character C-n to the command function next-line. See Keymaps.

键盘翻译表
Keyboard Translation Table

键盘转换表是一个数组,它将来自终端的字符代码转换为组成按键序列的字符代码。

The keyboard translation table is an array that translates the character codes that come from the terminal into the character codes that make up key sequences.

杀环
Kill Ring

杀戮环是保存您最近杀掉的所有文本(参见术语表---杀戮)的地方。您可以重新插入仍在环中的任何被删除的文本;这称为猛拉 (qv)。参见扬京

The kill ring is where all text you have killed (see Glossary---Killing) recently is saved. You can reinsert any of the killed text still in the ring; this is called yanking (q.v.). See Yanking.

杀戮
Killing

删除意味着删除文本并将其保存在删除环上,以便稍后可以将其拉出(qv)。其他一些系统将此称为“切割”。大多数擦除文本的 Emacs 命令执行的是终止操作,而不是删除 (qv)。请参阅删除和移动文本

Killing means erasing text and saving it on the kill ring so it can be yanked (q.v.) later. Some other systems call this “cutting”. Most Emacs commands that erase text perform killing, as opposed to deletion (q.v.). See Killing and Moving Text.

扼杀一份工作
Killing a Job

杀死一个作业(例如 Emacs 的调用)意味着让它不再存在。如果未保存在文件中,其中的任何数据都会丢失。请参阅退出 Emacs

Killing a job (such as, an invocation of Emacs) means making it cease to exist. Any data within it, if not saved in a file, is lost. See Exiting Emacs.

语言环境
Language Environment

您选择的语言环境指定输入法 (qv) 和编码系统 (qv) 的默认值。请参阅语言环境。如果您编辑非ASCII文本,这些默认值是相关的(请参阅国际字符集支持)。

Your choice of language environment specifies defaults for the input method (q.v.) and coding system (q.v.). See Language Environments. These defaults are relevant if you edit non-ASCII text (see International Character Set Support).

换行
Line Wrapping

参见术语表---填充

See Glossary---Filling.

口齿不清
Lisp

Lisp 是一种编程语言。大多数 Emacs 都是用 Lisp 的一种方言编写的,称为 Emacs Lisp,它扩展了一些特殊功能,使其特别适合文本编辑任务。

Lisp is a programming language. Most of Emacs is written in a dialect of Lisp, called Emacs Lisp, which is extended with special features that make it especially suitable for text editing tasks.

列表
List

列表大约是一个以左括号开头并以匹配的右括号结尾的文本字符串。在 C 模式和其他非 Lisp 模式中,由适合该语言的其他类型的匹配分隔符(例如大括号)包围的分组也被视为列表。 Emacs 有用于列表上许多操作的特殊命令。请参阅在括号结构中移动

A list is, approximately, a text string beginning with an open parenthesis and ending with the matching close parenthesis. In C mode and other non-Lisp modes, groupings surrounded by other kinds of matched delimiters appropriate to the language, such as braces, are also considered lists. Emacs has special commands for many operations on lists. See Moving in the Parenthesis Structure.

当地的
Local

本地意味着“仅在特定上下文中有效”;相关类型的上下文是特定的函数执行、特定的缓冲区或特定的主要模式。它与“全局”(qv) 相反。 Emacs 术语中“本地”的具体用法如下所示。

Local means “in effect only in a particular context”; the relevant kind of context is a particular function execution, a particular buffer, or a particular major mode. It is the opposite of “global” (q.v.). Specific uses of “local” in Emacs terminology appear below.

本地缩写
Local Abbrev

仅当选择特定的主模式时,本地缩写定义才有效。在该主要模式中,它会覆盖同一缩写的任何全局定义。参见缩写

A local abbrev definition is effective only if a particular major mode is selected. In that major mode, it overrides any global definition for the same abbrev. See Abbrevs.

本地键盘映射
Local Keymap

本地键盘映射用于特定的主要模式;当前本地键映射中的键绑定 (qv) 会覆盖相同键序列的全局绑定。请参阅键盘映射

A local keymap is used in a particular major mode; the key bindings (q.v.) in the current local keymap override global bindings of the same key sequences. See Keymaps.

局部变数
Local Variable

变量 (qv) 的局部值仅适用于一个缓冲区。请参阅局部变量

A local value of a variable (q.v.) applies to only one buffer. See Local Variables.

M-
M-

M-字符名称中的 是 的缩写Meta,是可以伴随任何字符的修饰键之一。参见M-

M- in the name of a character is an abbreviation for Meta, one of the modifier keys that can accompany any character. See M-.

M-C-
M-C-

M-C-角色名称中的 是 Control-Meta 的缩写;与C-M-(qv) 的意思相同。

M-C- in the name of a character is an abbreviation for Control-Meta; it means the same thing as C-M- (q.v.).

M-x
M-x

M-x是用于按名称调用 Emacs 命令的按键序列。这是运行未绑定到按键序列的命令的方式。请参阅按名称运行命令

M-x is the key sequence that is used to call an Emacs command by name. This is how you run commands that are not bound to key sequences. See Running Commands by Name.

邮件
Mail

邮件是指通过计算机系统从一个用户发送给另一个用户的消息,以便收件人方便时阅读。 Emacs 具有用于撰写和发送邮件以及用于阅读和编辑您收到的邮件的命令。请参阅发送邮件。请参阅使用 Rmail 阅读邮件,了解使用 Emacs 阅读邮件的一种方法。

Mail means messages sent from one user to another through the computer system, to be read at the recipient’s convenience. Emacs has commands for composing and sending mail, and for reading and editing the mail you have received. See Sending Mail. See Reading Mail with Rmail, for one way to read mail with Emacs.

邮件撰写方法
Mail Composition Method

邮件撰写方法是可在 Emacs 内运行的用于编辑和发送邮件消息的程序。 Emacs 允许您从多种替代邮件撰写方法中进行选择。请参阅邮件撰写方法

A mail composition method is a program runnable within Emacs for editing and sending a mail message. Emacs lets you select from several alternative mail composition methods. See Mail-Composition Methods.

主要模式
Major Mode

Emacs 主要模式是一组互斥的选项,每个选项都将 Emacs 配置为编辑某种类型的文本。理想情况下,每种编程语言都有自己的主要模式。请参阅主要模式

The Emacs major modes are a mutually exclusive set of options, each of which configures Emacs for editing a certain sort of text. Ideally, each programming language has its own major mode. See Major Modes.

利润
Margin

窗户的可用部分(包括边缘)和窗户边缘之间的空间。

The space between the usable part of a window (including the fringe) and the window edge.

标记
Mark

该标记指向文本中的某个位置。它指定区域 (qv) 的一端,点为另一端。许多命令对从点到标记的所有文本进行操作。每个缓冲区都有自己的标记。请参阅“标记”和“区域”

The mark points to a position in the text. It specifies one end of the region (q.v.), point being the other end. Many commands operate on all the text from point to the mark. Each buffer has its own mark. See The Mark and the Region.

马克环
Mark Ring

标记环用于保存标记的几个最近位置,以防您想移回它们。每个缓冲区都有自己的标记环;此外,还有一个全局标记环(qv)。请参阅“标记环”

The mark ring is used to hold several recent previous locations of the mark, in case you want to move back to them. Each buffer has its own mark ring; in addition, there is a single global mark ring (q.v.). See The Mark Ring.

菜单栏
Menu Bar

菜单栏是 Emacs 框架顶部的一行。它包含您可以用鼠标单击以显示菜单的单词,也可以使用键盘界面进行导航。请参阅菜单栏

The menu bar is a line at the top of an Emacs frame. It contains words you can click on with the mouse to bring up menus, or you can use a keyboard interface to navigate it. See Menu Bars.

信息
Message

参见术语表---邮件

See Glossary---Mail.

Meta

Meta 是可以在命令字符中使用的修饰符位的名称。要输入元字符,请Meta 在键入字符时按住该键。我们用以Meta-(通常简称)开头的名称来指代此类字符M-。例如,M-<通过按住Meta 并同时键入来键入(在大多数终端上,通过按住并键入来<完成)。参见SHIFT,

在某些终端上,该Meta键实际上标记为AltEdit

Meta is the name of a modifier bit which you can use in a command character. To enter a meta character, you hold down the Meta key while typing the character. We refer to such characters with names that start with Meta- (usually written M- for short). For example, M-< is typed by holding down Meta and at the same time typing < (which itself is done, on most terminals, by holding down SHIFT and typing ,). See Meta.

On some terminals, the Meta key is actually labeled Alt or Edit.

元字符
Meta Character

元字符是其字符代码包含元位的字符。

A Meta character is one whose character code includes the Meta bit.

迷你缓冲区
Minibuffer

迷你缓冲区是必要时在回显区域 (qv) 内出现的窗口,用于读取命令的参数。请参阅迷你缓冲区

The minibuffer is the window that appears when necessary inside the echo area (q.v.), used for reading arguments to commands. See The Minibuffer.

迷你缓冲区历史
Minibuffer History

迷你缓冲区历史记录记录您过去为迷你缓冲区参数指定的文本,因此您可以方便地再次使用相同的文本。请参阅迷你缓冲区历史记录

The minibuffer history records the text you have specified in the past for minibuffer arguments, so you can conveniently use the same text again. See Minibuffer History.

次要模式
Minor Mode

次要模式是 Emacs 的一项可选功能,可以独立于所有其他功能打开或关闭。每个次要模式都有一个打开或关闭它的命令。一些次要模式是全局的(qv),一些是局部的(qv)。请参阅次要模式

A minor mode is an optional feature of Emacs, which can be switched on or off independently of all other features. Each minor mode has a command to turn it on or off. Some minor modes are global (q.v.), and some are local (q.v.). See Minor Modes.

小调模式键盘映射
Minor Mode Keymap

次要模式键映射是属于次要模式的键映射,并且在启用该模式时处于活动状态。次要模式键映射优先于缓冲区的本地键映射,就像本地键映射优先于全局键映射一样。请参阅键盘映射

A minor mode keymap is a keymap that belongs to a minor mode and is active when that mode is enabled. Minor mode keymaps take precedence over the buffer’s local keymap, just as the local keymap takes precedence over the global keymap. See Keymaps.

模式线
Mode Line

模式行是每个窗口 (qv) 底部的行,提供该窗口中显示的缓冲区的状态信息。请参阅模式行

The mode line is the line at the bottom of each window (q.v.), giving status information on the buffer displayed in that window. See The Mode Line.

改良缓冲液
Modified Buffer

如果自上次保存缓冲区(或自创建以来,如果从未保存过)缓冲区文本发生更改,则缓冲区 (qv) 被修改。请参阅保存文件

A buffer (q.v.) is modified if its text has been changed since the last time the buffer was saved (or since it was created, if it has never been saved). See Saving Files.

移动文本
Moving Text

移动文本意味着将其从一处删除并将其插入到另一处。移动文本的常用方法是杀死 (qv) 它然后拉动 (qv) 它。请参阅删除和移动文本

Moving text means erasing it from one place and inserting it in another. The usual way to move text is by killing (q.v.) it and then yanking (q.v.) it. See Killing and Moving Text.

骡子
MULE

在 Emacs 23 之前,MULE是一个软件包的名称,该软件包通过添加对多字符集 (qv) 的支持来为 Emacs 提供多语言增强功能。 MULE后来被集成到 Emacs 中,当 Emacs 在版本 23 中获得内部 Unicode 支持时,其中大部分被替换。

Emacs 中处理字符集支持的某些部分仍然使用 MULE名称。请参阅国际字符集支持

Prior to Emacs 23, MULE was the name of a software package which provided a MULtilingual Enhancement to Emacs, by adding support for multiple character sets (q.v.). MULE was later integrated into Emacs, and much of it was replaced when Emacs gained internal Unicode support in version 23.

Some parts of Emacs that deal with character set support still use the MULE name. See International Character Set Support.

多字节字符
Multibyte Character

多字节字符是在缓冲区中占用多个字节的字符。 Emacs 使用多字节字符来表示非ASCII文本,因为非ASCII字符的数量远远超过 256 个。请参阅国际字符

A multibyte character is a character that takes up several bytes in a buffer. Emacs uses multibyte characters to represent non-ASCII text, since the number of non-ASCII characters is much more than 256. See International Characters.

名为马克
Named Mark

命名标记是一个寄存器 (qv),其作用是记录文本中的位置,以便您可以将点移动到该位置。请参阅寄存器

A named mark is a register (q.v.), in its role of recording a location in text so that you can move point to that location. See Registers.

缩小范围
Narrowing

缩小意味着创建一个限制 (qv),将当前缓冲区中的编辑限制为仅文本的一部分。在边界再次加宽之前,该部分之外的文本无法编辑(或查看),但它仍然存在,并且保存文件会保存所有内容。请参阅缩小范围

Narrowing means creating a restriction (q.v.) that limits editing in the current buffer to only a part of the text. Text outside that part is inaccessible for editing (or viewing) until the boundaries are widened again, but it is still there, and saving the file saves it all. See Narrowing.

新队
Newline

缓冲区中的 Control-J 字符终止文本行,因此也称为换行符。请参阅术语表---行尾

Control-J characters in the buffer terminate lines of text and are therefore also called newlines. See Glossary---End Of Line.

nil
nil

nil是一个通常被解释为逻辑“假”的值。它的反义词是t,解释为“true”。

nil is a value usually interpreted as a logical “false”. Its opposite is t, interpreted as “true”.

数字参数
Numeric Argument

数字参数是在命令之前指定的数字,用于更改命令的效果。通常数字参数用作重复计数。请参阅数字参数

A numeric argument is a number, specified before a command, to change the effect of the command. Often the numeric argument serves as a repeat count. See Numeric Arguments.

覆盖模式
Overwrite Mode

覆盖模式是次要模式。启用后,普通文本字符会替换点后的现有文本,而不是将其推到一侧。请参阅次要模式

Overwrite mode is a minor mode. When it is enabled, ordinary text characters replace the existing text after point rather than pushing it to one side. See Minor Modes.

包裹
Package

包是您从 Emacs 中下载并自动安装的 Lisp 代码的集合。包提供了一种添加新功能的便捷方法。请参阅Emacs Lisp 包

A package is a collection of Lisp code that you download and automatically install from within Emacs. Packages provide a convenient way to add new features. See Emacs Lisp Packages.

Page

页是一个文本单位,由 行首的换页符( ASCII控制-L,代码 014)分隔。提供了一些 Emacs 命令用于在页面上移动和操作。请参阅页数

A page is a unit of text, delimited by formfeed characters (ASCII control-L, code 014) at the beginning of a line. Some Emacs commands are provided for moving over and operating on pages. See Pages.

段落
Paragraph

段落是人类语言文本的中等大小单位。有特殊的 Emacs 命令用于移动和操作段落。参见段落

Paragraphs are the medium-size unit of human-language text. There are special Emacs commands for moving over and operating on paragraphs. See Paragraphs.

解析
Parsing

我们说某些 Emacs 命令解析正在编辑的文本中的单词或表达式。事实上,他们所知道的就是找到单词或表达方式的另一端。

We say that certain Emacs commands parse words or expressions in the text being edited. Really, all they know how to do is find the other end of a word or expression.

观点
Point

Point 是缓冲区中发生插入和删除的位置。点被认为位于两个字符之间,而不是一个字符处。终端的光标 (qv) 指示点的位置。参见

Point is the place in the buffer at which insertion and deletion occur. Point is considered to be between two characters, not at one character. The terminal’s cursor (q.v.) indicates the location of point. See Point.

前缀参数
Prefix Argument

请参阅术语表---数字参数

See Glossary---Numeric Argument.

前缀键
Prefix Key

前缀键是一个键序列 (qv),其唯一功能是引入一组较长的键序列。 C-x是前缀键的示例;因此,任何以 开头的两个字符序列C-x都是合法的密钥序列。请参阅

A prefix key is a key sequence (q.v.) whose sole function is to introduce a set of longer key sequences. C-x is an example of prefix key; any two-character sequence starting with C-x is therefore a legitimate key sequence. See Keys.

初选
Primary Selection

主要选择是一个特定的 X 选择 (qv);大多数 X 应用程序都选择它来与其他应用程序传输文本。

标记或选择文本的 Emacs 命令设置主要选择,单击鼠标会在适当的时候插入主要选择中的文本。请参阅班次选择

The primary selection is one particular X selection (q.v.); it is the selection that most X applications use for transferring text to and from other applications.

The Emacs commands that mark or select text set the primary selection, and clicking the mouse inserts text from the primary selection when appropriate. See Shift Selection.

迅速的
Prompt

提示是用于要求您输入的文本。显示提示称为提示。 Emacs 提示始终出现在回显区域 (qv)。当使用迷你缓冲区读取参数时,会发生一种提示(请参阅迷你缓冲区);当您在键入多字符按键序列的过程中暂停时发生的回声也是一种提示(请参阅回声区域)。

A prompt is text used to ask you for input. Displaying a prompt is called prompting. Emacs prompts always appear in the echo area (q.v.). One kind of prompting happens when the minibuffer is used to read an argument (see The Minibuffer); the echoing that happens when you pause in the middle of typing a multi-character key sequence is also a kind of prompting (see The Echo Area).

qv
q.v.

拉丁语“quod vide”的缩写,意思是“看到”。

Short for “quod vide” in Latin, which means “which see”.

查询-替换
Query-Replace

查询替换是 Emacs 提供的交互式字符串替换功能。请参阅查询替换

Query-replace is an interactive string replacement feature provided by Emacs. See Query Replace.

戒烟
Quitting

C-g退出意味着使用(或在 MS-DOS 上)取消部分键入的命令或正在运行的命令。请参阅退出和中止C-Break

Quitting means canceling a partially typed command or a running command, using C-g (or C-Break on MS-DOS). See Quitting and Aborting.

引用
Quoting

引用意味着剥夺一个角色通常的特殊意义。 Emacs 中最常见的引用类型是 with C-q。什么构成特殊意义取决于上下文和惯例。例如,一个普通字符作为 Emacs 命令插入自身;因此,在这种情况下,特殊字符是通常不会插入自身的任何字符(例如DEL),引用它会使其插入自身,就好像它不是特殊的一样。并非所有上下文都允许引用。请参阅引用

Quoting means depriving a character of its usual special significance. The most common kind of quoting in Emacs is with C-q. What constitutes special significance depends on the context and on convention. For example, an ordinary character as an Emacs command inserts itself; so in this context, a special character is any character that does not normally insert itself (such as DEL, for example), and quoting it makes it insert itself as if it were not special. Not all contexts allow quoting. See Quoting.

引用文件名
Quoting File Names

引用文件名会关闭诸如 ' 之类的结构的特殊意义$','' 和 ':'。请参阅引用的文件名

Quoting a file name turns off the special significance of constructs such as ‘$’, ‘~’ and ‘:’. See Quoted File Names.

只读缓冲区
Read-Only Buffer

只读缓冲区是不允许更改其文本的缓冲区。通常,当缓冲区包含对 Emacs 有特殊意义的文本时,Emacs 会将缓冲区设置为只读;例如,Dired 缓冲区。访问写保护的文件也会产生只读缓冲区。请参阅使用多个缓冲区

A read-only buffer is one whose text you are not allowed to change. Normally Emacs makes buffers read-only when they contain text which has a special significance to Emacs; for example, Dired buffers. Visiting a file that is write-protected also makes a read-only buffer. See Using Multiple Buffers.

长方形
Rectangle

矩形由给定范围的列和给定的行范围内的文本组成。通常,您可以通过在一个角放置点并将标记放置在对角的对角来指定矩形。请参阅矩形

A rectangle consists of the text in a given range of columns on a given range of lines. Normally you specify a rectangle by putting point at one corner and putting the mark at the diagonally opposite corner. See Rectangles.

递归编辑级别
Recursive Editing Level

递归编辑级别是命令执行的一部分涉及要求您编辑某些文本的状态。该文本可能与应用命令的文本相同,也可能不同。模式行 (qv) 用方括号 ('[' 和 ']')。请参阅递归编辑级别

A recursive editing level is a state in which part of the execution of a command involves asking you to edit some text. This text may or may not be the same as the text to which the command was applied. The mode line (q.v.) indicates recursive editing levels with square brackets (‘[’ and ‘]’). See Recursive Editing Levels.

重新显示
Redisplay

重新显示是校正屏幕上的图像以对应于正在编辑的文本中所做的更改的过程。请参阅重新显示

Redisplay is the process of correcting the image on the screen to correspond to changes that have been made in the text being edited. See Redisplay.

正则表达式
Regexp

请参阅术语表---正则表达式

See Glossary---Regular Expression.

地区
Region

该区域是点 (qv) 和标记 (qv) 之间的文本。许多命令对区域的文本进行操作。请参阅区域

The region is the text between point (q.v.) and the mark (q.v.). Many commands operate on the text of the region. See Region.

登记
Register

寄存器被命名为槽,可以在其中保存文本、缓冲区位置或矩形以供以后使用。请参阅寄存器。一个相关的 Emacs 功能是书签 (qv)。

Registers are named slots in which text, buffer positions, or rectangles can be saved for later use. See Registers. A related Emacs feature is bookmarks (q.v.).

正则表达式
Regular Expression

正则表达式是可以匹配各种文本字符串的模式;例如, '一个[0-9]+' 火柴 'A' 后跟一位或多位数字。请参阅正则表达式的语法

A regular expression is a pattern that can match various text strings; for example, ‘a[0-9]+’ matches ‘a’ followed by one or more digits. See Syntax of Regular Expressions.

远程文件
Remote File

远程文件是存储在您自己的系统以外的系统上的文件。 Emacs 可以访问其他计算机上的文件,前提是您的计算机可以通过网络访问这些文件,并且(显然)您有支持的方法来访问这些文件。请参阅远程文件

A remote file is a file that is stored on a system other than your own. Emacs can access files on other computers provided that they are reachable from your machine over the network, and (obviously) that you have a supported method to gain access to those files. See Remote Files.

重复计数
Repeat Count

请参阅术语表---数字参数

See Glossary---Numeric Argument.

替代品
Replacement

请参阅术语表---全局替换

See Glossary---Global Substitution.

限制
Restriction

缓冲区的限制是缓冲区开头或结尾处暂时无法访问的文本量。给予缓冲区非零的限制称为窄化 (qv);消除限制称为放宽 (qv)。请参阅缩小范围

A buffer’s restriction is the amount of text, at the beginning or the end of the buffer, that is temporarily inaccessible. Giving a buffer a nonzero amount of restriction is called narrowing (q.v.); removing a restriction is called widening (q.v.). See Narrowing.

RET
RET

RET是一个字符,在 Emacs 中运行命令以在文本中插入换行符。它还用于终止在迷你缓冲区 (qv) 中读取的大多数参数。请参阅返回

RET is a character that in Emacs runs the command to insert a newline into the text. It is also used to terminate most arguments read in the minibuffer (q.v.). See Return.

恢复
Reverting

恢复就是回到原来的状态。例如,Emacs 允许您通过从磁盘重新读取文件来恢复缓冲区。请参阅恢复缓冲区

Reverting means returning to the original state. For example, Emacs lets you revert a buffer by re-reading its file from disk. See Reverting a Buffer.

保存
Saving

保存缓冲区意味着将其文本复制到该缓冲区中访问过的文件 (qv) 中。这就是 Emacs 编辑实际更改文件中文本的方式。请参阅保存文件

Saving a buffer means copying its text into the file that was visited (q.v.) in that buffer. This is the way text in files actually gets changed by your Emacs editing. See Saving Files.

滚动条
Scroll Bar

滚动条是出现在窗口一侧的一个又高又薄的空心盒子。您可以使用滚动条中的鼠标命令来滚动窗口。滚动条功能仅在窗口系统下受支持。请参阅滚动条

A scroll bar is a tall thin hollow box that appears at the side of a window. You can use mouse commands in the scroll bar to scroll the window. The scroll bar feature is supported only under windowing systems. See Scroll Bars.

滚动
Scrolling

滚动意味着移动 Emacs 窗口中的文本,以便看到缓冲区的不同部分。请参阅滚动

Scrolling means shifting the text in the Emacs window so as to see a different part of the buffer. See Scrolling.

搜寻中
Searching

搜索意味着将点移动到指定字符串的下一个出现位置或指定正则表达式的下一个匹配项。请参阅搜索和替换

Searching means moving point to the next occurrence of a specified string or the next match for a specified regular expression. See Searching and Replacement.

搜索路径
Search Path

搜索路径是目录列表,用于出于特定目的搜索文件。例如,该变量load-path 保存用于查找 Lisp 库文件的搜索路径。请参阅Emacs 的 Lisp 代码库

A search path is a list of directories, to be used for searching for files for certain purposes. For example, the variable load-path holds a search path for finding Lisp library files. See Libraries of Lisp Code for Emacs.

二次选拔
Secondary Selection

次要选择是一个特定的 X 选择 (qv);某些 X 应用程序可以使用它与其他应用程序传输文本。 Emacs 有特殊的鼠标命令,用于使用辅助选择传输文本。请参阅二次选择

The secondary selection is one particular X selection (q.v.); some X applications can use it for transferring text to and from other applications. Emacs has special mouse commands for transferring text using the secondary selection. See Secondary Selection.

选定的帧
Selected Frame

所选帧是您当前输入操作的帧。请参阅框架和图形显示

The selected frame is the one your input currently operates on. See Frames and Graphical Displays.

选定的窗口
Selected Window

所选窗口是您当前输入操作的窗口。请参阅Emacs Windows 的概念

The selected window is the one your input currently operates on. See Concepts of Emacs Windows.

选择缓冲区
Selecting a Buffer

选择一个缓冲区意味着将其设为当前 (qv) 缓冲区。请参阅创建和选择缓冲区

Selecting a buffer means making it the current (q.v.) buffer. See Creating and Selecting Buffers.

选择
Selection

窗口系统允许应用程序指定其值为文本的选择。程序还可以读取其他程序已设置的选择。这是在窗口应用程序之间传输文本的主要方式。 Emacs 具有可处理主要 (qv) 选择和辅助 (qv) 选择以及剪贴板 (qv) 的命令。

Windowing systems allow an application program to specify selections whose values are text. A program can also read the selections that other programs have set up. This is the principal way of transferring text between window applications. Emacs has commands to work with the primary (q.v.) selection and the secondary (q.v.) selection, and also with the clipboard (q.v.).

自我记录
Self-Documentation

自文档是 Emacs 的功能,它可以告诉您任何命令的作用,或者为您提供与您指定的主题相关的所有命令的列表。您要求使用帮助字符 来提供自我文档 C-h。请参阅帮助

Self-documentation is the feature of Emacs that can tell you what any command does, or give you a list of all commands related to a topic you specify. You ask for self-documentation with the help character, C-h. See Help.

自插入字符
Self-Inserting Character

如果键入某个字符会将该字符插入到缓冲区中,则该字符是自插入的。除了某些特殊的主要模式外,普通的打印字符和空白字符在 Emacs 中都是自动插入的。

A character is self-inserting if typing that character inserts that character in the buffer. Ordinary printing and whitespace characters are self-inserting in Emacs, except in certain special major modes.

句子
Sentences

Emacs 具有按句子移动或按句子删除的命令。参见句子

Emacs has commands for moving by or killing by sentences. See Sentences.

服务器
Server

在 Emacs 中,您可以启动一个“服务器”进程,该进程侦听来自“客户端”的连接。这提供了比启动多个 Emacs 实例更快的替代方案。请参阅使用 Emacs 作为服务器术语表---守护程序

Within Emacs, you can start a “server” process, which listens for connections from “clients”. This offers a faster alternative to starting several Emacs instances. See Using Emacs as a Server, and Glossary---Daemon.

性别
Sexp

sexp(“s-表达式”的缩写)是 Lisp 文本形式的基本语法单元:列表或 Lisp 原子。 Sexps 也是 Lisp 语言的平衡表达式 (qv);这就是为什么编辑平衡表达式的命令具有 '性别'以他们的名义。请参阅性别

A sexp (short for “s-expression”) is the basic syntactic unit of Lisp in its textual form: either a list, or Lisp atom. Sexps are also the balanced expressions (q.v.) of the Lisp language; this is why the commands for editing balanced expressions have ‘sexp’ in their name. See Sexps.

同步编辑
Simultaneous Editing

同时编辑意味着两个用户同时修改同一个文件。如果未检测到同时编辑,可能会导致用户丢失其工作成果。 Emacs 检测所有同时编辑的情况,并警告其中一名用户进行调查。请参阅同时编辑

Simultaneous editing means two users modifying the same file at once. Simultaneous editing, if not detected, can cause one user to lose his or her work. Emacs detects all cases of simultaneous editing, and warns one of the users to investigate. See Simultaneous Editing.

SPC
SPC

SPC是空格字符,通过按空格键输入。

SPC is the space character, which you enter by pressing the space bar.

速度条
Speedbar

speedbar 是一个特殊的高框架,它提供对 Emacs 缓冲区、这些缓冲区中的函数、信息节点以及 Emacs 中其他有趣的文本部分的快速访问。请参阅Speedbar 框架

The speedbar is a special tall frame that provides fast access to Emacs buffers, functions within those buffers, Info nodes, and other interesting parts of text within Emacs. See Speedbar Frames.

拼写检查
Spell Checking

拼写检查是指检查文本中每个单词的书面形式的正确性。 Emacs 可以使用各种外部拼写检查程序通过方便的用户界面检查缓冲区各部分的拼写。请参阅检查和更正拼写

Spell checking means checking correctness of the written form of each one of the words in a text. Emacs can use various external spelling-checker programs to check the spelling of parts of a buffer via a convenient user interface. See Checking and Correcting Spelling.

细绳
String

字符串是一种包含字符序列的 Lisp 数据对象。许多 Emacs 变量旨在将字符串作为值。字符串的 Lisp 语法由字符串中带有 ' 的字符组成'之前和另一个'' 后。 A '' 作为字符串的一部分必须写成 '\"'和一个'\' 作为字符串的一部分必须写成 '\\'。所有其他字符,包括换行符,只需将它们写入字符串即可包含在内;然而,反斜杠序列与 C 中一样,例如 '\n'换行符或'\241' 使用八进制字符代码也是允许的。

A string is a kind of Lisp data object that contains a sequence of characters. Many Emacs variables are intended to have strings as values. The Lisp syntax for a string consists of the characters in the string with a ‘"’ before and another ‘"’ after. A ‘"’ that is part of the string must be written as ‘\"’ and a ‘\’ that is part of the string must be written as ‘\\’. All other characters, including newline, can be included just by writing them inside the string; however, backslash sequences as in C, such as ‘\n’ for newline or ‘\241’ using an octal character code, are allowed as well.

字符串替换
String Substitution

请参阅术语表---全局替换

See Glossary---Global Substitution.

象征
Symbol

Emacs Lisp 中的符号是一个有名称的对象。该对象可以是变量 (qv)、函数或命令 (qv) 或面 (qv)。符号的名称作为符号的印刷表示形式。请参阅Emacs Lisp 参考手册中的符号类型

A symbol in Emacs Lisp is an object with a name. The object can be a variable (q.v.), a function or command (q.v.), or a face (q.v.). The symbol’s name serves as the printed representation of the symbol. See Symbol Type in The Emacs Lisp Reference Manual.

语法高亮
Syntax Highlighting

请参见术语表---字体锁定

See Glossary---Font Lock.

语法表
Syntax Table

语法表告诉 Emacs 哪些字符是单词的一部分,哪些字符像括号一样相互平衡,等等。请参阅Emacs Lisp 参考手册中的语法表

The syntax table tells Emacs which characters are part of a word, which characters balance each other like parentheses, etc. See Syntax Tables in The Emacs Lisp Reference Manual.

极好的
Super

Super 是键盘输入字符可能具有的修饰符位的名称。要创建超级字符,请在按住该 SUPER键的同时键入该字符。这些字符的名称以 Super-(通常缩写s-为)开头。请参阅修饰键

Super is the name of a modifier bit that a keyboard input character may have. To make a character Super, type it while holding down the SUPER key. Such characters are given names that start with Super- (usually written s- for short). See Modifier Keys.

暂停
Suspending

挂起 Emacs 意味着暂时停止它并将控制权返回给其父进程(通常是 shell)。与终止作业 (qv) 不同,您可以稍后恢复挂起的 Emacs 作业,而不会丢失缓冲区、未保存的编辑、撤消历史记录等。请参阅退出 Emacs

Suspending Emacs means stopping it temporarily and returning control to its parent process, which is usually a shell. Unlike killing a job (q.v.), you can later resume the suspended Emacs job without losing your buffers, unsaved edits, undo history, etc. See Exiting Emacs.

TAB
TAB

TAB是制表符。在 Emacs 中,它通常用于缩进或完成。

TAB is the tab character. In Emacs it is typically used for indentation or completion.

标签栏
Tab Bar

选项卡栏是 Emacs 框架顶部的一排选项卡。单击这些选项卡之一可切换名为持久窗口配置的选项。请参阅选项卡栏

The tab bar is a row of tabs at the top of an Emacs frame. Clicking on one of these tabs switches named persistent window configurations. See Tab Bars.

制表线
Tab Line

选项卡行是 Emacs 窗口顶部的一行选项卡。单击这些选项卡之一可切换窗口缓冲区。请参见窗口选项卡行

The tab line is a line of tabs at the top of an Emacs window. Clicking on one of these tabs switches window buffers. See Window Tab Line.

标签
Tag

标签是节目源中的标识符。请参阅查找标识符参考

A tag is an identifier in a program source. See Find Identifier References.

标签表
Tags Table

标签表是一种用作标识符索引的文件:一个或多个其他文件中的函数、宏、数据结构等的定义。请参阅标签表

A tags table is a file that serves as an index to identifiers: definitions of functions, macros, data structures, etc., in one or more other files. See Tags Tables.

术语脚本文件
Termscript File

termscript 文件包含 Emacs 发送到终端的所有字符的记录。它用于跟踪 Emacs 重新显示中的错误。除非您指定,否则 Emacs 不会创建 termscript 文件。请参阅报告错误

A termscript file contains a record of all characters sent by Emacs to the terminal. It is used for tracking down bugs in Emacs redisplay. Emacs does not make a termscript file unless you tell it to. See Reporting Bugs.

文本
Text

“文本”有两种含义(参见人类语言命令):

  • 由字符序列组成的数据,与二进制数、可执行程序等不同。从这个意义上讲,Emacs 缓冲区的基本内容(除了文本属性 qv)始终是文本。
  • 由书面人类语言(与程序相对)组成或遵循人类语言的文体约定的数据。

“Text” has two meanings (see Commands for Human Languages):

  • Data consisting of a sequence of characters, as opposed to binary numbers, executable programs, and the like. The basic contents of an Emacs buffer (aside from the text properties, q.v.) are always text in this sense.
  • Data consisting of written human language (as opposed to programs), or following the stylistic conventions of human language.
文本终端
Text Terminal

文本终端或字符终端是仅限于以字符为单位显示文本的显示器。这样的终端无法控制其显示的各个像素。 Emacs 支持文本终端上的一部分显示功能。

A text terminal, or character terminal, is a display that is limited to displaying text in character units. Such a terminal cannot control individual pixels it displays. Emacs supports a subset of display features on text terminals.

文本属性
Text Properties

文本属性是为缓冲区中的特定字符记录的注释。缓冲区中的图像被记录为文本属性;它们还指定格式信息。请参阅编辑格式信息

Text properties are annotations recorded for particular characters in the buffer. Images in the buffer are recorded as text properties; they also specify formatting information. See Editing Format Information.

主题
Theme

主题是一组定制 (qv),它们赋予 Emacs 特定的外观或行为。例如,您可以为您最喜欢的一组面孔 (qv) 使用主题。

A theme is a set of customizations (q.v.) that give Emacs a particular appearance or behavior. For example, you might use a theme for your favorite set of faces (q.v.).

工具栏
Tool Bar

工具栏是 Emacs 框架顶部的一行(有时是多行)图标。单击这些图标之一即可执行命令。您可以将其视为菜单栏 (qv) 的图形相关项。请参阅工具栏

The tool bar is a line (sometimes multiple lines) of icons at the top of an Emacs frame. Clicking on one of these icons executes a command. You can think of this as a graphical relative of the menu bar (q.v.). See Tool Bars.

工具提示
Tooltips

工具提示是显示帮助回显 (qv) 文本的小窗口,它解释了显示的各个部分,列出了通过鼠标单击可用的有用选项等。请参阅工具提示

Tooltips are small windows displaying a help echo (q.v.) text, which explains parts of the display, lists useful options available via mouse clicks, etc. See Tooltips.

顶层
Top Level

顶层是 Emacs 的正常状态,您正在编辑已访问文件的文本。只要您不在递归编辑级别 (qv) 或迷你缓冲区 (qv) 中,并且不在命令中间,您就处于顶层。您可以通过中止 (qv) 和退出 (qv) 返回顶层。请参阅退出和中止

Top level is the normal state of Emacs, in which you are editing the text of the file you have visited. You are at top level whenever you are not in a recursive editing level (q.v.) or the minibuffer (q.v.), and not in the middle of a command. You can get back to top level by aborting (q.v.) and quitting (q.v.). See Quitting and Aborting.

瞬态标记模式
Transient Mark Mode

标记 (qv) 和区域 (qv) 的默认行为(其中设置标记会激活它并突出显示区域)称为瞬态标记模式。默认情况下它是启用的。请参阅禁用瞬态标记模式

The default behavior of the mark (q.v.) and region (q.v.), in which setting the mark activates it and highlights the region, is called Transient Mark mode. It is enabled by default. See Disabling Transient Mark Mode.

换位
Transposition

调换两个文本单元意味着将每个文本单元放到另一个文本单元之前占据的位置。 Emacs 命令可以调换两个相邻的字符、单词、平衡表达式 (qv) 或行(请参阅调换文本)。

Transposing two units of text means putting each one into the place formerly occupied by the other. There are Emacs commands to transpose two adjacent characters, words, balanced expressions (q.v.) or lines (see Transposing Text).

垃圾箱
Trash Can

请参阅术语表---删除文件

See Glossary---Deletion of Files.

截断
Truncation

截断显示中的文本行意味着省略不适合显示该文本的窗口的右边距的行上的任何文本。请参阅截断术语表---续行

Truncating text lines in the display means leaving out any text on a line that does not fit within the right margin of the window displaying it. See Truncation, and Glossary---Continuation Line.

电传打字员
TTY

请参阅术语表---文本终端

See Glossary---Text Terminal.

撤销
Undoing

撤消意味着使之前的编辑反向进行,恢复编辑会话中较早存在的文本。请参阅撤消

Undoing means making your previous editing go in reverse, bringing back the text that existed earlier in the editing session. See Undo.

Unix
Unix

Unix是一类具有悠久历史的多用户计算机操作系统。今天有几种实现。 GNU 项目 (qv) 旨在开发一个完整的类 Unix 操作系统,即自由软件 (qv)。

Unix is a class of multi-user computer operating systems with a long history. There are several implementations today. The GNU project (q.v.) aims to develop a complete Unix-like operating system that is free software (q.v.).

用户选项
User Option

用户选项是一个面 (qv) 或一个存在的变量 (qv),以便您可以通过将其设置为新值来自定义 Emacs。请参阅简易定制界面

A user option is a face (q.v.) or a variable (q.v.) that exists so that you can customize Emacs by setting it to a new value. See Easy Customization Interface.

多变的
Variable

变量是 Lisp 中可以存储任意值的对象。 Emacs 使用一些变量用于内部目的,还有其他变量(称为“用户选项”;qv),以便您可以设置它们的值来控制 Emacs 的行为。您可能感兴趣的 Emacs 中使用的变量列在本手册的变量索引中(请参阅变量索引)。有关变量的信息, 请参阅变量。

A variable is an object in Lisp that can store an arbitrary value. Emacs uses some variables for internal purposes, and has others (known as “user options”; q.v.) just so that you can set their values to control the behavior of Emacs. The variables used in Emacs that you are likely to be interested in are listed in the Variables Index in this manual (see Variable Index). See Variables, for information on variables.

版本控制
Version Control

版本控制系统跟踪源文件的多个版本。它们提供了保存备份文件 (qv) 的更强大的替代方案。请参阅版本控制

Version control systems keep track of multiple versions of a source file. They provide a more powerful alternative to keeping backup files (q.v.). See Version Control.

参观
Visiting

访问文件意味着将其内容加载到可以编辑的缓冲区 (qv) 中。请参阅访问文件

Visiting a file means loading its contents into a buffer (q.v.) where they can be edited. See Visiting Files.

空白
Whitespace

空白是任何连续的格式化字符(空格、制表符、换行符、退格符等)。

Whitespace is any run of consecutive formatting characters (space, tab, newline, backspace, etc.).

加宽
Widening

加宽是指消除对当前缓冲区的任何限制 (qv);它与缩小 (qv) 相反。请参阅缩小范围

Widening is removing any restriction (q.v.) on the current buffer; it is the opposite of narrowing (q.v.). See Narrowing.

窗户
Window

Emacs 将一帧(qv)划分为一个或多个窗口,每个窗口可以随时显示一个缓冲区(qv)的内容。有关 Emacs 如何使用屏幕的基本信息,请参阅屏幕的组织。有关控制窗口使用的命令,请参阅多个窗口。其他一些编辑器使用术语“窗口”来表示 Emacs 中的“框架”。

Emacs divides a frame (q.v.) into one or more windows, each of which can display the contents of one buffer (q.v.) at any time. See The Organization of the Screen, for basic information on how Emacs uses the screen. See Multiple Windows, for commands to control the use of windows. Some other editors use the term “window” for what we call a “frame” in Emacs.

窗口系统
Window System

窗口系统是在图形显示器(qv)上运行的软件,用于细分屏幕,以便多个应用程序可以同时拥有自己的窗口。所有现代操作系统都包含窗口系统。

A window system is software that operates on a graphical display (q.v.), to subdivide the screen so that multiple applications can have their own windows at the same time. All modern operating systems include a window system.

单词缩写
Word Abbrev

参见术语表---缩写

See Glossary---Abbrev.

单词搜索
Word Search

单词搜索正在搜索一系列单词,认为它们之间的标点符号无关紧要。请参阅单词搜索

Word search is searching for a sequence of words, considering the punctuation between them as insignificant. See Word Search.

扬金
Yanking

Yanking 意味着重新插入之前被删除的文本 (qv)。它可用于撤消错误的删除,或用于复制或移动文本。其他一些系统将此称为“粘贴”。参见扬京

Yanking means reinserting text previously killed (q.v.). It can be used to undo a mistaken kill, or for copying or moving text. Some other systems call this “pasting”. See Yanking.


致谢

Acknowledgments

许多人贡献了包含在自由软件基金会的 GNU Emacs 发行版中的代码。为了表达我们对他们的公共精神的赞赏,我们在这里按字母顺序列出了那些撰写了大量内容的人。其他人已经报告并修复了错误,并为 Emacs 的许多部分添加了功能,不胜枚举。我们也感谢他们的慷慨。

Many people have contributed code included in the Free Software Foundation’s distribution of GNU Emacs. To show our appreciation for their public spirit, we list here in alphabetical order those who have written substantial portions. Others too numerous to mention have reported and fixed bugs, and added features to many parts of Emacs. We thank them for their generosity as well.

此列表旨在提及主要软件包或功能的每个贡献者;如果您知道我们遗漏了某个人,请提交错误报告。更全面的信息可在 变更日志文件,总结在文件中等/作者在分布中。

This list is intended to mention every contributor of a major package or feature; if you know of someone we have omitted, please make a bug report. More comprehensive information is available in the ChangeLog files, summarized in the file etc/AUTHORS in the distribution.

  • Per Abrahamsen 编写了定制工具,以及 双电子,用于输入键盘上通常无法输入的重音字符;xt-mouse.el,允许通过 Xterm 执行鼠标命令;gnus-cus.el,它实现了Gnus的定制命令;gnus-cite.el,新闻文章的引文解析工具;gnus-score.el,Gnus 得分;cpp.el,根据预处理器条件隐藏或突出显示 C 程序的部分内容;和小部件库文件宽浏览器, wid-edit.el,小部件.el。他还合写了 gnus-soup.el
  • Per Abrahamsen wrote the customization facilities, as well as double.el, for typing accented characters not normally available from the keyboard; xt-mouse.el, which allows mouse commands through Xterm; gnus-cus.el, which implements customization commands for Gnus; gnus-cite.el, a citation-parsing facility for news articles; gnus-score.el, scoring for Gnus; cpp.el, which hides or highlights parts of C programs according to preprocessor conditionals; and the widget library files wid-browse.el, wid-edit.el, widget.el. He also co-wrote gnus-soup.el.
  • 托马斯·亚伯拉罕森写道艺术家.el,一个用于使用鼠标或键盘按键 制作ASCII艺术的软件包 。
  • Tomas Abrahamsson wrote artist.el, a package for producing ASCII art with a mouse or with keyboard keys.
  • 杰·K·亚当斯写道jka-compr.eljka-cmpr-hook.el,提供压缩文件的自动解压和重新压缩。
  • Jay K. Adams wrote jka-compr.el and jka-cmpr-hook.el, providing automatic decompression and recompression for compressed files.
  • 迈克尔·阿尔比努斯写道dbus.el,实现D-Bus消息总线协议的包;零配置,浏览Avahi服务的模式;秘密.el,用于存储机密数据的密钥环守护程序的接口;和文件通知.el以及相关的低级接口例程,用于监视文件状态变化。他和 Kai Großjohann 编写了 Tramp 软件包,该软件包使用 ssh、ftp 和其他网络协议提供透明的远程文件编辑。他和丹尼尔·皮特曼写道流浪缓存.el
  • Michael Albinus wrote dbus.el, a package that implements the D-Bus message bus protocol; zeroconf.el, a mode for browsing Avahi services; secrets.el, an interface to keyring daemons for storing confidential data; and filenotify.el and the associated low-level interface routines, for watching file status changes. He and Kai Großjohann wrote the Tramp package, which provides transparent remote file editing using ssh, ftp, and other network protocols. He and Daniel Pittman wrote tramp-cache.el.
  • 拉尔夫·安杰利写道滚动锁.el,一种次要模式,在缓冲区中上下移动时通过滚动窗口来保持点垂直固定。
  • Ralf Angeli wrote scroll-lock.el, a minor mode which keeps the point vertically fixed by scrolling the window when moving up and down in the buffer.
  • Aurélien Aptel 为 Emacs 添加了动态模块支持。 Philipp Stephani 和其他人也参与了动态模块代码的工作。
  • Aurélien Aptel added dynamic module support to Emacs. Philipp Stephani and others also worked on the dynamic module code.
  • Joe Arceneaux 编写了原始文本属性实现,并实现了对 X11 的支持。
  • Joe Arceneaux wrote the original text property implementation, and implemented support for X11.
  • 埃米尔·奥斯特罗姆、米兰·扎马扎和斯特凡·布鲁达写道序言.el,一种编辑 Prolog(和 Mercury)代码的模式。
  • Emil Åström, Milan Zamaza, and Stefan Bruda wrote prolog.el, a mode for editing Prolog (and Mercury) code.
  • 迈尔斯·巴德写道图像文件.el、支持访问图片文件的代码;minibuf-eldef.el,一种次要模式,在适当的时候隐藏迷你缓冲区默认值;rfn-eshadow.elread-file-name,输入的遮蔽 ;mb-深度.el、显示minibuffer深度;按钮.el,实现可点击按钮的库; 面部重映射.el,用于更改各个缓冲区中的默认面的包;和宏表达式.el为宏观扩张。他还研究了词汇绑定代码的早期版本。
  • Miles Bader wrote image-file.el, support code for visiting image files; minibuf-eldef.el, a minor mode that hides the minibuffer default value when appropriate; rfn-eshadow.el, shadowing of read-file-name input; mb-depth.el, display of minibuffer depth; button.el, the library that implements clickable buttons; face-remap.el, a package for changing the default face in individual buffers; and macroexp.el for macro-expansion. He also worked on an early version of the lexical binding code.
  • 大卫·巴卡什写道笔画.el,一种通过以特定模式移动鼠标来控制 Emacs 的模式。
  • David Bakhash wrote strokes.el, a mode for controlling Emacs by moving the mouse in particular patterns.
  • 胡安玛·巴兰克罗写道emacs-lock.el(基于 Tom Wurgler 的原始版本),这使得在未保存有价值的缓冲区的情况下退出变得更加困难;和框架集.el,用于保存和恢复框架/窗口设置。他还为其他领域做出了许多其他贡献,包括 MS Windows 支持。
  • Juanma Barranquero wrote emacs-lock.el (based on the original version by Tom Wurgler), which makes it harder to exit with valuable buffers unsaved; and frameset.el, for saving and restoring the frame/window setup. He also made many other contributions to other areas, including MS Windows support.
  • 伊莱·巴齐莱写道计算器.el,Emacs 的桌面计算器。
  • Eli Barzilay wrote calculator.el, a desktop calculator for Emacs.
  • 史蒂文·L·鲍尔写道脚注.el它允许您在电子邮件中添加脚注;和gnus-audio.el耳康网,为 Gnus 提供声音效果。他还写了 gnus-setup.el
  • Steven L. Baur wrote footnote.el which lets you include footnotes in email messages; and gnus-audio.el and earcon.el, which provide sound effects for Gnus. He also wrote gnus-setup.el.
  • Alexander L. Belikoff、Sergey Berezin、Sacha Chua、David Edmondson、Noah Friedman、Andreas Fuchs、Mario Lang、Ben Mesander、Lawrence Mitchell、Gergely Nagy、Michael Olson、Per Persson、Jorgen Schäfer、Alex Schroeder 和 Tom Tromey 撰写了 ERC,高级 Internet 中继聊天客户端(有关详细信息,请参阅文件学分在 ERC 发行版中)。
  • Alexander L. Belikoff, Sergey Berezin, Sacha Chua, David Edmondson, Noah Friedman, Andreas Fuchs, Mario Lang, Ben Mesander, Lawrence Mitchell, Gergely Nagy, Michael Olson, Per Persson, Jorgen Schäfer, Alex Schroeder, and Tom Tromey wrote ERC, an advanced Internet Relay Chat client (for more information, see the file CREDITS in the ERC distribution).
  • Scott Bender、Michael Brouwer、Christophe de Dinechin、Carl Edman、Christian Limpach 和 Adrian Robert 开发并维护了 Emacs 的 NeXTstep 端口。
  • Scott Bender, Michael Brouwer, Christophe de Dinechin, Carl Edman, Christian Limpach and Adrian Robert developed and maintained the NeXTstep port of Emacs.
  • 斯蒂芬·伯曼写道todo-mode.el(基于 Oliver Seidel 的原始版本),一个用于维护的包去做列出文件。
  • Stephen Berman wrote todo-mode.el (based on the original version by Oliver Seidel), a package for maintaining TODO list files.
  • 安娜·M·比加蒂写道cal-html.el,它生成 HTML 日历。
  • Anna M. Bigatti wrote cal-html.el, which produces HTML calendars.
  • 雷·布莱克和西蒙·南写道欧帕斯卡.el,一种用于编辑 Object Pascal 源代码的模式。
  • Ray Blaak and Simon South wrote opascal.el, a mode for editing Object Pascal source code.
  • 马丁·布莱斯、斯特凡·默滕和大卫·古杰写道rst.el,一种用于编辑 reStructuredText 文档的模式。
  • Martin Blais, Stefan Merten, and David Goodger wrote rst.el, a mode for editing reStructuredText documents.
  • Jim Blandy 编写了 Emacs 19 的输入系统,使其配置和构建过程符合 GNU 编码标准,并为框架支持和多面支持做出了贡献。吉姆还写道tvi970.el、终端支持TeleVideo 970终端;并共同撰写 wyse50.el(qv)。
  • Jim Blandy wrote Emacs 19’s input system, brought its configuration and build process up to the GNU coding standards, and contributed to the frame support and multi-face support. Jim also wrote tvi970.el, terminal support for the TeleVideo 970 terminals; and co-wrote wyse50.el (q.v.).
  • Per Bothner 写道术语.el,Emacs 缓冲区中的终端仿真器。
  • Per Bothner wrote term.el, a terminal emulator in an Emacs buffer.
  • 特伦斯·M·布兰农写道地标.el,一个学习地标的神经网络机器人。
  • Terrence M. Brannon wrote landmark.el, a neural-network robot that learns landmarks.
  • 弗兰克·布雷兹写道差异,一个显示输出的程序diff
  • Frank Bresz wrote diff.el, a program to display diff output.
  • 彼得·布雷顿实施土轨网,一个用于跟踪 shell 缓冲区中目录更改的库;文件缓存.el,它记录您的文件所在的目录;定位.el,与locate命令交互;find-lisp.el,该程序的 Emacs Lisp 模拟findnet-utils.el;和通用模式功能。
  • Peter Breton implemented dirtrack.el, a library for tracking directory changes in shell buffers; filecache.el, which records which directories your files are in; locate.el, which interfaces to the locate command; find-lisp.el, an Emacs Lisp emulation of the find program; net-utils.el; and the generic mode feature.
  • 伊曼纽尔·布里奥特写道xml.el,Emacs 的 XML 解析器;和 ada-prj.el、Ada模式项目文件的编辑以及共同创作ada-mode.elada-xref.el
  • Emmanuel Briot wrote xml.el, an XML parser for Emacs; and ada-prj.el, editing of Ada mode project files, as well as co-authoring ada-mode.el and ada-xref.el.
  • 凯文·布罗德写道折页.el,为 Emacs 的大纲模式提供折叠扩展。
  • Kevin Broadey wrote foldout.el, providing folding extensions to Emacs’s outline modes.
  • 大卫·M·布朗写道数组.el,用于编辑数组和其他表格数据。
  • David M. Brown wrote array.el, for editing arrays and other tabular data.
  • Włodek Bzyl 和 Ryszard Kubiak 写道奥戈内克.el,用于更改波兰语字符编码的包。
  • Włodek Bzyl and Ryszard Kubiak wrote ogonek.el, a package for changing the encoding of Polish characters.
  • 比尔·卡彭特提供feedmail.el,一个用于整理外发邮件消息并通过各种流行的邮件程序发送它们的包。
  • Bill Carpenter provided feedmail.el, a package for massaging outgoing mail messages and sending them through various popular mailers.
  • Per Cederqvist 和 Inge Wallin 写道埃沃克网站,一个用于操作对象集合的 Emacs 小部件。 Per Cederqvist、Inge Wallin 和 Thomas Bellman 写道avl-tree.el,对于平衡二叉树。
  • Per Cederqvist and Inge Wallin wrote ewoc.el, an Emacs widget for manipulating object collections. Per Cederqvist, Inge Wallin, and Thomas Bellman wrote avl-tree.el, for balanced binary trees.
  • 汉斯·查洛普斯基写道咨询.el,Emacs Lisp 函数的重载机制;和跟踪.el,Emacs Lisp 的跟踪工具。
  • Hans Chalupsky wrote advice.el, an overloading mechanism for Emacs Lisp functions; and trace.el, a tracing facility for Emacs Lisp.
  • Chris Chase、Carsten Dominik 和 JD Smith 编写了 IDLWAVE 模式,用于编辑 IDL 和 WAVE CL。
  • Chris Chase, Carsten Dominik, and J. D. Smith wrote IDLWAVE mode, for editing IDL and WAVE CL.
  • 鲍勃·查塞尔写道texnfo-upd.el,texinfo.el, 和 makeinfo.el、用于处理 Texinfo 文件的模式和实用程序;和页面扩展.el,用于扩展页面处理的命令。他还撰写了 Emacs Lisp 简介。请参阅Emacs Lisp 编程简介
  • Bob Chassell wrote texnfo-upd.el, texinfo.el, and makeinfo.el, modes and utilities for working with Texinfo files; and page-ext.el, commands for extended page handling. He also wrote the Emacs Lisp introduction. See Introduction to Programming in Emacs Lisp.
  • 赵智贤写道汉字实用程序韩文网,韩文汉字实用程序。
  • Jihyun Cho wrote hanja-util.el and hangul.el, utilities for Korean Hanja.
  • Andrew Choi 和 Yamamoto Mitsuharu 编写了 Carbon 支持,在 Emacs 23 for macOS 之前使用。 Yamamoto Mitsuharu 继续为较新的 Nextstep 端口中的 macOS 支持做出贡献;还改进了对多显示器显示的支持。
  • Andrew Choi and Yamamoto Mitsuharu wrote the Carbon support, used prior to Emacs 23 for macOS. Yamamoto Mitsuharu continued to contribute to macOS support in the newer Nextstep port; and also improved support for multi-monitor displays.
  • Chong Yidong 是 Emacs 23 到 24.3 期间的 Emacs 联合维护者。他对 Emacs 显示引擎进行了许多改进。他还写了 表格列表.el,数据列表的通用主要模式;并改进了对主题和包的支持。
  • Chong Yidong was the Emacs co-maintainer from Emacs 23 to 24.3. He made many improvements to the Emacs display engine. He also wrote tabulated-list.el, a generic major mode for lists of data; and improved support for themes and packages.
  • James Clark 编写了 SGML 模式,一种编辑 SGML 文档的模式; nXML 模式,一种编辑 XML 文档的模式。他还为 Emacs 的转储程序做出了贡献。
  • James Clark wrote SGML mode, a mode for editing SGML documents; and nXML mode, a mode for editing XML documents. He also contributed to Emacs’s dumping procedures.
  • 迈克·克拉克森写道电子报,DEC 的 EDT 编辑器的模拟。
  • Mike Clarkson wrote edt.el, an emulation of DEC’s EDT editor.
  • 格林·克莱门茨提供游戏网格.el以及一些使用它的游戏,《贪吃蛇》和《俄罗斯方块》。
  • Glynn Clements provided gamegrid.el and a couple of games that use it, Snake and Tetris.
  • 安德鲁·科恩写道垃圾邮件清洗网站,在分析垃圾邮件之前解码并清理电子邮件。
  • Andrew Cohen wrote spam-wash.el, to decode and clean email before it is analyzed for spam.
  • Daniel Colascione 在中编写了可移植的转储代码pdumper.c 和其他地方。他还为基于 X 的 GUI 框架实现了双缓冲,以及将共享对象模块加载到 Emacs 中的原始支持。
  • Daniel Colascione wrote the portable dumping code in pdumper.c and elsewhere. He also implemented double-buffering for X-based GUI frames, and the original support for loading shared-object modules into Emacs.
  • 特里萨·奥康纳写道json.el,用于解析和生成 JSON 文件的文件。
  • Theresa O’Connor wrote json.el, a file for parsing and generating JSON files.
  • Andrea Corallo 在中编写了本机编译支持计算机程序迫使,用于使用 ' 将 Emacs Lisp 编译为本机代码libgccjit'。
  • Andrea Corallo wrote the native compilation support in comp.c and comp.el, for compiling Emacs Lisp to native code using ‘libgccjit’.
  • 乔治·布伦-科坦和斯特凡·莫尼尔写道Easy-mmode.el,一个用于轻松定义主要模式和次要模式的包。
  • Georges Brun-Cottan and Stefan Monnier wrote easy-mmode.el, a package for easy definition of major and minor modes.
  • Andrew Csillag 编写了 M4 模式(m4-模式.el)。
  • Andrew Csillag wrote M4 mode (m4-mode.el).
  • 道格·卡廷 (Doug Cutting) 和杰米·扎文斯基 (Jamie Zawinski) 写道disass.el,编译 Emacs Lisp 代码的反汇编器。
  • Doug Cutting and Jamie Zawinski wrote disass.el, a disassembler for compiled Emacs Lisp code.
  • 马蒂亚斯·达尔写道图像目录.el,用于以缩略图形式查看图像文件的包。
  • Mathias Dahl wrote image-dired.el, a package for viewing image files as thumbnails.
  • Julien Danjou 编写了桌面通知的实现(通知.el,以及 ERC 和 Gnus 的相关包);和彩色.el,一个用于一般颜色操作的库。他还为 Gnus 做出了各种贡献。
  • Julien Danjou wrote an implementation of desktop notifications (notifications.el, and related packages for ERC and Gnus); and color.el, a library for general color manipulation. He also made various contributions to Gnus.
  • 维韦克·达斯莫哈帕特拉写道htmlfontify.el,将缓冲区或源树转换为 HTML。
  • Vivek Dasmohapatra wrote htmlfontify.el, to convert a buffer or source tree to HTML.
  • 马蒂厄·德文写道德尔塞尔,一个使新输入的文本替换当前选择的包。
  • Matthieu Devin wrote delsel.el, a package to make newly-typed text replace the current selection.
  • 埃里克·丁写道转到地址.el,
  • Eric Ding wrote goto-addr.el,
  • Jan Djärv 添加了对 GTK+ 工具包和 X 拖放的支持。他还写了动态设置.el
  • Jan Djärv added support for the GTK+ toolkit and X drag-and-drop. He also wrote dynamic-setting.el.
  • Carsten Dominik 编写了 RefTeX,这是一个用于在 LaTeX 文档中设置标签和交叉引用的包;并共同编写了 IDLWAVE 模式 (qv)。他是 Org 模式的原作者,用于维护笔记、待办事项列表和项目规划。 Bastien Guerry 随后接管了维护工作。本杰明·安德烈森、托马斯·鲍曼、乔尔·博兰、扬·博克、伦纳特·博格曼、崔宝秋、丹·戴维森、克里斯蒂安·埃格利、埃里克·S·弗拉加、丹尼尔·日耳曼、克里斯·格雷、康拉德·辛森、塔西洛·霍恩、菲利普·杰克逊、马丁·贾戈、托尔斯滕·乔利茨、 Jambunathan K、龟岛德也、谢尔盖·利特维诺夫、大卫·莫斯、罗斯·帕特森、胡安·佩希亚尔、塞巴斯蒂安·罗斯、埃里克·舒尔特、保罗·塞克斯顿、乌尔夫·斯蒂格曼、安迪·斯图尔特、克里斯托弗·萨克林、大卫·奥图尔、约翰·韦格利、张伟泽、皮奥特·齐林斯基、其他人还编写了各种 Org 模式组件。有关更多信息,请参阅《组织手册》中的历史记录和致谢
  • Carsten Dominik wrote RefTeX, a package for setting up labels and cross-references in LaTeX documents; and co-wrote IDLWAVE mode (q.v.). He was the original author of Org mode, for maintaining notes, todo lists, and project planning. Bastien Guerry subsequently took over maintainership. Benjamin Andresen, Thomas Baumann, Joel Boehland, Jan Böcker, Lennart Borgman, Baoqiu Cui, Dan Davison, Christian Egli, Eric S. Fraga, Daniel German, Chris Gray, Konrad Hinsen, Tassilo Horn, Philip Jackson, Martyn Jago, Thorsten Jolitz, Jambunathan K, Tokuya Kameshima, Sergey Litvinov, David Maus, Ross Patterson, Juan Pechiar, Sebastian Rose, Eric Schulte, Paul Sexton, Ulf Stegemann, Andy Stewart, Christopher Suckling, David O’Toole, John Wiegley, Zhang Weize, Piotr Zieliński, and others also wrote various Org mode components. For more information, see History and Acknowledgments in The Org Manual.
  • 斯科特·德拉夫斯写道tq.el,用于维护 Emacs 及其子进程之间的事务队列的帮助函数。
  • Scott Draves wrote tq.el, help functions for maintaining transaction queues between Emacs and its subprocesses.
  • 本杰明·德里厄写道庞埃尔,经典乒乓球游戏的实现。
  • Benjamin Drieu wrote pong.el, an implementation of the classical pong game.
  • Viktor Dukhovni 在 SunOS 版本 4 下编写了对转储的支持。
  • Viktor Dukhovni wrote support for dumping under SunOS version 4.
  • John Eaton 和 Kurt Hornik 编写了 Octave 模式。
  • John Eaton and Kurt Hornik wrote Octave mode.
  • Rolf Ebert、Markus Heritsch 和 Emmanuel Briot 编写了 Ada 模式。
  • Rolf Ebert, Markus Heritsch, and Emmanuel Briot wrote Ada mode.
  • Paul Eggert 集成了 Gnulib 可移植性库,并对 C 代码进行了许多其他可移植性修复;以及他对 VC 和日历的贡献。
  • Paul Eggert integrated the Gnulib portability library, and made many other portability fixes to the C code; as well as his contributions to VC and the calendar.
  • 斯蒂芬·埃格伦写道mspools.el,它告诉您哪些 Procmail 文件夹中有邮件在等待。
  • Stephen Eglen wrote mspools.el, which tells you which Procmail folders have mail waiting in them.
  • 托比昂·艾纳尔松写道f90.el,Fortran 90 文件的模式。
  • Torbjörn Einarsson wrote f90.el, a mode for Fortran 90 files.
  • Tsugutomo Enami 与人共同编写了对国际字符集的支持。
  • Tsugutomo Enami co-wrote the support for international character sets.
  • 大卫·恩斯特写道麦里克斯.elnnmairix.el,Mairix 索引工具的接口。
  • David Engster wrote mairix.el and nnmairix.el, an interface to the Mairix indexing tool.
  • 汉斯·亨里克·埃里克森写道模拟.el,一种编辑 SIMULA 87 代码的模式。
  • Hans Henrik Eriksen wrote simula.el, a mode for editing SIMULA 87 code.
  • 迈克尔·恩斯特写道重新定位.el,用于将函数源代码和屏幕上前面的注释重新居中的命令。
  • Michael Ernst wrote reposition.el, a command for recentering a function’s source code and preceding comment on the screen.
  • 阿塔·埃特马迪写道cdl.el,用于使用通用数据语言源代码的函数。
  • Ata Etemadi wrote cdl.el, functions for working with Common Data Language source code.
  • 弗雷德里克·法恩巴赫实施摩尔斯电报,它将文本转换为摩尔斯电码。
  • Frederick Farnbach implemented morse.el, which converts text to Morse code.
  • Oscar Figueiredo 编写了 EUDC(Emacs 统一目录客户端),它是通过 LDAP、CCSO PH/QI 或 BBDB 与目录服务器的接口;和 ldap.el,LDAP 客户端界面。
  • Oscar Figueiredo wrote EUDC, the Emacs Unified Directory Client, which is an interface to directory servers via LDAP, CCSO PH/QI, or BBDB; and ldap.el, the LDAP client interface.
  • Fred Fish 编写了对转储 COFF 可执行文件的支持。
  • Fred Fish wrote the support for dumping COFF executable files.
  • 卡尔·福格尔写道书签.el,它实现命名占位符;邮件历史.el,外发邮件消息的历史记录机制;和保存地点.el,用于在编辑会话之间保留文件中的点位置。
  • Karl Fogel wrote bookmark.el, which implements named placeholders; mail-hist.el, a history mechanism for outgoing mail messages; and saveplace.el, for preserving point’s location in files between editing sessions.
  • 加里·福斯特写道全部滚动.el,一种同时滚动多个缓冲区的模式。
  • Gary Foster wrote scroll-all.el, a mode for scrolling several buffers together.
  • Romain Francoise 贡献了 ACL(访问控制列表)支持,用于在备份和复制时保留扩展文件属性。
  • Romain Francoise contributed ACL (Access Control List) support, for preserving extended file attributes on backup and copy.
  • 诺亚·弗里德曼写道rlogin.el,Rlogin 的接口, 类型中断.el,它提醒您定期休息一下打字,以及eldoc-mode,一种显示已定义参数或 Lisp 函数附近点的文档字符串的模式。
  • Noah Friedman wrote rlogin.el, an interface to Rlogin, type-break.el, which reminds you to take periodic breaks from typing, and eldoc-mode, a mode to show the defined parameters or the doc string for the Lisp function near point.
  • Shigeru Fukaya 为字节编译器编写了一个测试套件。
  • Shigeru Fukaya wrote a testsuite for the byte-compiler.
  • 基思·加布里尔斯基写道十六进制,一种编辑二进制文件的模式。
  • Keith Gabryelski wrote hexl.el, a mode for editing binary files.
  • Kevin Gallagher 重写并增强了 EDT 仿真,并写道 流量控制.el,一个用于处理不可抑制的 XON/XOFF 流量控制的包。
  • Kevin Gallagher rewrote and enhanced the EDT emulation, and wrote flow-ctrl.el, a package for coping with unsuppressible XON/XOFF flow control.
  • 法比安·E·加利纳 (Fabián E. Gallina) 重写python.el,Emacs 24.3 及以上版本中使用的 Python 编程语言的主要模式。
  • Fabián E. Gallina rewrote python.el, the major mode for the Python programming language used in Emacs 24.3 onwards.
  • Kevin Gallo 添加了对 Windows NT 的多帧支持并写道 w32-win.el,支持MS-Windows窗口系统的功能。
  • Kevin Gallo added multiple-frame support for Windows NT and wrote w32-win.el, support functions for the MS-Windows window system.
  • 胡安·莱昂·拉霍斯·加西亚写道wdired.el,一个通过直接编辑 Dired 缓冲区来执行文件操作的包。
  • Juan León Lahoz García wrote wdired.el, a package for performing file operations by directly editing Dired buffers.
  • Howard Gayle 为显示表和案例表编写了大部分 C 和 Lisp 代码。他还写了rot13.el,显示用凯撒密码编码的缓冲区的纯文本形式的命令; vt100-led.el,用于控制 VT100 兼容终端上 LED 的封装;以及对 ISO-8859 欧洲字符集的大部分支持(包括iso-ascii.el, iso-insert.el,iso-swed.el, iso-syntax.el,iso-transl.el, 和瑞典语网站)。
  • Howard Gayle wrote much of the C and Lisp code for display tables and case tables. He also wrote rot13.el, a command to display the plain-text form of a buffer encoded with the Caesar cipher; vt100-led.el, a package for controlling the LEDs on VT100-compatible terminals; and much of the support for ISO-8859 European character sets (which includes iso-ascii.el, iso-insert.el, iso-swed.el, iso-syntax.el, iso-transl.el, and swedish.el).
  • Stephen Gildea 制作了 Emacs 快速参考卡,并为时间戳.el,一个用于维护文件中最后更改时间戳的包。
  • Stephen Gildea made the Emacs quick reference card, and made many contributions for time-stamp.el, a package for maintaining last-change time stamps in files.
  • 朱利安·吉尔斯写道gnus-ml.el,Gnus 的邮件列表次要模式。
  • Julien Gilles wrote gnus-ml.el, a mailing list minor mode for Gnus.
  • David Gillespie 编写了 Common Lisp 兼容包; Calc,一种高级计算器和数学工具,由 Jay Belanger 维护和开发;完整.el,部分完成机制;和edmacro.el,用于编辑键盘宏的包。
  • David Gillespie wrote the Common Lisp compatibility packages; Calc, an advanced calculator and mathematical tool, since maintained and developed by Jay Belanger; complete.el, a partial completion mechanism; and edmacro.el, a package for editing keyboard macros.
  • 鲍勃·格利克斯坦写道sregex.el,一种使用类似 Lisp 的语法编写正则表达式的工具。
  • Bob Glickstein wrote sregex.el, a facility for writing regexps using a Lisp-like syntax.
  • 鲍里斯·戈多夫斯基写道避免.el,一个使鼠标光标远离文本光标的包;影子文件.el,一个用于在多个地方保存相同文件副本的软件包; 格式.el,用于读写各种格式文件的包;丰富的.el,用于保存文件中文本属性的包;面菜单.el,用于指定面孔的包;和 描述文本.el,描述文本和字符属性。
  • Boris Goldowsky wrote avoid.el, a package to keep the mouse cursor out of the way of the text cursor; shadowfile.el, a package for keeping identical copies of files in more than one place; format.el, a package for reading and writing files in various formats; enriched.el, a package for saving text properties in files; facemenu.el, a package for specifying faces; and descr-text.el, describing text and character properties.
  • 米开朗基罗·格里尼写道ffap.el它访问一个文件,从缓冲区中获取文件名。
  • Michelangelo Grigni wrote ffap.el which visits a file, taking the file name from the buffer.
  • 奥德·格里彭斯坦写道dcl-模式.el用于编辑 DCL 命令文件。
  • Odd Gripenstam wrote dcl-mode.el for editing DCL command files.
  • 迈克尔·格施温德写道iso-cvt.el,一个用于在 ISO 8859-1 字符集与 TeX 和 net trend 使用的 非ASCII字符符号之间进行转换的包。
  • Michael Gschwind wrote iso-cvt.el, a package to convert between the ISO 8859-1 character set and the notations for non-ASCII characters used by TeX and net tradition.
  • 巴斯蒂安·盖里写道gnus-bookmark.el, 对 Gnus 的书签支持;以及帮助维持组织模式 (qv)。
  • Bastien Guerry wrote gnus-bookmark.el, bookmark support for Gnus; as well as helping to maintain Org mode (q.v.).
  • 亨利·纪尧姆写道查找文件.el,一个用于访问与当前访问的文件相关的文件的包。
  • Henry Guillaume wrote find-file.el, a package to visit files related to the currently visited file.
  • Doug Gwyn 编写了可移植的alloca实现。
  • Doug Gwyn wrote the portable alloca implementation.
  • Ken'ichi Handa 实现了大部分对国际字符集的支持,并编写了大部分 Emacs 23 字体处理代码。他还写了复合材料.el,提供了显示时自动组合字符的小模式; isearch-x.el,用于搜索非ASCII 文本的工具;和ps-bdf.el,一种 BDF 字体,支持在 PostScript 打印机上打印非ASCII文本。他与高桥直人一起写了鹌鹑.el,一种用于从ASCII键盘输入非ASCII文本的输入工具。
  • Ken’ichi Handa implemented most of the support for international character sets, and wrote most of the Emacs 23 font handling code. He also wrote composite.el, which provides a minor mode that composes characters automatically when they are displayed; isearch-x.el, a facility for searching non-ASCII text; and ps-bdf.el, a BDF font support for printing non-ASCII text on a PostScript printer. Together with Naoto Takahashi, he wrote quail.el, an input facility for typing non-ASCII text from an ASCII keyboard.
  • 杰斯珀·哈德写道yenc.el,用于解码日元编码消息。
  • Jesper Harder wrote yenc.el, for decoding yenc encoded messages.
  • Alexandru Harsanyi 编写了一个用于访问 SOAP Web 服务的库。
  • Alexandru Harsanyi wrote a library for accessing SOAP web services.
  • K.肖恩·哈特曼写道历史故事网echistory.el,用于浏览命令历史列表的软件包;电.el助手.el,它提供了替代的命令循环和适当的帮助设施;emacsbug.el,用于报告 Emacs bug 的包;图片.el,一种编辑ASCII图片的模式 ;和查看.el,一个用于读取文件和缓冲区而不对其进行编辑的包。
  • K. Shane Hartman wrote chistory.el and echistory.el, packages for browsing command history lists; electric.el and helper.el, which provide an alternative command loop and appropriate help facilities; emacsbug.el, a package for reporting Emacs bugs; picture.el, a mode for editing ASCII pictures; and view.el, a package for perusing files and buffers without editing them.
  • 约翰·海德曼写道鼠标复制.el鼠标拖动.el,它提供替代的基于鼠标的编辑和滚动功能。
  • John Heidemann wrote mouse-copy.el and mouse-drag.el, which provide alternative mouse-based editing and scrolling features.
  • 乔恩·K·海伦写道utf7.el、支持邮件安全的Unicode转换格式。
  • Jon K Hellan wrote utf7.el, support for mail-safe transformation format of Unicode.
  • Karl Heuer 编写了原始的 blessmail 脚本,实现了 intangible文本属性,并重新排列了类型的结构 Lisp_Object以允许更多的数据位。
  • Karl Heuer wrote the original blessmail script, implemented the intangible text property, and rearranged the structure of the Lisp_Object type to allow for more data bits.
  • Manabu Higashida 将 Emacs 移植到 MS-DOS。
  • Manabu Higashida ported Emacs to MS-DOS.
  • 安德斯·霍尔斯特写道嬉皮士-exp.el,一个多功能的完成和扩展包。
  • Anders Holst wrote hippie-exp.el, a versatile completion and expansion package.
  • Tassilo Horn 编写了 DocView 模式,允许查看 PDF、PostScript 和 DVI 文档。
  • Tassilo Horn wrote DocView mode, allowing viewing of PDF, PostScript and DVI documents.
  • Khaled Hosny、Yamamoto Mitsuharu 和 Eli Zaretskii 使用 HarfBuzz for Emacs 实现了文本整形。
  • Khaled Hosny, Yamamoto Mitsuharu, and Eli Zaretskii implemented text shaping with HarfBuzz for Emacs.
  • 乔金·霍夫写道html2text.el,一个 html 到纯文本转换器。
  • Joakim Hove wrote html2text.el, a html to plain text converter.
  • 丹尼斯·豪写道浏览网址.el,用于调用 WWW 浏览器显示 URL 的包。
  • Denis Howe wrote browse-url.el, a package for invoking a WWW browser to display a URL.
  • Lars Magne Ingebrigtsen 是 Emacs 27.2 到 29.1 的 Emacs(共同)维护者。他对 Gnus 新闻阅读器进行了重大重新设计,并编写了其中的许多部分。其中有几个现在是 Emacs 的通用组件,包括:域名解析系统用于域名服务查找; 格式规范.el用于格式化任意格式字符串; 网络资源网用于解析.netrc文件;和 时间-日期.el用于一般日期和时间处理。他还写了网络流.el,用于打开网络进程; url-queue.el,用于控制 URL 的并行下载;并实现了 libxml2 支持。他还写了eww.el,一个 Emacs Lisp 网络浏览器;并实现了原生 zlib 解压。 Gnus 组件的编写者还有:Nagy Andras、David Blacka、Scott Byer、Ludovic Courtès、Julien Danjou、Kevin Greiner、Kai Großjohann、Joe Hildebrand、Paul Jarc、Simon Josefsson、Sascha Lüdecke、David Moore、Jim Radford、Benjamin Rutt 、Raymond Scholz、Thomas Steffen、Reiner Steib、Jan Tatarik、Didier Verna、Ilja Weis、Katsumi Yamaoka、Teodor Zlatanov 等(请参阅Gnus 手册中的贡献者)。
  • Lars Magne Ingebrigtsen was the Emacs (co-)maintainer from Emacs 27.2 to 29.1. He did a major redesign of the Gnus news-reader and wrote many of its parts. Several of these are now general components of Emacs, including: dns.el for Domain Name Service lookups; format-spec.el for formatting arbitrary format strings; netrc.el for parsing of .netrc files; and time-date.el for general date and time handling. He also wrote network-stream.el, for opening network processes; url-queue.el, for controlling parallel downloads of URLs; and implemented libxml2 support. He also wrote eww.el, an Emacs Lisp web browser; and implemented native zlib decompression. Components of Gnus have also been written by: Nagy Andras, David Blacka, Scott Byer, Ludovic Courtès, Julien Danjou, Kevin Greiner, Kai Großjohann, Joe Hildebrand, Paul Jarc, Simon Josefsson, Sascha Lüdecke, David Moore, Jim Radford, Benjamin Rutt, Raymond Scholz, Thomas Steffen, Reiner Steib, Jan Tatarik, Didier Verna, Ilja Weis, Katsumi Yamaoka, Teodor Zlatanov, and others (see Contributors in the Gnus Manual).
  • Andrew Innes 对 MS-Windows 支持做出了巨大贡献。
  • Andrew Innes contributed extensively to the MS-Windows support.
  • Seiichiro Inoue 改进了 Emacs 的 XIM 支持。
  • Seiichiro Inoue improved Emacs’s XIM support.
  • 菲利普·杰克逊写道查找cmd.el,构建find 命令行。
  • Philip Jackson wrote find-cmd.el, to build a find command-line.
  • 乌尔夫·贾斯珀写道calendar.el,一个用于将 Emacs 日记条目与 iCalendar 格式相互转换的包; 新贴纸.el,一个基于 RSS 和 Atom 的 Newsticker;和 泡泡.el,一款益智游戏。
  • Ulf Jasper wrote icalendar.el, a package for converting Emacs diary entries to and from the iCalendar format; newsticker.el, an RSS and Atom based Newsticker; and bubbles.el, a puzzle game.
  • 凯尔·琼斯写道生活.el,一个玩康威生命游戏的包。
  • Kyle Jones wrote life.el, a package to play Conway’s Game of Life.
  • 特里·琼斯写道影子.el,一个包,用于在某些 Lisp 文件遮盖另一个文件时查找潜在的加载路径问题。
  • Terry Jones wrote shadow.el, a package for finding potential load-path problems when some Lisp file shadows another.
  • 西蒙·约瑟夫森写道dns-模式.el,域名系统主文件的编辑模式;数字电子报,域名系统接口; 流动填充.el,用于解释消息中 RFC2646 格式文本的包;边缘.el,定制流苏的包; imap.el,一个用于与 IMAP 服务器对话的 Emacs Lisp 库; 密码缓存.el、密码读取器;尼玛普,Gnus 的 IMAP 后端;url-imap.el对于 URL 库; rfc2104.el,散列消息认证设施; Gnus S/MIME 和 Sieve 组件;和tls.elstarttls.el 用于传输层安全协议。
  • Simon Josefsson wrote dns-mode.el, an editing mode for Domain Name System master files; dig.el, a Domain Name System interface; flow-fill.el, a package for interpreting RFC2646 formatted text in messages; fringe.el, a package for customizing the fringe; imap.el, an Emacs Lisp library for talking to IMAP servers; password-cache.el, a password reader; nnimap.el, the IMAP back-end for Gnus; url-imap.el for the URL library; rfc2104.el, a hashed message authentication facility; the Gnus S/MIME and Sieve components; and tls.el and starttls.el for the Transport Layer Security protocol.
  • 阿恩·约根森写道乳胶,一个自动猜测 LaTeX 文件中正确编码系统的包。
  • Arne Jørgensen wrote latexenc.el, a package to automatically guess the correct coding system in LaTeX files.
  • 亚历山大·朱利亚德写道vc-git.el、支持Git版本控制系统。
  • Alexandre Julliard wrote vc-git.el, support for the Git version control system.
  • 加贺谷友二实施smtpmail.el,用于通过 SMTP 发送邮件。
  • Tomoji Kagatani implemented smtpmail.el, used for sending out mail with SMTP.
  • Stefan Kangas 从 29.2 开始担任 Emacs(联合)维护者。
  • Stefan Kangas was the Emacs (co-)maintainer from 29.2 onwards.
  • 伊万·卡尼斯写道vc-hg.el,支持Mercurial版本控制系统。
  • Ivan Kanis wrote vc-hg.el, support for the Mercurial version control system.
  • 亨利·考茨写道围兜模型.elrefer,一种维护与(troff 版本)和lookbib、以及兼容的书目数据库的模式refbib.el,一个将这些数据库转换为 LaTeX 文本格式化包使用的格式的包。
  • Henry Kautz wrote bib-mode.el, a mode for maintaining bibliography databases compatible with refer (the troff version) and lookbib, and refbib.el, a package to convert those databases to the format used by the LaTeX text formatting package.
  • Taichi Kawabata 添加了对梵文文字和印度语言的支持,并写道ucs-标准化.el用于 Unicode 标准化。
  • Taichi Kawabata added support for Devanagari script and the Indian languages, and wrote ucs-normalize.el for Unicode normalization.
  • Taro Kawagishi 在 Lisp 中实现了 MD4 消息摘要算法;并写道ntlm.elsasl-ntlm.el用于 NT LanManager 身份验证支持。
  • Taro Kawagishi implemented the MD4 Message Digest Algorithm in Lisp; and wrote ntlm.el and sasl-ntlm.el for NT LanManager authentication support.
  • 霍华德·凯伊写道排序.el,对 Emacs 缓冲区中的文本进行排序的命令。
  • Howard Kaye wrote sort.el, commands to sort text in Emacs buffers.
  • Michael Kifer 编写了、 、和程序ediff的交互式界面 ; Viper,VI 编辑器的模拟器。 diffpatchmerge
  • Michael Kifer wrote ediff, an interactive interface to the diff, patch, and merge programs; and Viper, an emulator of the VI editor.
  • 理查德·金 (Richard King) 编写了第一个版本用户锁.el文件锁.c,它为多个用户编辑同一文件提供简单的支持。他还编写了最初的版本 独特的.el,一种通过将文件名的一部分添加到缓冲区名称来使缓冲区名称唯一的工具。
  • Richard King wrote the first version of userlock.el and filelock.c, which provide simple support for multiple users editing the same file. He also wrote the initial version of uniquify.el, a facility to make buffer names unique by adding parts of the file’s name to the buffer name.
  • 彼得·克莱维格写道ps-模式.el,一种用于编辑 PostScript 文件并在 Emacs 中交互运行 PostScript 解释器的模式。
  • Peter Kleiweg wrote ps-mode.el, a mode for editing PostScript files and running a PostScript interpreter interactively from within Emacs.
  • Karel Klíč 贡献了 SELinux 支持,用于在备份和复制时保留文件的安全增强型 Linux 上下文。
  • Karel Klíč contributed SELinux support, for preserving the Security-Enhanced Linux context of files on backup and copy.
  • 小林修平写道hex-util.el,用于对十六进制字符串进行操作;并支持 HMAC(用于消息身份验证的密钥散列)。
  • Shuhei Kobayashi wrote hex-util.el, for operating on hexadecimal strings; and support for HMAC (Keyed-Hashing for Message Authentication).
  • 帕维尔·科比亚科夫写道Flymake.el,用于执行即时语法检查的次要模式。
  • Pavel Kobyakov wrote flymake.el, a minor mode for performing on-the-fly syntax checking.
  • 大卫·M·科佩尔曼写道hi-lock.el,一种用于交互式自动突出显示部分缓冲区文本的次要模式。
  • David M. Koppelman wrote hi-lock.el, a minor mode for interactive automatic highlighting of parts of the buffer text.
  • 小关义则写道图像库,用于显示内联图像的次要模式。
  • Koseki Yoshinori wrote iimage.el, a minor mode for displaying inline images.
  • 罗伯特·克拉维茨 (Robert Krawitz) 撰写了原著xmenu.c,Emacs 弹出菜单支持的一部分。
  • Robert Krawitz wrote the original xmenu.c, part of Emacs’s pop-up menu support.
  • 塞巴斯蒂安·克雷默 (Sebastian Kremer) 撰写dired-mode,劳伦斯·R·多德 (Lawrence R. Dodd) 贡献。他还写了ls-lisp.ells,针对没有ls标准程序 的平台的命令的 Lisp 模拟 。
  • Sebastian Kremer wrote dired-mode, with contributions by Lawrence R. Dodd. He also wrote ls-lisp.el, a Lisp emulation of the ls command for platforms that don’t have ls as a standard program.
  • 大卫·卡格达尔写道节奏.el,为轻松插入样板文本和其他常见结构提供支持。
  • David Kågedal wrote tempo.el, providing support for easy insertion of boilerplate text and other common constructions.
  • 伊戈尔·库兹明写道cnv.el,为静态范围的 Emacs lisp 提供闭包转换。
  • Igor Kuzmin wrote cconv.el, providing closure conversion for statically scoped Emacs lisp.
  • 丹尼尔·拉利伯特写道edebug.el,Emacs Lisp 的源代码级调试器;cl-规格.el,帮助edebug 调试使用 David Gillespie 的 Common Lisp 支持编写的代码的规范;和 isearch.el,Emacs 的增量搜索次要模式。他还合写了赫迪夫网站(qv)。
  • Daniel LaLiberte wrote edebug.el, a source-level debugger for Emacs Lisp; cl-specs.el, specifications to help edebug debug code written using David Gillespie’s Common Lisp support; and isearch.el, Emacs’s incremental search minor mode. He also co-wrote hideif.el (q.v.).
  • 卡尔·兰德斯特罗姆和丹尼尔·科拉西奥内写道js.el,一种编辑 JavaScript 的模式。
  • Karl Landstrom and Daniel Colascione wrote js.el, a mode for editing JavaScript.
  • Vinicius Jose Latorre 编写了 Emacs 打印工具,以及 ps-print(与 Jim Thompson、Jacques Duthen 和 Kenichi Handa)一个用于将 Emacs 缓冲区漂亮地打印到 PostScript 打印机的包; 德利姆大学,一个将文本排列成列的包; ebnf2ps.el,一个将 EBNF 语法转换为可以打印到 PostScript 打印机的语法图表的包;和 空白.el,一个检测并清理文件中多余空白的包(基于 Rajesh Vaidheeswarran 的早期版本构建)。
  • Vinicius Jose Latorre wrote the Emacs printing facilities, as well as ps-print (with Jim Thompson, Jacques Duthen, and Kenichi Handa), a package for pretty-printing Emacs buffers to PostScript printers; delim-col.el, a package to arrange text into columns; ebnf2ps.el, a package that translates EBNF grammar to a syntactic chart that can be printed to a PostScript printer; and whitespace.el, a package that detects and cleans up excess whitespace in a file (building on an earlier version by Rajesh Vaidheeswarran).
  • 弗雷德里克·莱皮德写道展开.el,它使用缩写机制来插入编程结构。
  • Frederic Lepied wrote expand.el, which uses the abbrev mechanism for inserting programming constructs.
  • 彼得·利詹伯格写道elint.el,用于 Emacs Lisp 程序的 Lint 风格的代码检查器。
  • Peter Liljenberg wrote elint.el, a Lint-style code checker for Emacs Lisp programs.
  • 拉斯·林德伯格写道msb.el,为缓冲区选择提供了更灵活的菜单;合写伊米努.el(qv);并重写了 达布雷夫.el,最初由唐·莫里森撰写。
  • Lars Lindberg wrote msb.el, which provides more flexible menus for buffer selection; co-wrote imenu.el (q.v.); and rewrote dabbrev.el, originally written by Don Morrison.
  • 安德斯·林格伦写道自动恢复.el,一个用于自动恢复 Emacs 访问的、磁盘上已更改的文件的包; 警告网,一个用于突出显示可疑 C 和 C++ 构造的包;和关注.el,一种次要模式,用于同步显示相同缓冲区的窗口。
  • Anders Lindgren wrote autorevert.el, a package for automatically reverting files visited by Emacs that were changed on disk; cwarn.el, a package to highlight suspicious C and C++ constructs; and follow.el, a minor mode to synchronize windows that show the same buffer.
  • 托马斯·林克写道文件集.el,用于处理文件集的包。
  • Thomas Link wrote filesets.el, a package for handling sets of files.
  • 尤里·林科夫写道米搜索网站,将 isearch 扩展到多缓冲区搜索;中的代码文件-x.el用于处理文件和目录局部变量;以及info-finder创建软件包关键字虚拟信息手册的功能。他还实现了选项卡栏和窗口选项卡行,并在 I-search 中添加了许多增强和改进。
  • Juri Linkov wrote misearch.el, extending isearch to multi-buffer searches; the code in files-x.el for handling file- and directory-local variables; and the info-finder feature that creates a virtual Info manual of package keywords. He also implemented the Tab Bar and window tab-lines, and added numerous enhancements and improvements in I-search.
  • 刘里奥写道pcmpl-x.el,为各种外部工具提供补全;并改进了 Emacs 24.4 中对 Octave 的支持。
  • Leo Liu wrote pcmpl-x.el, providing completion for miscellaneous external tools; and revamped support for Octave in Emacs 24.4.
  • Károly Lőrentey 编写了多终端代码,它允许 Emacs 同时在图形和文本终端上运行。
  • Károly Lőrentey wrote the multi-terminal code, which allows Emacs to run on graphical and text terminals simultaneously.
  • 马丁·洛伦森写道vc-annotate.el,支持版本控制注解。
  • Martin Lorentzon wrote vc-annotate.el, support for version control annotation.
  • Dave Love 编写了许多涉及 Unicode 支持和 Latin-N 统一的代码。他添加了对许多编码系统的支持,包括各种 UTF-7 和 UTF-16 编码系统。他还编写了 autoarg-mode一种全局次要模式,其中数字键提供前缀参数;autoarg-kp-mode,它将键盘数字键重新定义为数字参数;自动配置文件,一种编辑Autoconf文件的模式;cfengine.el,一种编辑Cfengine文件的模式; elide-head.el,一个用于从文件头中删除样板文本的包;hl-line.el,一种次要模式,用于突出显示当前窗口中点所在的线;大写单词.el,运动的次要模式CapitalizedWordIdentifierslatin1-disp.el,一个软件包,可让您通过设置适当的显示表在 Latin-1 终端上显示 ISO 8859 字符;的版本 python.elEmacs 24.3 之前使用;笑脸.el,显示笑脸的设施;符号编译器,用于执行依赖于模式的符号完成的库;基准测试.el 用于计时代码执行;和工具栏.el,一种控制 Emacs 工具栏显示的模式。他与里卡多·穆里 (Riccardo Murri) 一起写了 vc-bzr.el、支持Bazaar版本控制系统。
  • Dave Love wrote much of the code dealing with Unicode support and Latin-N unification. He added support for many coding systems, including the various UTF-7 and UTF-16 coding systems. He also wrote autoarg-mode, a global minor mode whereby digit keys supply prefix arguments; autoarg-kp-mode, which redefines the keypad numeric keys to digit arguments; autoconf.el, a mode for editing Autoconf files; cfengine.el, a mode for editing Cfengine files; elide-head.el, a package for eliding boilerplate text from file headers; hl-line.el, a minor mode for highlighting the line in the current window on which point is; cap-words.el, a minor mode for motion in CapitalizedWordIdentifiers; latin1-disp.el, a package that lets you display ISO 8859 characters on Latin-1 terminals by setting up appropriate display tables; the version of python.el used prior to Emacs 24.3; smiley.el, a facility for displaying smiley faces; sym-comp.el, a library for performing mode-dependent symbol completion; benchmark.el for timing code execution; and tool-bar.el, a mode to control the display of the Emacs tool bar. With Riccardo Murri he wrote vc-bzr.el, support for the Bazaar version control system.
  • Eric Ludlam 编写了 Speedbar 软件包;检查文档.el,用于检查 Emacs Lisp 程序中的文档字符串;dframe.el、提供专用框架支撑模式;ezimage.el,一种将图像放置在文本上的通用方法;图表.el用于绘制条形图等;和 EIEIO(Emacs 解释对象的增强实现)包。他也是 CEDET(Emacs 开发环境工具集合)包的主要作者。扬·莫林根 (Jan Moringen)、大卫·庞塞 (David Ponce) 和乔金·维罗纳 (Joakim Verona) 也创作了部分作品。
  • Eric Ludlam wrote the Speedbar package; checkdoc.el, for checking doc strings in Emacs Lisp programs; dframe.el, providing dedicated frame support modes; ezimage.el, a generalized way to place images over text; chart.el for drawing bar charts etc.; and the EIEIO (Enhanced Implementation of Emacs Interpreted Objects) package. He was also the main author of the CEDET (Collection of Emacs Development Environment Tools) package. Portions were also written by Jan Moringen, David Ponce, and Joakim Verona.
  • 罗兰·麦格拉思写道编译.el(自 Daniel Pfeiffer 更新以来),一个用于在缓冲区中运行编译,然后访问错误消息中报告的位置的包;电子标签,一个用于跳转到函数定义并在 a 中提到的所有文件中搜索或替换的包标签文件;与塞巴斯蒂安·克莱默查找dired.el,用于dired对程序的输出使用命令findgrep.el用于运行 grep命令;地图-ynp.el,通用布尔提问器;自动加载.el,提供自动加载文件的半自动维护。
  • Roland McGrath wrote compile.el (since updated by Daniel Pfeiffer), a package for running compilations in a buffer, and then visiting the locations reported in error messages; etags.el, a package for jumping to function definitions and searching or replacing in all the files mentioned in a TAGS file; with Sebastian Kremer find-dired.el, for using dired commands on output from the find program; grep.el for running the grep command; map-ynp.el, a general purpose boolean question-asker; autoload.el, providing semi-automatic maintenance of autoload files.
  • Alan Mackenzie 在 CC 模式中编写了集成的 AWK 支持,并从 Emacs 22 开始维护 CC 模式。
  • Alan Mackenzie wrote the integrated AWK support in CC Mode, and maintained CC Mode from Emacs 22 onwards.
  • Michael McNamara 和 Wilson Snyder 编写了 Verilog 模式。
  • Michael McNamara and Wilson Snyder wrote Verilog mode.
  • 克里斯托弗·J·马德森写道解密.el,一个用于破解简单替换密码的包。
  • Christopher J. Madsen wrote decipher.el, a package for cracking simple substitution ciphers.
  • 尼尔·M·马格写道应用程序,用于通知用户他们的约会的功能。它查找包使用的日记文件中记录的约会calendar
  • Neil M. Mager wrote appt.el, functions to notify users of their appointments. It finds appointments recorded in the diary files used by the calendar package.
  • 肯·曼海默写道allout.el,一种用于操作和格式化轮廓的模式,以及完整版,它在迷你缓冲区中提供增量完成反馈。
  • Ken Manheimer wrote allout.el, a mode for manipulating and formatting outlines, and icomplete.el, which provides incremental completion feedback in the minibuffer.
  • 比尔·曼写道perl-mode.el,一种编辑 Perl 代码的模式。
  • Bill Mann wrote perl-mode.el, a mode for editing Perl code.
  • 布莱恩·马里克和丹尼尔·拉利伯特写道赫迪夫网站,支持隐藏 C#ifdef子句中选定的代码。
  • Brian Marick and Daniel LaLiberte wrote hideif.el, support for hiding selected code within C #ifdef clauses.
  • 西蒙·马歇尔写道正则表达式-opt.el,它从字符串列表生成正则表达式;以及快速锁定和惰性锁定字体锁定支持模式。他还延长了comint.el外壳.el,最初由奥林·希弗斯撰写。
  • Simon Marshall wrote regexp-opt.el, which generates a regular expression from a list of strings; and the fast-lock and lazy-lock font-lock support modes. He also extended comint.el and shell.el, originally written by Olin Shivers.
  • Bengt Martensson、Dirk Herrmann、Marc Shapiro、Mike Newton、Aaron Larson 和 Stefan Schoef 写道图书馆,一种编辑 BibTeX 参考书目文件的模式。
  • Bengt Martensson, Dirk Herrmann, Marc Shapiro, Mike Newton, Aaron Larson, and Stefan Schoef, wrote bibtex.el, a mode for editing BibTeX bibliography files.
  • 查理·马丁写道自动插入.el,它提供自动模式敏感的文本插入到新文件中。
  • Charlie Martin wrote autoinsert.el, which provides automatic mode-sensitive insertion of text into new files.
  • Yukihiro Matsumoto 和 Nobuyoshi Nakada 编写了 Ruby-mode。
  • Yukihiro Matsumoto and Nobuyoshi Nakada wrote Ruby-mode.
  • Tomohiro Matsuyama 编写了原生 Elisp 分析器。
  • Tomohiro Matsuyama wrote the native Elisp profiler.
  • 托马斯·梅写道黑盒.el,传统黑盒游戏的一个版本。
  • Thomas May wrote blackbox.el, a version of the traditional blackbox game.
  • 大卫·梅金森写道派生.el,它允许人们通过继承现有主要模式的键绑定和命令来定义新的主要模式。
  • David Megginson wrote derived.el, which allows one to define new major modes by inheriting key bindings and commands from existing major modes.
  • Jimmy Aguilar Mena 编写了支持面部属性的代码:extend,并实现了可选 display-fill-column-indicator功能。
  • Jimmy Aguilar Mena wrote the code to support the :extend face attribute, and also implemented the optional display-fill-column-indicator feature.
  • 威尔·门加里尼写道重复.el,一个命令,用于重复前面的命令及其参数。
  • Will Mengarini wrote repeat.el, a command to repeat the preceding command with its arguments.
  • 理查德·姆利纳里克写道cl-缩进.el,用于缩进 Common Lisp 代码的包;ebuff-menu.el,一个用于缓冲区列表的电子浏览器;电子帮助网站,用于浏览帮助屏幕的绑定;和rfc822.el,用于邮件消息和新闻文章(Internet RFC 822 及其后续版本)中使用的格式的电子邮件地址的解析器。
  • Richard Mlynarik wrote cl-indent.el, a package for indenting Common Lisp code; ebuff-menu.el, an electric browser for buffer listings; ehelp.el, bindings for browsing help screens; and rfc822.el, a parser for E-mail addresses in the format used in mail messages and news articles (Internet RFC 822 and its successors).
  • 从 Emacs 21 开发之初到 21.1 发布,Gerd Möllmann 一直是 Emacs 维护者。他编写了从 Emacs 21 开始使用的新显示引擎和异步计时器设施。他还编写了ebrowseC++浏览器; 吉特洛克.el、Just-In-Time 字体锁定支持模式; 工具提示.el,用于显示工具提示的包; 作者.el,一个用于维护的包作者文件;和接收器,正则表达式构造函数。
  • Gerd Möllmann was the Emacs maintainer from the beginning of Emacs 21 development until the release of 21.1. He wrote the new display engine used from Emacs 21 onwards, and the asynchronous timers facility. He also wrote ebrowse, the C++ browser; jit-lock.el, the Just-In-Time font-lock support mode; tooltip.el, a package for displaying tooltips; authors.el, a package for maintaining the AUTHORS file; and rx.el, a regular expression constructor.
  • Stefan Monnier 从 Emacs 23 一直担任 Emacs(联合)维护者,直到 25.1 开发后期。他向 VC 添加了对 Arch 和 Subversion 的支持,重新编写了 Emacs 服务器的大部分内容以使用内置网络原语,并为 Emacs 23 重新编写了 abbrev 和 minibuffer 完成代码。他还编写了PCL-CVS目录级前端 。结束CVS版本控制系统; 揭示.el,一种自动显示不可见文本的小模式;smerge-mode.el,解决冲突的次要模式diff3差异模型.el,一种用于查看和编辑上下文差异的模式;CSS模式.el用于层叠样式表; bibtex-style.el对于 BibTeX 样式文件;mpc.el,音乐播放器守护进程 (MPD) 的客户端;斯密埃尔,一个通用的缩进引擎;和pcase.el,实现 ML 风格的模式匹配。在 Emacs 24 中,他集成了词法绑定代码,清理了 CL 命名空间(使得可以在运行时使用 CL 函数),向核心 Emacs Lisp 添加通用变量,并实现了新的轻量级建议机制。
  • Stefan Monnier was the Emacs (co-)maintainer from Emacs 23 until late in the development of 25.1. He added support for Arch and Subversion to VC, re-wrote much of the Emacs server to use the built-in networking primitives, and re-wrote the abbrev and minibuffer completion code for Emacs 23. He also wrote PCL-CVS, a directory-level front end to the CVS version control system; reveal.el, a minor mode for automatically revealing invisible text; smerge-mode.el, a minor mode for resolving diff3 conflicts; diff-mode.el, a mode for viewing and editing context diffs; css-mode.el for Cascading Style Sheets; bibtex-style.el for BibTeX Style files; mpc.el, a client for the Music Player Daemon (MPD); smie.el, a generic indentation engine; and pcase.el, implementing ML-style pattern matching. In Emacs 24, he integrated the lexical binding code, cleaned up the CL namespace (making it acceptable to use CL functions at runtime), added generalized variables to core Emacs Lisp, and implemented a new lightweight advice mechanism.
  • Morioka Tomohiko 在 Gnus 和其他地方编写了几个支持 MIME 的软件包。
  • Morioka Tomohiko wrote several packages for MIME support in Gnus and elsewhere.
  • 永田森写道客户关系管理系统,一个用于完成读取多个字符串的包,以及rfc2368.el, 支持mailto: URL。
  • Sen Nagata wrote crm.el, a package for reading multiple strings with completion, and rfc2368.el, support for mailto: URLs.
  • Erik Naggum 编写了时间转换函数。他还写了 显示表.el,用于处理显示表; 邮件头.el,用于解析电子邮件标头;和 解析时间.el,用于解析时间字符串。
  • Erik Naggum wrote the time-conversion functions. He also wrote disp-table.el, for dealing with display tables; mailheader.el, for parsing email headers; and parse-time.el, for parsing time strings.
  • 高桥直人 共同编剧鹌鹑.el(qv),并写道 罗宾·埃尔,另一种输入法。
  • Takahashi Naoto co-wrote quail.el (q.v.), and wrote robin.el, another input method.
  • 托马斯·诺依曼和埃里克·雷蒙德写道制作模式.el,一种编辑 makefile 的模式。
  • Thomas Neumann and Eric Raymond wrote make-mode.el, a mode for editing makefiles.
  • 阮天赐 (Thien-Thi Nguyen) 撰写了《XPM','格努戈', 和 'ascii 艺术到 unicode' 包。他还为许多其他人做出了重大贡献,例如vc.el
  • Thien-Thi Nguyen wrote the ‘xpm’, ‘gnugo’, and ‘ascii-art-to-unicode’ packages. He also made substantial contributions to many others, such as vc.el.
  • Thien-Thi Nguyen 和 Dan Nicolaescu 写道隐藏秀,一种用于选择性显示文本块的次要模式。
  • Thien-Thi Nguyen and Dan Nicolaescu wrote hideshow.el, a minor mode for selectively displaying blocks of text.
  • Dan Nicolaescu 添加了对将 Emacs 作为守护进程运行的支持。他还写了罗马尼亚语.el,支持编辑罗马尼亚语文本; 鸢尾花-ansi.el,支持在 SGIxwshwinterm终端仿真器上运行 Emacs;和vc目录.el,显示版本控制目录的状态。
  • Dan Nicolaescu added support for running Emacs as a daemon. He also wrote romanian.el, support for editing Romanian text; iris-ansi.el, support for running Emacs on SGI’s xwsh and winterm terminal emulators; and vc-dir.el, displaying the status of version-controlled directories.
  • 赫尔沃耶·尼克希奇写道savehist.el,用于保存 Emacs 会话之间的迷你缓冲区历史记录。
  • Hrvoje Nikšić wrote savehist.el, for saving the minibuffer history between Emacs sessions.
  • 杰夫·诺登写道克米特.el,一个帮助 Kermit 拨号通信程序在 Emacs shell 缓冲区中舒适运行的包。
  • Jeff Norden wrote kermit.el, a package to help the Kermit dialup communications program run comfortably in an Emacs shell buffer.
  • 安德鲁·诺曼写道天使FTP.el,提供透明的FTP支持。
  • Andrew Norman wrote ange-ftp.el, providing transparent FTP support.
  • Kentaro Ohkouchi 创建了从 Emacs 23 开始使用的 Emacs 图标。
  • Kentaro Ohkouchi created the Emacs icons used beginning with Emacs 23.
  • 克里斯蒂安·奥勒写道埃尔特,一个用于自动回归测试的库。
  • Christian Ohler wrote ert.el, a library for automated regression testing.
  • 亚历山大·奥利瓦写道gnus-mlspl.el,一种基于组参数的邮件分割机制。
  • Alexandre Oliva wrote gnus-mlspl.el, a group params-based mail splitting mechanism.
  • 太田贵明 写道表.el,用于创建和编辑嵌入的基于文本的表格的包。
  • Takaaki Ota wrote table.el, a package for creating and editing embedded text-based tables.
  • 彼得·EJ·帕雷特写道mixal-model.el,MIX 汇编语言的编辑模式。
  • Pieter E. J. Pareit wrote mixal-mode.el, an editing mode for the MIX assembly language.
  • 大卫·皮尔森写道快速网址,一种根据点文本将 URL 插入当前缓冲区的简单方法;5x5.el,一场填满球场上所有方格的游戏。
  • David Pearson wrote quickurl.el, a simple method of inserting a URL into the current buffer based on text at point; 5x5.el, a game to fill all squares on the field.
  • 杰夫·佩克写道太阳报,sunterm 键的键绑定。
  • Jeff Peck wrote sun.el, key bindings for sunterm keys.
  • 达蒙·安东·佩梅泽尔写道河内网,河内塔拼图的动画演示。
  • Damon Anton Permezel wrote hanoi.el, an animated demonstration of the Towers of Hanoi puzzle.
  • 威廉·M·佩里写道mailcap.el(与 Lars Magne Ingebrigtsen 合作),MIME 媒体类型配置工具; mwheel.el,支持鼠标滚轮的包; (与戴夫·洛夫合写)袜子.el,Socks v5 客户端;并开发了URL包。
  • William M. Perry wrote mailcap.el (with Lars Magne Ingebrigtsen), a MIME media types configuration facility; mwheel.el, a package for supporting mouse wheels; co-wrote (with Dave Love) socks.el, a Socks v5 client; and developed the URL package.
  • 每人写的gnus-vm.el,Gnus 的 VM 接口。
  • Per Persson wrote gnus-vm.el, the VM interface for Gnus.
  • 延斯·彼得森写道查找函数.el,这使得查找 Emacs Lisp 函数或变量的源代码变得容易。
  • Jens Petersen wrote find-func.el, which makes it easy to find the source code for an Emacs Lisp function or variable.
  • 尼古拉斯·佩顿写道地图.el,一个提供映射操作函数的库,可用于列表、哈希表和数组; 后续文件,一个提供高级序列操作函数和宏的库;和thunk.el,一个提供函数和宏来延迟表单评估的库。他还在 Emacs 25 中创建了新图标。
  • Nicolas Petton wrote map.el, a library providing map-manipulation functions that work on alists, hash-table and arrays; seq.el, a library providing advanced sequence manipulation functions and macros; and thunk.el, a library providing functions and macros to delay the evaluation of forms. He also created the new icon in Emacs 25.
  • 丹尼尔·菲佛写道conf-模式.el,编辑配置文件的模式;版权.el,用于更新文件中版权声明的包;可执行文件.el,用于执行解释器脚本的包;sh脚本.el,一种编辑shell脚本的模式;骨架.el,实现一种简洁的语言来编写语句骨架;和两栏.el,用于同时两列编辑的次要模式。

    丹尼尔也重写了apropos.el(最初由 Joe Wells 编写),用于查找与正则表达式匹配的命令、函数和变量;并与吉姆·布兰迪 (Jim Blandy) 合着wyse50.el,支持 Wyse 50 终端。他还合写了编译.el (qv) 和ada-stmt.el

  • Daniel Pfeiffer wrote conf-mode.el, a mode for editing configuration files; copyright.el, a package for updating copyright notices in files; executable.el, a package for executing interpreter scripts; sh-script.el, a mode for editing shell scripts; skeleton.el, implementing a concise language for writing statement skeletons; and two-column.el, a minor mode for simultaneous two-column editing.

    Daniel also rewrote apropos.el (originally written by Joe Wells), for finding commands, functions, and variables matching a regular expression; and, together with Jim Blandy, co-authored wyse50.el, support for Wyse 50 terminals. He also co-wrote compile.el (q.v.) and ada-stmt.el.

  • 理查德·L·皮耶里写道流行3.el,Emacs 的邮局协议 (RFC 1460) 接口。
  • Richard L. Pieri wrote pop3.el, a Post Office Protocol (RFC 1460) interface for Emacs.
  • Fred Pierresteguy 和 Paul Reilly 让 Emacs 与 X Toolkit 小部件一起工作。
  • Fred Pierresteguy and Paul Reilly made Emacs work with X Toolkit widgets.
  • 弗朗索瓦·皮纳德、格雷格·麦加里和布鲁诺·海布尔写道波埃尔,支持PO翻译文件。
  • François Pinard, Greg McGary, and Bruno Haible wrote po.el, support for PO translation files.
  • 克里斯蒂安·普朗特写道soundex.el,Soundex 算法的实现,用于通过发音来比较英语单词。
  • Christian Plaunt wrote soundex.el, an implementation of the Soundex algorithm for comparing English words by their pronunciation.
  • 大卫·庞塞写道最近的el,一个将最近访问的文件菜单放在 Emacs 菜单栏中的包;标尺模型.el,一种在标题行显示标尺的次要模式;和 树部件.el,一个显示分层数据结构的包。
  • David Ponce wrote recentf.el, a package that puts a menu of recently visited files in the Emacs menu bar; ruler-mode.el, a minor mode for displaying a ruler in the header line; and tree-widget.el, a package to display hierarchical data structures.
  • 弗朗西斯科·A·波托尔蒂写道cmacexp.el,提供在文件区域上运行 C 预处理器并显示结果的命令。他还扩展并重新设计了该etags程序。
  • Francesco A. Potortì wrote cmacexp.el, providing a command which runs the C preprocessor on a region of a file and displays the results. He also expanded and redesigned the etags program.
  • 迈克尔·D·普兰奇和史蒂文·A·伍德写道Fortran.el,一种编辑 Fortran 代码的模式。
  • Michael D. Prange and Steven A. Wood wrote fortran.el, a mode for editing Fortran code.
  • 阿什温·拉姆写道参考.el,通过关键字在参考书目文件中查找参考文献的命令。
  • Ashwin Ram wrote refer.el, commands to look up references in bibliography files by keyword.
  • 埃里克·S·雷蒙德写道vc.el,RCS 和 SCCS 源代码版本控制系统的接口,与 Paul Eggert 合作;古德埃尔,一个用于在 Emacs 中运行源代码级调试器(如 GDB 和 SDB)的包;asm-模式.el,一种编辑汇编语言代码的模式; AT386.el,IBM AT 键盘的终端支持包; cookie1.el,支持幸运饼干程序,例如 yow.el幽灵.el;发现者.el,一个用于通过关键字和主题查找 Emacs Lisp 包的包;密钥交换工具,交换BSDEL键的代码;loadhist.el, 用于加载和卸载 Emacs 功能的函数; lisp-mnt.el,用于处理 Emacs Lisp 库文件中使用的特殊标头的函数;以及设置和使用 load-historylisp 变量的代码,该变量记录了加载到 Emacs 中的每个 lisp 函数的源文件。
  • Eric S. Raymond wrote vc.el, an interface to the RCS and SCCS source code version control systems, with Paul Eggert; gud.el, a package for running source-level debuggers like GDB and SDB in Emacs; asm-mode.el, a mode for editing assembly language code; AT386.el, terminal support package for IBM’s AT keyboards; cookie1.el, support for fortune-cookie programs like yow.el and spook.el; finder.el, a package for finding Emacs Lisp packages by keyword and topic; keyswap.el, code to swap the BS and DEL keys; loadhist.el, functions for loading and unloading Emacs features; lisp-mnt.el, functions for working with the special headers used in Emacs Lisp library files; and code to set and make use of the load-history lisp variable, which records the source file from which each lisp function loaded into Emacs came.
  • 爱德华·M·莱因戈尔德 (Edward M. Reingold) 在斯图尔特·克拉门 (Stewart Clamen) 的贡献下编写了日历和日记支持 (卡尔-玛雅.el)、纳楚姆·德肖维茨(希伯来报)、保罗·艾格特(cal-dst.el)、史蒂夫·菲斯克(加德克斯公司)、迈克尔·基弗(钙-x.el)、拉拉·里奥斯(cal-menu.el)和丹尼斯·B·罗格尔(太阳能电子)。 Andy Oram 为其文档做出了贡献。莱因戈尔德还做出了贡献tex-mode.el,一种编辑 TeX 文件的模式,William F. Schelter、Dick King、Stephen Gildea、Michael Prange 和 Jacob Gore 也是如此。
  • Edward M. Reingold wrote the calendar and diary support, with contributions from Stewart Clamen (cal-mayan.el), Nachum Dershowitz (cal-hebrew.el), Paul Eggert (cal-dst.el), Steve Fisk (cal-tex.el), Michael Kifer (cal-x.el), Lara Rios (cal-menu.el), and Denis B. Roegel (solar.el). Andy Oram contributed to its documentation. Reingold also contributed to tex-mode.el, a mode for editing TeX files, as did William F. Schelter, Dick King, Stephen Gildea, Michael Prange, and Jacob Gore.
  • 大卫·雷特写道邮件客户端.el它可以通过系统指定的邮件客户端发送邮件。
  • David Reitter wrote mailclient.el which can send mail via the system’s designated mail client.
  • 亚历克斯·雷辛斯基写道which-func.el,一种在模式行中显示当前函数名称的模式。
  • Alex Rezinsky wrote which-func.el, a mode that shows the name of the current function in the mode line.
  • 罗布·里佩尔写道vt-control.el,为DEC VT线的终端提供一些控制功能。
  • Rob Riepel wrote vt-control.el, providing some control functions for the DEC VT line of terminals.
  • 尼克·罗伯茨写道t-mouse.el,用于文本终端中的鼠标支持;和gdb-ui.el,GDB 的图形用户界面。他与德米特里·朱斯 (Dmitry Dzhus) 一起撰写了gdb-mi.el,后继者 gdb-ui.el
  • Nick Roberts wrote t-mouse.el, for mouse support in text terminals; and gdb-ui.el, a graphical user interface to GDB. Together with Dmitry Dzhus, he wrote gdb-mi.el, the successor to gdb-ui.el.
  • 丹尼·鲁森达尔实施手写.el,将文本转换为“手写”。
  • Danny Roozendaal implemented handwrite.el, which converts text into “handwriting”.
  • 马库斯·罗斯特写道客户测试.el,一个定制的测试框架。
  • Markus Rost wrote cus-test.el, a testing framework for customize.
  • 吉列尔莫·J·罗萨斯写道方案.el,一种用于编辑Scheme和DSSSL代码的模式。
  • Guillermo J. Rozas wrote scheme.el, a mode for editing Scheme and DSSSL code.
  • Martin Rudalics 在 Emacs 24 中改进了显示缓冲区处理;并实现了窗口和框架的像素级调整大小。
  • Martin Rudalics implemented improved display-buffer handling in Emacs 24; and implemented pixel-wise resizing of windows and frames.
  • 伊瓦尔·鲁梅尔霍夫写道赢家.el,它记录最近的窗口配置,以便您可以返回到它们。
  • Ivar Rummelhoff wrote winner.el, which records recent window configurations so you can move back to them.
  • Jason Rumney 将 Emacs 21 显示引擎移植到 MS-Windows,并对 Emacs 的 MS-Windows 移植做出了广泛贡献。
  • Jason Rumney ported the Emacs 21 display engine to MS-Windows, and has contributed extensively to the MS-Windows port of Emacs.
  • Wolfgang Rupprecht 编写了 Emacs 19 的浮点支持(包括 浮动-sup.elfloatfns.c)。
  • Wolfgang Rupprecht wrote Emacs 19’s floating-point support (including float-sup.el and floatfns.c).
  • 凯文·赖德写道信息外部参照.el,一个用于检查信息文件中引用的库。
  • Kevin Ryde wrote info-xref.el, a library for checking references in Info files.
  • 菲尔·桑蒂写道这么久了。el,一组功能,可以更轻松地编辑具有很长行的文件。
  • Phil Sainty wrote so-long.el, a set of features for easier editing of files with very long lines.
  • 詹姆斯·B·塞勒姆 (James B. Salem) 和布鲁斯特·卡勒 (Brewster Kahle) 写道完成.el,提供动态单词补全。
  • James B. Salem and Brewster Kahle wrote completion.el, providing dynamic word completion.
  • 霍尔格·绍尔写道财富网,一个在消息签名中使用 Fortune 的包。
  • Holger Schauer wrote fortune.el, a package for using fortune in message signatures.
  • 威廉·谢尔特写道telnet.el,支持telnet Emacs 内的会话。
  • William Schelter wrote telnet.el, support for telnet sessions within Emacs.
  • 拉尔夫·施莱彻写道电池.el,用于显示笔记本电脑电池状态的包,以及信息查找.el,用于查找缓冲区中符号的信息文档的包。
  • Ralph Schleicher wrote battery.el, a package for displaying laptop computer battery status, and info-look.el, a package for looking up Info documentation for symbols in the buffer.
  • 迈克尔·施密特和汤姆·佩林写道模块2.el,一种编辑 Modula-2 代码的模式,基于 Mick Jordan 和 Peter Robinson 的工作。
  • Michael Schmidt and Tom Perrine wrote modula2.el, a mode for editing Modula-2 code, based on work by Mick Jordan and Peter Robinson.
  • 罗纳德·S·施内尔写道邓尼特网站,一款文字冒险游戏。
  • Ronald S. Schnell wrote dunnet.el, a text adventure game.
  • 菲利普·施诺贝伦写道五子棋.el,一款对抗 Emacs 的 Go Moku 游戏;和mpuz.el,乘法谜题。
  • Philippe Schnoebelen wrote gomoku.el, a Go Moku game played against Emacs; and mpuz.el, a multiplication puzzle.
  • 扬·肖曼写道纸牌接龙网站,纸牌游戏的实现。
  • Jan Schormann wrote solitaire.el, an implementation of the Solitaire game.
  • 亚历克斯·施罗德写道ansi-color.el,一个用于将 ANSI 颜色转义序列转换为 Emacs 界面的包;sql.el,一个用于在 Emacs 缓冲区中交互式运行 SQL 解释器的包; 客户主题.el,自定义主题的界面;大师.el,用于制作缓冲区的包'掌握' 超过另一个;和 垃圾邮件统计网站,用于垃圾邮件的统计检测。他还编写了 IRC 客户端 ERC (qv) 的部分内容。
  • Alex Schroeder wrote ansi-color.el, a package for translating ANSI color escape sequences to Emacs faces; sql.el, a package for interactively running an SQL interpreter in an Emacs buffer; cus-theme.el, an interface for custom themes; master.el, a package for making a buffer ‘master’ over another; and spam-stat.el, for statistical detection of junk email. He also wrote parts of the IRC client ERC (q.v.).
  • 兰德尔·施瓦茨写道pp.el,一个用于 Lisp 对象的漂亮打印机。
  • Randal Schwartz wrote pp.el, a pretty-printer for lisp objects.
  • Manuel Serrano 编写了 Flyspell 包,它可以在您键入时进行拼写检查。
  • Manuel Serrano wrote the Flyspell package, which does spell checking as you type.
  • 霍瓦夫·沙哈姆写道风行网,一组用于根据窗口在框架上的几何位置来选择窗口的命令。
  • Hovav Shacham wrote windmove.el, a set of commands for selecting windows based on their geometrical position on the frame.
  • 斯坦尼斯拉夫·沙鲁诺夫写道欧斯电子,用于回复未经请求的商业电子邮件。
  • Stanislav Shalunov wrote uce.el, for responding to unsolicited commercial email.
  • 理查德·沙曼写道hilit-chg.el,它使用颜色来显示最近的编辑更改。
  • Richard Sharman wrote hilit-chg.el, which uses colors to show recent editing changes.
  • 奥林·希弗斯写道comint.el,一个用于运行交互式命令行子进程的模式的库,以及外壳.el,用于运行劣质 shell(均由 Simon Marshall 扩展); cmuscheme.el,用于运行较差的Scheme进程; inf-lisp.el,用于运行劣质 Lisp 进程。
  • Olin Shivers wrote comint.el, a library for modes running interactive command-line-oriented subprocesses, and shell.el, for running inferior shells (both since extended by Simon Marshall); cmuscheme.el, for running inferior Scheme processes; inf-lisp.el, for running inferior Lisp process.
  • 埃斯彭·斯科格伦德写道帕斯卡.el,一种编辑 Pascal 代码的模式。
  • Espen Skoglund wrote pascal.el, a mode for editing Pascal code.
  • 里克·斯拉基写道反引号.el,一个用于创建基本恒定数据的 Lisp 宏。
  • Rick Sladkey wrote backquote.el, a lisp macro for creating mostly-constant data.
  • 林恩·斯莱特写道帮助宏.el,用于编写键绑定交互式帮助的宏。
  • Lynn Slater wrote help-macro.el, a macro for writing interactive help for key bindings.
  • 克里斯·史密斯写道图标.el,一种编辑图标代码的模式。
  • Chris Smith wrote icon.el, a mode for editing Icon code.
  • 大卫·史密斯写道伊尔姆.el,一种作为子进程与 Emacs Lisp 解释器交互的模式。
  • David Smith wrote ielm.el, a mode for interacting with the Emacs Lisp interpreter as a subprocess.
  • 保罗·D·史密斯写道snmp模式.el
  • Paul D. Smith wrote snmp-mode.el.
  • 威廉·索末菲写道抄写员,一种编辑 Scribe 文件的模式,以及服务器.el,一个允许程序将文件发送到现有 Emacs 作业进行编辑的包。
  • William Sommerfeld wrote scribe.el, a mode for editing Scribe files, and server.el, a package allowing programs to send files to an extant Emacs job to be edited.
  • Andre Spiegel 对 Emacs 版本控制包做出了许多贡献,特别是使其支持多个后端。
  • Andre Spiegel made many contributions to the Emacs Version Control package, and in particular made it support multiple back ends.
  • 迈克尔·斯塔茨写道电脑选择.el,它重新绑定用于选择区域的键以遵循许多其他系统。
  • Michael Staats wrote pc-select.el, which rebinds keys for selecting regions to follow many other systems.
  • 理查德·斯托曼 (Richard Stallman) 发明了 Emacs。他是 GNU Emacs 的原作者,并且在多个非连续时期担任 Emacs 维护者。除了 Emacs 的大部分核心代码之外,他还编写了简易菜单.el,用于定义 Emacs 菜单的工具; 图像模式.el、支持访问图片文件; 菜单栏.el、Emacs菜单栏支持代码; 帕伦.埃尔,一个使匹配的括号颜色突出的包;还共同创作了 CC 模式的部分内容。
  • Richard Stallman invented Emacs. He is the original author of GNU Emacs, and has been Emacs maintainer over several non-contiguous periods. In addition to much of the core Emacs code, he has written easymenu.el, a facility for defining Emacs menus; image-mode.el, support for visiting image files; menu-bar.el, the Emacs menu bar support code; paren.el, a package to make matching parentheses stand out in color; and also co-authored portions of CC mode.
  • 萨姆·斯坦戈尔德写道午夜.el,用于每午夜运行命令的包。
  • Sam Steingold wrote midnight.el, a package for running a command every midnight.
  • 阿克·斯坦霍夫和拉斯·林德伯格写道伊米努.el,一个用于浏览由缓冲区内容组成的索引的框架。
  • Ake Stenhoff and Lars Lindberg wrote imenu.el, a framework for browsing indices made from buffer contents.
  • 彼得·史蒂芬森写道vcursor.el,它实现了一个虚拟光标,您可以使用键盘移动该光标并用于复制文本。
  • Peter Stephenson wrote vcursor.el, which implements a virtual cursor that you can move with the keyboard and use for copying text.
  • 肯·史蒂文斯写道伊斯佩尔.el,拼写检查器界面。
  • Ken Stevens wrote ispell.el, a spell-checker interface.
  • Kim F. Storm 对 Emacs 显示引擎、进程支持和网络支持进行了许多改进。他还写了 宾达特,用于编码和解码二进制数据的包; CUA 模式,允许 Emacs 模拟标准 CUA 键绑定;伊多.el,用于快速选择缓冲区和文件的包;键盘.el用于简化键盘绑定;和 克宏.el,键盘宏工具。
  • Kim F. Storm made many improvements to the Emacs display engine, process support, and networking support. He also wrote bindat.el, a package for encoding and decoding binary data; CUA mode, which allows Emacs to emulate the standard CUA key bindings; ido.el, a package for selecting buffers and files quickly; keypad.el for simplified keypad bindings; and kmacro.el, the keyboard macro facility.
  • Martin Stjernholm 与人合着了 CC 模式,这是 C、C ++、Objective-C、Java、Pike、CORBA IDL 和 AWK 代码的主要编辑模式。
  • Martin Stjernholm co-authored CC Mode, a major editing mode for C, C++, Objective-C, Java, Pike, CORBA IDL, and AWK code.
  • 史蒂夫·斯特拉斯曼没有写幽灵.el,即使他这样做了,他也确实不是想让你以无政府主义的方式使用它。
  • Steve Strassmann did not write spook.el, and even if he did, he really didn’t mean for you to use it in an anarchistic way.
  • 奥拉夫·西尔维斯特写道BS.el,一个用于操作 Emacs 缓冲区的包。
  • Olaf Sylvester wrote bs.el, a package for manipulating Emacs buffers.
  • 蒂博尔·西姆科和米兰·扎马扎尔写道斯洛伐克网,支持编辑斯洛伐克语文本。
  • Tibor Šimko and Milan Zamazal wrote slovak.el, support for editing text in Slovak language.
  • João Távora 编写了许多改进Flymake.el,一个即时语法检查包。
  • João Távora wrote many improvements for flymake.el, an on-the-fly syntax-checking package.
  • 吕克·泰尔林克写道帮助中心,通过键盘提供本地帮助。
  • Luc Teirlinck wrote help-at-pt.el, providing local help through the keyboard.
  • 让·菲利普·泰伯格写道拇指.el,用于以缩略图形式查看图像文件的包。
  • Jean-Philippe Theberge wrote thumbs.el, a package for viewing image files as thumbnails.
  • 斯宾塞·托马斯撰写了原著达布雷夫.el,提供一个命令,根据其作为前缀的其他附近单词来完成 point 之前的部分单词。他还写了最初的倾销支持。
  • Spencer Thomas wrote the original dabbrev.el, providing a command which completes the partial word before point, based on other nearby words for which it is a prefix. He also wrote the original dumping support.
  • Toru Tomabechi 为西藏的支持做出了贡献。
  • Toru Tomabechi contributed to Tibetan support.
  • 马库斯·特里斯卡写道林努姆.el,一种在左边距中显示行号的次要模式。
  • Markus Triska wrote linum.el, a minor mode that displays line numbers in the left margin.
  • 汤姆·特罗米和克里斯·林德布拉德写道tcl.el,一种编辑 Tcl/Tk 源文件并作为 Emacs 子进程运行 Tcl 解释器的模式。汤姆·特罗米还写道错误参考.el,提供错误报告的可点击链接;以及 Emacs 软件包系统的第一个版本。
  • Tom Tromey and Chris Lindblad wrote tcl.el, a mode for editing Tcl/Tk source files and running a Tcl interpreter as an Emacs subprocess. Tom Tromey also wrote bug-reference.el, providing clickable links to bug reports; and the first version of the Emacs package system.
  • 伊莱·齐珀曼写道rmail-垃圾邮件过滤器.el,RMAIL 的垃圾邮件过滤器。
  • Eli Tziperman wrote rmail-spam-filter.el, a spam filter for RMAIL.
  • 上野大树写道starttls.el、支持传输层安全协议;sasl-cram.elsasl-digest.el(与冈田健一),以及萨斯尔.el,支持简单身份验证和安全层(SASL);plstore.el用于安全存储财产清单;以及 EasyPG(及其前身 PGG)包,用于 GnuPG 和 PGP 支持。
  • Daiki Ueno wrote starttls.el, support for Transport Layer Security protocol; sasl-cram.el and sasl-digest.el (with Kenichi Okada), and sasl.el, support for Simple Authentication and Security Layer (SASL); plstore.el for secure storage of property lists; and the EasyPG (and its predecessor PGG) package, for GnuPG and PGP support.
  • Masanobu Umeda 编写了 GNUS,这是一个功能丰富的 Usenet 新闻阅读器,它是当前 Gnus 软件包的祖先。他还写了 rmailsort.el,用于对 RMAIL 文件夹中的邮件进行排序的包; 元邮件.el,Metamail 程序的接口; gnus-kill.el,Gnus 的 Kill File 模式;gnus-mh.el,Gnus 的 mh-e 接口;gnus-msg.el,Gnus 的邮件和邮寄界面;和时区.el,提供处理时区的函数。
  • Masanobu Umeda wrote GNUS, a feature-rich reader for Usenet news that was the ancestor of the current Gnus package. He also wrote rmailsort.el, a package for sorting messages in RMAIL folders; metamail.el, an interface to the Metamail program; gnus-kill.el, the Kill File mode for Gnus; gnus-mh.el, an mh-e interface for Gnus; gnus-msg.el, a mail and post interface for Gnus; and timezone.el, providing functions for dealing with time zones.
  • 尼尔·范·戴克 (Neil W. Van Dyke) 写道网络跳转.el,一个 Web 热门列表包。
  • Neil W. Van Dyke wrote webjump.el, a Web hotlist package.
  • 迪迪埃·维尔纳写道直肠,用于对文本矩形区域进行操作的函数包。他还为 Gnus (qv) 做出了贡献。
  • Didier Verna wrote rect.el, a package of functions for operations on rectangle regions of text. He also contributed to Gnus (q.v.).
  • Joakim Verona 实现了 ImageMagick 支持。
  • Joakim Verona implemented ImageMagick support.
  • 乌尔里克·维特实施元模型.el,用于编辑 MetaFont 代码。
  • Ulrik Vieth implemented meta-mode.el, for editing MetaFont code.
  • Geoffrey Voelker 编写了 Windows NT 支持。他还写了 dos-w32.el、Emacs 的 MS-DOS 和 MS-Windows 端口共享的功能,以及w32-fns.el,MS-Windows特定的支持功能。
  • Geoffrey Voelker wrote the Windows NT support. He also wrote dos-w32.el, functions shared by the MS-DOS and MS-Windows ports of Emacs, and w32-fns.el, MS-Windows specific support functions.
  • 约翰·弗罗曼斯写道表格.el及其相关文件,一种填写表格的模式。他还写了iso-acc.el,一种提供电子重音键的小模式。
  • Johan Vromans wrote forms.el and its associated files, a mode for filling in forms. He also wrote iso-acc.el, a minor mode providing electric accent keys.
  • Colin Walters 编写了 Ibuffer,一个增强的缓冲区菜单。
  • Colin Walters wrote Ibuffer, an enhanced buffer menu.
  • 巴里·华沙写道cc-模式.el,一种用于编辑 C、C 和 Java 代码的模式++,基于 Dave Detlefs、Stewart Clamen 和 Richard Stallman 的早期工作;elp.el,Emacs Lisp 程序的分析器;曼埃尔,一种阅读 Unix 手册页的模式; 雷吉尔,提供类似 AWK 的功能以在 lisp 程序中使用;记者网站,为 lisp 包提供可定制的错误报告;和supercite.el,一种用于引用邮件消息和新闻文章部分的次要模式。
  • Barry Warsaw wrote cc-mode.el, a mode for editing C, C++, and Java code, based on earlier work by Dave Detlefs, Stewart Clamen, and Richard Stallman; elp.el, a profiler for Emacs Lisp programs; man.el, a mode for reading Unix manual pages; regi.el, providing an AWK-like functionality for use in lisp programs; reporter.el, providing customizable bug reporting for lisp packages; and supercite.el, a minor mode for quoting sections of mail messages and news articles.
  • 克里斯托夫·韦德勒写道antlr-mode.el,ANTLR语法文件的主要模式。
  • Christoph Wedler wrote antlr-mode.el, a major mode for ANTLR grammar files.
  • Morten Welinder 帮助将 Emacs 移植到 MS-DOS,并将面部支持引入到 Emacs 的 MS-DOS 移植中。他还写了 桌面.el,用于在会话之间保存一些 Emacs 状态的工具;定时器.el、在给定时间或频率或在 Emacs 空闲时运行命令的 Emacs 工具及其 C 级支持代码;pc-win.el、MS-DOS“窗口系统”支持; 内部.el,Emacs MS-DOS 端口的“内部终端”模拟器;弧线模型.el,压缩档案的编辑模式;s-区域.el、使用 Shift 键和运动命令设置区域的命令;和dos-fns.el,在 MS-DOS 下使用的函数。
  • Morten Welinder helped port Emacs to MS-DOS, and introduced face support into the MS-DOS port of Emacs. He also wrote desktop.el, facilities for saving some of Emacs’s state between sessions; timer.el, the Emacs facility to run commands at a given time or frequency, or when Emacs is idle, and its C-level support code; pc-win.el, the MS-DOS “window-system” support; internal.el, an “internal terminal” emulator for the MS-DOS port of Emacs; arc-mode.el, the mode for editing compressed archives; s-region.el, commands for setting the region using the shift key and motion commands; and dos-fns.el, functions for use under MS-DOS.
  • 乔·威尔斯 (Joe Wells) 编写了原版apropos.el(qv); 简历.el,支持在恢复挂起的 Emacs 作业后处理命令行参数;和邮件扩展.el,一个用于从邮件标头中提取姓名和地址的包,由 Jamie Zawinski 贡献。
  • Joe Wells wrote the original version of apropos.el (q.v.); resume.el, support for processing command-line arguments after resuming a suspended Emacs job; and mail-extr.el, a package for extracting names and addresses from mail headers, with contributions from Jamie Zawinski.
  • 罗德尼·惠特比和雷托·齐默尔曼写道vhdl-模式.el,编辑VHDL源代码的主要模式。
  • Rodney Whitby and Reto Zimmermann wrote vhdl-mode.el, a major mode for editing VHDL source code.
  • John Wiegley 是 Emacs 25 到 29.1 期间的 Emacs(联合)维护者。他写了对齐.el,一组用于根据基于正则表达式的规则对齐文本的命令;isearchb.el用于快速缓冲区切换;时间时钟.el,一个用于跟踪项目所花费时间的包;巴哈伊日历支持;完整版,一个可编程完成设施;记住.el,一种记下要记住的事情的模式;eudcb-mab.el,Emacs 统一目录客户端的地址簿后端;以及eshell,一个完全用 Emacs Lisp 实现的命令 shell。他还为组织模式 (qv) 做出了贡献。
  • John Wiegley was the Emacs (co-)maintainer from Emacs 25 to 29.1. He wrote align.el, a set of commands for aligning text according to regular-expression based rules; isearchb.el for fast buffer switching; timeclock.el, a package for keeping track of time spent on projects; the Bahá’í calendar support; pcomplete.el, a programmable completion facility; remember.el, a mode for jotting down things to remember; eudcb-mab.el, an address book backend for the Emacs Unified Directory Client; and eshell, a command shell implemented entirely in Emacs Lisp. He also contributed to Org mode (q.v.).
  • 迈克·威廉姆斯写道事物网站,用于查找点处“事物”(单词、线条、s 表达式)的函数库。
  • Mike Williams wrote thingatpt.el, a library of functions for finding the “thing” (word, line, s-expression) at point.
  • 罗兰·温克勒写道程序.el,一个系统进程编辑器。
  • Roland Winkler wrote proced.el, a system process editor.
  • Bill Wohler 编写了 MH-E,即 MH 邮件系统的 Emacs 接口;利用 James R. Larus 的早期作品。 Satyaki Das、Peter S. Galbraith、Stephen Gildea 和 Jeffrey C. Honig 也编写了各种 MH-E 组件。
  • Bill Wohler wrote MH-E, the Emacs interface to the MH mail system; making use of earlier work by James R. Larus. Satyaki Das, Peter S. Galbraith, Stephen Gildea, and Jeffrey C. Honig also wrote various MH-E components.
  • 戴尔·R·沃利写道出现.el,用于交互式合并文件的两个版本的包。
  • Dale R. Worley wrote emerge.el, a package for interactively merging two versions of a file.
  • 弗朗西斯·J·赖特写道女人.el,一个无需命令即可浏览手册页的包man
  • Francis J. Wright wrote woman.el, a package for browsing manual pages without the man command.
  • 大和正武写道ld脚本.el,一种 GNU 链接器脚本的编辑模式,并在 CC 模式下贡献了子字处理和样式猜测。
  • Masatake Yamato wrote ld-script.el, an editing mode for GNU linker scripts, and contributed subword handling and style guessing in CC mode.
  • 乔纳森·亚夫纳写道测试覆盖.el,一个用于跟踪 Emacs Lisp 代码测试状态的包;不安全的网站确定 Lisp 形式是否安全;和 SES 电子表格包。
  • Jonathan Yavner wrote testcover.el, a package for keeping track of the testing status of Emacs Lisp code; unsafep.el to determine if a Lisp form is safe; and the SES spreadsheet package.
  • 瑞安·耶斯克写道rcirc.el一个简单的互联网中继聊天客户端。
  • Ryan Yeske wrote rcirc.el a simple Internet Relay Chat client.
  • 伊利亚·扎哈列维奇和鲍勃·奥尔森写道cperl-mode.el,编辑 Perl 代码的主要模式。伊利亚·扎哈列维奇还写道 tmm.el,一种用于在文本模式终端上访问 Emacs 菜单栏的模式。
  • Ilya Zakharevich and Bob Olson wrote cperl-mode.el, a major mode for editing Perl code. Ilya Zakharevich also wrote tmm.el, a mode for accessing the Emacs menu bar on a text-mode terminal.
  • 米兰扎马扎尔写道捷克语网,支持编辑捷克语文本; 眼镜.el,一个更容易阅读使用难以辨认的标识符名称的源代码的包;和tilify.el、用于向文本、TeX 和 SGML/HTML 文件添加硬空格的命令。
  • Milan Zamazal wrote czech.el, support for editing Czech text; glasses.el, a package for easier reading of source code that uses illegible identifier names; and tildify.el, commands for adding hard spaces to text, TeX, and SGML/HTML files.
  • 维克多·赞迪写道区域.el,一个为那些喜欢在 Emacs 前走神的人准备的软件包。
  • Victor Zandy wrote zone.el, a package for people who like to zone out in front of Emacs.
  • Eli Zaretskii 从 Emacs 25 开始担任 Emacs(联合)维护者。他使许多标准 Emacs 功能可以在 MS-DOS 和 Microsoft Windows 上运行。他还写了tty-colors.el,实现了X颜色到tty颜色的透明映射;和 rxvt.el。他实现了对双向文本、文本模式终端上的菜单以及内置行号显示的支持。
  • Eli Zaretskii was the Emacs (co-)maintainer from Emacs 25 onwards. He made many standard Emacs features work on MS-DOS and Microsoft Windows. He also wrote tty-colors.el, which implements transparent mapping of X colors to tty colors; and rxvt.el. He implemented support for bidirectional text, menus on text-mode terminals, and built-in display of line numbers.
  • Jamie Zawinski 编写了大部分对面孔和 X 选择的支持。他与 Hallvard Furuseth 一起编写了从 Emacs 19 开始使用的优化字节编译器。他还写了邮件缩写.el,一个提供邮件别名自动扩展的包,以及 tar-mode.el,它提供了简单的 tar 文件查看和编辑命令。
  • Jamie Zawinski wrote much of the support for faces and X selections. With Hallvard Furuseth, he wrote the optimizing byte compiler used from Emacs 19 onwards. He also wrote mailabbrev.el, a package that provides automatic expansion of mail aliases, and tar-mode.el, which provides simple viewing and editing commands for tar files.
  • Andrewzhilin 创建了 Emacs 22 图标。
  • Andrew Zhilin created the Emacs 22 icons.
  • 朱生火写道binhex.el,用于读写 binhex 文件的包;mm-partial.el、消息/部分支持MIME消息;rfc1843.el,一个HZ解码包; uudecode.el,用于 uuencoded 数据的 Emacs Lisp 解码器;和 网络邮件.el,Web 邮件的接口。他还编写了其他几个 Gnus 组件。
  • Shenghuo Zhu wrote binhex.el, a package for reading and writing binhex files; mm-partial.el, message/partial support for MIME messages; rfc1843.el, an HZ decoding package; uudecode.el, an Emacs Lisp decoder for uuencoded data; and webmail.el, an interface to Web mail. He also wrote several other Gnus components.
  • 伊恩·T·齐默尔曼写道游戏树.el
  • Ian T. Zimmerman wrote gametree.el.
  • 雷托·齐默尔曼写道维拉模式.el
  • Reto Zimmermann wrote vera-mode.el.
  • Neal Ziring 和 Felix ST Wu 写道维埃尔,VI 文本编辑器的模拟。
  • Neal Ziring and Felix S. T. Wu wrote vi.el, an emulation of the VI text editor.
  • Ted Zlatanov(以及他对 Gnus 新闻阅读器的贡献)编写了 GnuTLS 库的接口,用于安全网络连接;以及 URL 库的 futures 工具。
  • Ted Zlatanov (as well as his contributions to the Gnus newsreader) wrote an interface to the GnuTLS library, for secure network connections; and a futures facility for the URL library.
  • 德特列夫·尊德尔写道重建者.el,一个用于构建具有视觉反馈的正则表达式的包。
  • Detlev Zundel wrote re-builder.el, a package for building regexps with visual feedback.

关键(字符)索引

Key (Character) Index

跳到:     "   #   $   %   (   *   +   -   .   /   1   2   :   <   =   >   ?   ^   {   }   ~  
A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   P   Q   R   S   T   U   V   W   X   Y   Z  
索引条目 部分

! (Dired): Dired 中的 Shell 命令

" (TeX mode): 文本编辑

#
# (Dired): 标记许多文件

$
$ (Dired): 隐藏子目录

%
% & (Dired): 标记许多文件
% (Buffer Menu): 多个缓冲区
% C (Dired): 转换文件名
% d (Dired): 标记许多文件
% g (Dired): 标记与旗帜
% H (Dired): 转换文件名
% l (Dired): 转换文件名
% m (Dired): 标记与旗帜
% R (Dired): 转换文件名
% S (Dired): 转换文件名
% u (Dired): 转换文件名
% Y (Dired): 转换文件名

( (Dired): 其他 Dired 功能
( (Package Menu): 套餐菜单

*
* ! (Dired): 标记与旗帜
* % (Dired): 标记与旗帜
* * (Dired): 标记与旗帜
* / (Dired): 标记与旗帜
* ? (Dired): 标记与旗帜
* @ (Dired): 标记与旗帜
* c (Dired): 标记与旗帜
* C-n (Dired): 标记与旗帜
* C-p (Dired): 标记与旗帜
* DEL (Dired): 标记与旗帜
* m (Dired): 标记与旗帜
* N (Dired): 标记与旗帜
* s (Dired): 标记与旗帜
* t (Dired): 标记与旗帜
* u (Dired): 标记与旗帜

+
+ (Dired): 其他 Dired 功能
+ (DocView mode): 文档视图导航

-
- (DocView mode): 文档视图导航

. (Calendar mode): 指定日期
. (Dired): 标记许多文件
. (Rmail): Rmail 滚动

/
/ (Rmail): Rmail 滚动
/ / (Package Menu): 套餐菜单
/ a (Package Menu): 套餐菜单
/ d (Package Menu): 套餐菜单
/ k (Package Menu): 套餐菜单
/ m (Package Menu): 套餐菜单
/ N (Package Menu): 套餐菜单
/ n (Package Menu): 套餐菜单
/ s (Package Menu): 套餐菜单
/ u (Package Menu): 套餐菜单
/ v (Package Menu): 套餐菜单

1
1 (Buffer Menu): 多个缓冲区

2
2 (Buffer Menu): 多个缓冲区

:
:d (Dired): 对文件进行操作
:e (Dired): 对文件进行操作
:s (Dired): 对文件进行操作
:v (Dired): 对文件进行操作

<
< (Calendar mode): 滚动日历
< (Dired): 子目录运动
< (Rmail): 邮件动议

=
= (Dired): Dired 中的比较

>
> (Calendar mode): 滚动日历
> (Dired): 子目录运动
> (Rmail): 邮件动议

? (completion): 完成命令
? (Package Menu): 套餐菜单

^
^ (Dired): 可怕的访问

{
{ (Buffer Menu): 多个缓冲区

}
} (Buffer Menu): 多个缓冲区

~ (Buffer Menu): 多个缓冲区
~ (Dired): 标记许多文件
~ (Package Menu): 套餐菜单

A
a (Calendar mode): 假期
A (Dired): 对文件进行操作
a (Rmail): 邮件标签
A k (Gnus Group mode): Gnus 组缓冲区
A s (Gnus Group mode): Gnus 组缓冲区
A u (Gnus Group mode): Gnus 组缓冲区
A z (Gnus Group mode): Gnus 组缓冲区
AltGr (MS-Windows): Windows 键盘

b (Buffer Menu): 多个缓冲区
B (Dired): 对文件进行操作
b (Rmail summary): Rmail摘要编辑
b (Rmail): Rmail 基础知识
BS (MS-DOS): MS-DOS 键盘

C
C (Dired): 对文件进行操作
c (Dired): 对文件进行操作
c (Rmail): 邮件回复
C-/: 撤消
C-0, tab bar: 标签栏
C-1, tab bar: 标签栏
C-9, tab bar: 标签栏
C-@: 设置标记
C-a: 移动点
C-a (Calendar mode): 移至开头或结尾
C-b: 移动点
C-b (Calendar mode): 日历单元运动
C-b, when using input methods: 输入法
C-Break (MS-DOS): MS-DOS 键盘
C-c ' (Picture mode): 插入图片
C-c , j: 语义学
C-c , J: 语义学
C-c , l: 语义学
C-c , SPC: 语义学
C-c . (C mode): 自定义 C 缩进
C-c . (Picture mode): 插入图片
C-c . (Shell mode): 贝壳环
C-c / (Picture mode): 插入图片
C-c / (SGML mode): HTML模式
C-c 8 (SGML mode): HTML模式
C-c ; (Fortran mode): Fortran 注释
C-c < (GUD): GUD命令
C-c < (Picture mode): 插入图片
C-c > (GUD): GUD命令
C-c > (Picture mode): 插入图片
C-c ? (SGML mode): HTML模式
C-c @ (Outline minor mode): 轮廓小调模式
C-c @ C-c: 秀秀
C-c @ C-h: 秀秀
C-c @ C-l: 秀秀
C-c @ C-M-h: 秀秀
C-c @ C-M-s: 秀秀
C-c @ C-r: 秀秀
C-c @ C-s: 秀秀
C-c C-a (C mode): 电动C
C-c C-a (F90 mode): Fortran 运动
C-c C-a (Log Edit mode): 日志缓冲区
C-c C-a (Message mode): 邮件杂项
C-c C-a (Outline mode): 轮廓可见性
C-c C-a (SGML mode): HTML模式
C-c C-a (Shell mode): 外壳模式
C-c C-b (Help mode): 帮助模式
C-c C-b (Message mode): 标题编辑
C-c C-b (Outline mode): 轮廓运动
C-c C-b (Picture mode): 插入图片
C-c C-b (SGML mode): HTML模式
C-c C-b (Shell mode): 外壳模式
C-c C-b (TeX mode): TeX 打印
C-c C-c (C mode): 评论命令
C-c C-c (customization buffer): 更改变量
C-c C-c (Edit Abbrevs): 编辑缩写
C-c C-c (Edit Tab Stops): 制表位
C-c C-c (Log Edit mode): 日志缓冲区
C-c C-c (Message mode): 邮件发送
C-c C-c (Outline mode): 轮廓可见性
C-c C-c (Shell mode): 外壳模式
C-c C-c (TeX mode): TeX 打印
C-c C-d (C Mode): 饿删除
C-c C-d (Fortran mode): 对于缩进命令
C-c C-d (GUD): GUD命令
C-c C-d (Log Edit mode): 日志缓冲区
C-c C-d (Org Mode): 组织组织者
C-c C-d (Outline mode): 轮廓可见性
C-c C-d (Picture mode): 基本图片
C-c C-d (SGML mode): HTML模式
C-c C-DEL (C Mode): 饿删除
C-c C-Delete (C Mode): 饿删除
C-c C-e (C mode): 其他 C 命令
C-c C-e (F90 mode): Fortran 运动
C-c C-e (LaTeX mode): 乳胶编辑
C-c C-e (Org mode): 组织创作
C-c C-e (Outline mode): 轮廓可见性
C-c C-e (Shell mode): 外壳模式
C-c C-f (GUD): GUD命令
C-c C-f (Help mode): 帮助模式
C-c C-f (Log Edit mode): 日志缓冲区
C-c C-f (Outline mode): 轮廓运动
C-c C-f (Picture mode): 插入图片
C-c C-f (SGML mode): HTML模式
C-c C-f (Shell mode): 外壳模式
C-c C-f (TeX mode): TeX 打印
C-c C-f C-b (Message mode): 标题编辑
C-c C-f C-c (Message mode): 标题编辑
C-c C-f C-f (Message mode): 标题编辑
C-c C-f C-r (Message mode): 标题编辑
C-c C-f C-s (Message mode): 标题编辑
C-c C-f C-t (Message mode): 标题编辑
C-c C-f C-w (Message mode): 标题编辑
C-c C-i (GUD): GUD命令
C-c C-i (Outline mode): 轮廓可见性
C-c C-j (Term mode): 期限模式
C-c C-k (Outline mode): 轮廓可见性
C-c C-k (Picture mode): 图片中的矩形
C-c C-k (Term mode): 期限模式
C-c C-k (TeX mode): TeX 打印
C-c C-l (C mode): 电动C
C-c C-l (Calendar mode): 通用日历
C-c C-l (GUD): GUD命令
C-c C-l (Outline mode): 轮廓可见性
C-c C-l (Shell mode): 贝壳环
C-c C-l (TeX mode): TeX 打印
C-c C-n (C mode): C 语言运动
C-c C-n (Fortran mode): Fortran 运动
C-c C-n (GUD): GUD命令
C-c C-n (Outline mode): 轮廓运动
C-c C-n (Rmail): 邮件动议
C-c C-n (SGML mode): HTML模式
C-c C-n (Shell mode): Shell 历史记录复制
C-c C-o (LaTeX mode): 乳胶编辑
C-c C-o (Outline mode): 轮廓可见性
C-c C-o (Shell mode): 外壳模式
C-c C-p (C mode): C 语言运动
C-c C-p (Fortran mode): Fortran 运动
C-c C-p (GUD): GUD命令
C-c C-p (Outline mode): 轮廓运动
C-c C-p (Rmail): 邮件动议
C-c C-p (Shell mode): Shell 历史记录复制
C-c C-p (TeX mode): TeX 打印
C-c C-q (C mode): C 缩进
C-c C-q (Message mode): 引用邮件
C-c C-q (Outline mode): 轮廓可见性
C-c C-q (Term mode): 期限模式
C-c C-r (Fortran mode): Fortran 列
C-c C-r (GUD): GUD命令
C-c C-r (Shell mode): 外壳模式
C-c C-r (TeX mode): TeX 打印
C-c C-s (C mode): 其他 C 命令
C-c C-s (GUD): GUD命令
C-c C-s (Message mode): 邮件发送
C-c C-s (Org Mode): 组织组织者
C-c C-s (Outline mode): 轮廓可见性
C-c C-s (Shell mode): 外壳模式
C-c C-t (GUD): GUD命令
C-c C-t (Org Mode): 组织组织者
C-c C-t (Outline mode): 轮廓可见性
C-c C-t (SGML mode): HTML模式
C-c C-u (C mode): C 语言运动
C-c C-u (GUD): GUD命令
C-c C-u (Outline mode): 轮廓运动
C-c C-u (Shell mode): 外壳模式
C-c C-v (SGML mode): HTML模式
C-c C-v (TeX mode): TeX 打印
C-c C-w (Fortran mode): Fortran 列
C-c C-w (Log Edit mode): 日志缓冲区
C-c C-w (Message mode): 邮件签名
C-c C-w (Picture mode): 图片中的矩形
C-c C-w (Shell mode): 外壳模式
C-c C-x: 展开
C-c C-x (Picture mode): 图片中的矩形
C-c C-x (Shell mode): 贝壳环
C-c C-y (Message mode): 引用邮件
C-c C-y (Picture mode): 图片中的矩形
C-c C-z: 展开
C-c C-z (Shell mode): 外壳模式
C-c C-\ (C mode): 其他 C 命令
C-c C-\ (Shell mode): 外壳模式
C-c DEL (C Mode): 饿删除
C-c Delete (C Mode): 饿删除
C-c DOWN (Picture mode): 插入图片
C-c End (Picture mode): 插入图片
C-c Home (Picture mode): 插入图片
C-c LEFT (Picture mode): 插入图片
C-c next (Picture mode): 插入图片
C-c PageDown (Picture mode): 插入图片
C-c PageUp (Picture mode): 插入图片
C-c prior (Picture mode): 插入图片
C-c RET (Goto Address mode): 转到地址模式
C-c RET (Shell mode): Shell 历史记录复制
C-c RIGHT (Picture mode): 插入图片
C-c TAB (Picture mode): 图片中的选项卡
C-c TAB (SGML mode): HTML模式
C-c TAB (TeX mode): TeX 打印
C-c UP (Picture mode): 插入图片
C-c [ (Enriched mode): 丰富的缩进
C-c [ (Org Mode): 组织组织者
C-c \ (Picture mode): 插入图片
C-c ] (Enriched mode): 丰富的缩进
C-c ^ (Picture mode): 插入图片
C-c ` (Picture mode): 插入图片
C-c { (TeX mode): 文本编辑
C-c } (TeX mode): 文本编辑
C-d (Buffer Menu): 多个缓冲区
C-d (Rmail): 邮件删除
C-d (Shell mode): 外壳模式
C-Down-mouse-1: 缓冲区菜单
C-e: 移动点
C-e (Calendar mode): 移至开头或结尾
C-END: 移动点
C-f: 移动点
C-f (Calendar mode): 日历单元运动
C-f, when using input methods: 输入法
C-g: 戒烟
C-g (Incremental search): 搜索错误
C-g (MS-DOS): MS-DOS 键盘
C-g C-g (Incremental Search): 基础搜索
C-h: 帮助
C-h .: 帮助回声
C-h 4 i: 其他帮助
C-h a: 恰如其分
C-h b: 其他帮助
C-h c: 主要帮助
C-h C: 编码系统
C-h C-c: 帮助文件
C-h C-d: 帮助文件
C-h C-e: 帮助文件
C-h C-f: 帮助文件
C-h C-h: 帮助
C-h C-h (Incremental Search): 特殊研究
C-h C-m: 帮助文件
C-h C-n: 帮助文件
C-h C-o: 帮助文件
C-h C-p: 帮助文件
C-h C-q: 其他帮助
C-h C-t: 帮助文件
C-h C-w: 帮助文件
C-h C-\: 选择输入法
C-h d: 恰如其分
C-h e: 其他帮助
C-h f: 名称帮助
C-h F: 名称帮助
C-h g: 帮助文件
C-h h: 国际字符
C-h i: 其他帮助
C-h I: 选择输入法
C-h k: 主要帮助
C-h K: 主要帮助
C-h l: 其他帮助
C-h L: 语言环境
C-h m: 其他帮助
C-h o: 名称帮助
C-h p: 套餐关键词
C-h P: 套餐关键词
C-h S: 其他帮助
C-h s: 其他帮助
C-h t: 基本的
C-h v: 名称帮助
C-h w: 主要帮助
C-h x: 名称帮助
C-j: 插入文本
C-j (and major modes): 主要模式
C-j (Lisp Interaction mode): Lisp交互
C-j (MS-DOS): MS-DOS 键盘
C-j (TeX mode): 文本编辑
C-k: 线杀
C-k (Gnus Group mode): Gnus 组缓冲区
C-l: 重心调整
C-LEFT: 移动点
C-M-%: 查询替换
C-M-% (Incremental search): 特殊研究
C-M-,: 查找标识符
C-M-.: 查找标识符
C-M-/: 动态缩写
C-M-@: 标记对象
C-M-a: 移动由 Defuns 提供
C-M-b: 表达式
C-M-c: 递归编辑
C-M-d: 帕伦斯移动
C-M-d (Dired): 子目录运动
C-M-d (Incremental search): 搜索扬克
C-M-e: 移动由 Defuns 提供
C-M-f: 表达式
C-M-f (Rmail): Rmail 总结
C-M-h: 移动由 Defuns 提供
C-M-h (C mode): 移动由 Defuns 提供
C-M-i: 符号完成
C-M-i (customization buffer): 更改变量
C-M-j: 多行注释
C-M-j (Fortran mode): 对于缩进命令
C-M-k: 表达式
C-M-l: 重心调整
C-M-l (Rmail): Rmail 总结
C-M-l (Shell mode): 外壳模式
C-M-n: 帕伦斯移动
C-M-n (Dired): 子目录运动
C-M-n (Fortran mode): Fortran 运动
C-M-n (Rmail): 邮件标签
C-M-o: 缩进命令
C-M-p: 帕伦斯移动
C-M-p (Dired): 子目录运动
C-M-p (Fortran mode): Fortran 运动
C-M-p (Rmail): 邮件标签
C-M-q: 多行缩进
C-M-q (C mode): C 缩进
C-M-q (Fortran mode): 对于缩进命令
C-M-r: 正则表达式搜索
C-M-r (Rmail): Rmail 总结
C-M-s: 正则表达式搜索
C-M-s (Rmail): Rmail 总结
C-M-S-l: 其他窗口
C-M-S-v: 其他窗口
C-M-SPC: 表达式
C-M-t: 表达式
C-M-t (Rmail): Rmail 总结
C-M-u: 帕伦斯移动
C-M-u (Dired): 子目录运动
C-M-v: 其他窗口
C-M-w: 追加击杀数
C-M-w (Incremental search): 搜索扬克
C-M-wheel-down: 文字比例
C-M-wheel-up: 文字比例
C-M-x (Emacs Lisp mode): Lisp 评估
C-M-x (Lisp mode): 外部 Lisp
C-M-x (Scheme mode): 外部 Lisp
C-M-y (Incremental search): 搜索扬克
C-M-z (Incremental search): 搜索扬克
C-M-\: 缩进命令
C-mouse-1: 菜单鼠标点击
C-mouse-2: 菜单鼠标点击
C-mouse-2 (mode line): 分割窗口
C-mouse-2 (scroll bar): 分割窗口
C-mouse-3: 菜单鼠标点击
C-mouse-3 (when menu bar is disabled): 菜单栏
C-n: 移动点
C-n (Calendar mode): 日历单元运动
C-n (Dired): 定向导航
C-n, when using input methods: 输入法
C-o: 空行
C-o (Buffer Menu): 多个缓冲区
C-o (Dired): 可怕的访问
C-o (Occur mode): 其他重复搜索
C-o (Rmail): 邮件输出
C-p: 移动点
C-p (Calendar mode): 日历单元运动
C-p (Dired): 定向导航
C-p, when using input methods: 输入法
C-q: 插入文本
C-q (Incremental Search): 特殊研究
C-r: 基础搜索
C-r (Incremental Search): 重复搜索
C-RIGHT: 移动点
C-s: 基础搜索
C-s (Incremental Search): 重复搜索
C-S-backspace: 线杀
C-S-mouse-3 (FFAP): FFAP
C-SPC: 设置标记
C-SPC C-SPC: 马克环
C-SPC C-SPC, enabling Transient Mark mode temporarily: 禁用瞬态标记
C-t: 转置
C-t d (Image-Dired): 图像定向
C-TAB: 文件名缓存
C-TAB: 标签栏
C-u: 论点
C-u C-/: 撤消
C-u C-c C-w (Fortran mode): Fortran 列
C-u C-SPC: 马克环
C-u C-x C-x: 禁用瞬态标记
C-u C-x v =: 旧版本
C-u C-x v D: 旧版本
C-u M-;: 评论命令
C-u TAB: 多行缩进
C-v: 移动点
C-v: 滚动
C-v (Calendar mode): 滚动日历
C-w: 其他杀死命令
C-w (Incremental search): 搜索扬克
C-wheel-down: 文字比例
C-wheel-up: 文字比例
C-x #: 调用 emacsclient
C-x $: 选择性显示
C-x (: 基本键盘宏
C-x ): 基本键盘宏
C-x +: 更改窗口
C-x -: 更改窗口
C-x .: 填充前缀
C-x 0: 更改窗口
C-x 1: 更改窗口
C-x 2: 分割窗口
C-x 3: 分割窗口
C-x 4: 弹出窗口
C-x 4 .: 查找标识符
C-x 4 0: 更改窗口
C-x 4 a: 更改日志命令
C-x 4 b: 选择缓冲区
C-x 4 c: 间接缓冲区
C-x 4 C-j: 直接输入
C-x 4 C-o: 弹出窗口
C-x 4 d: 直接输入
C-x 4 f: 参观
C-x 4 f (FFAP): FFAP
C-x 4 m: 发送邮件
C-x 5: 创建框架
C-x 5 .: 查找标识符
C-x 5 0: 帧命令
C-x 5 1: 帧命令
C-x 5 2: 创建框架
C-x 5 b: 选择缓冲区
C-x 5 c: 创建框架
C-x 5 d: 直接输入
C-x 5 f: 参观
C-x 5 f (FFAP): FFAP
C-x 5 m: 发送邮件
C-x 5 o: 帧命令
C-x 5 r: 创建框架
C-x 5 u: 帧命令
C-x 6 1: 两柱式
C-x 6 2: 两柱式
C-x 6 b: 两柱式
C-x 6 d: 两柱式
C-x 6 RET: 两柱式
C-x 6 s: 两柱式
C-x 8: 插入文本
C-x 8 e: 输入法
C-x 8 e RET (Incremental Search): 特殊研究
C-x 8 RET: 输入法
C-x 8 RET (Incremental Search): 特殊研究
C-x ;: 评论选项
C-x <: 水平滚动
C-x =: 职位信息
C-x =, and international characters: 国际字符
C-x >: 水平滚动
C-x a g: 定义缩写
C-x a i g: 定义缩写
C-x a i l: 定义缩写
C-x a l: 定义缩写
C-x b: 选择缓冲区
C-x C-+: 文字比例
C-x C--: 文字比例
C-x C-0: 文字比例
C-x C-;: 评论命令
C-x C-=: 文字比例
C-x C-a (GUD): GUD命令
C-x C-a C-b: GUD命令
C-x C-a C-j (GUD): GUD命令
C-x C-a C-w (GUD): 观看表情
C-x C-b: 列表缓冲区
C-x C-c: 退出
C-x C-c (customization buffer): 更改变量
C-x C-d: 目录
C-x C-e: Lisp 评估
C-x C-f: 参观
C-x C-f (FFAP): FFAP
C-x C-j: 直接输入
C-x C-k b: 保存键盘宏
C-x C-k C-a: 键盘宏计数器
C-x C-k C-c: 键盘宏计数器
C-x C-k C-e: 编辑键盘宏
C-x C-k C-f: 键盘宏计数器
C-x C-k C-i: 键盘宏计数器
C-x C-k C-k: 键盘宏环
C-x C-k C-n: 键盘宏环
C-x C-k C-p: 键盘宏环
C-x C-k d: 基本键盘宏
C-x C-k e: 编辑键盘宏
C-x C-k l: 编辑键盘宏
C-x C-k n: 保存键盘宏
C-x C-k r: 基本键盘宏
C-x C-k RET: 编辑键盘宏
C-x C-k SPC: 键盘宏步进编辑
C-x C-k x: 键盘宏寄存器
C-x C-l: 案件
C-x C-M-+: 文字比例
C-x C-M--: 文字比例
C-x C-M-0: 文字比例
C-x C-M-=: 文字比例
C-x C-n: 移动点
C-x C-o: 空行
C-x C-p: 页数
C-x C-q: 杂项缓冲区
C-x C-r: 参观
C-x C-r (FFAP): FFAP
C-x C-s: 保存命令
C-x C-s (Custom Themes buffer): 自定义主题
C-x C-SPC: 全球标志戒指
C-x C-t: 转置
C-x C-u: 案件
C-x C-v: 参观
C-x C-v (FFAP): FFAP
C-x C-w: 保存命令
C-x C-x: 设置标记
C-x C-x, in rectangle-mark-mode: 矩形
C-x C-z: 外部 Lisp
C-x d: 直接输入
C-x d (FFAP): FFAP
C-x DEL: 句子
C-x e: 基本键盘宏
C-x ESC ESC: 重复
C-x f: 填充命令
C-x h: 标记对象
C-x i: 其他文件操作
C-x k: 终止缓冲区
C-x l: 页数
C-x LEFT: 选择缓冲区
C-x m: 发送邮件
C-x n d: 缩小范围
C-x n n: 缩小范围
C-x n p: 缩小范围
C-x n w: 缩小范围
C-x o: 其他窗口
C-x q: 键盘宏查询
C-x r +: 寄存器数量
C-x r b: 书签
C-x r c: 矩形
C-x r d: 矩形
C-x r f: 配置寄存器
C-x r i: 文本寄存器
C-x r j: 位置寄存器
C-x r k: 矩形
C-x r l: 书签
C-x r m: 书签
C-x r M: 书签
C-x r M-w: 矩形
C-x r N: 矩形
C-x r n: 寄存器数量
C-x r o: 矩形
C-x r r: 矩形寄存器
C-x r s: 文本寄存器
C-x r SPC: 位置寄存器
C-x r t: 矩形
C-x r w: 配置寄存器
C-x r y: 矩形
C-x RET: 国际字符
C-x RET c: 文本编码
C-x RET C-\: 选择输入法
C-x RET f: 文本编码
C-x RET F: 文件名编码
C-x RET k: 端子编码
C-x RET p: 通讯编码
C-x RET r: 文本编码
C-x RET t: 端子编码
C-x RET x: 通讯编码
C-x RET X: 通讯编码
C-x RIGHT: 选择缓冲区
C-x s: 保存命令
C-x t: 标签栏
C-x t 0: 标签栏
C-x t 1: 标签栏
C-x t 2: 标签栏
C-x t b: 标签栏
C-x t C-f (FFAP): FFAP
C-x t d: 标签栏
C-x t f: 标签栏
C-x t m: 标签栏
C-x t o: 标签栏
C-x t r: 标签栏
C-x t RET: 标签栏
C-x t t: 标签栏
C-x TAB: 缩进命令
C-x TAB (Enriched mode): 丰富的缩进
C-x u: 撤消
C-x v !: 编辑 VC 命令
C-x v +: 拉/推
C-x v =: 旧版本
C-x v a: 变更日志和 VC
C-x v b c: 创建分支
C-x v b l: VC变更日志
C-x v b s: 切换分支
C-x v D: 旧版本
C-x v d: VC目录模式
C-x v g: 旧版本
C-x v G: VC 忽略
C-x v h: VC变更日志
C-x v i: 注册
C-x v I: VC变更日志
C-x v l: VC变更日志
C-x v L: VC变更日志
C-x v O: VC变更日志
C-x v P: 拉/推
C-x v r: 修订标签
C-x v s: 修订标签
C-x v u: VC 撤消
C-x v v: 基本 VC 编辑
C-x v ~: 旧版本
C-x w .: 交互式突出显示
C-x w b: 交互式突出显示
C-x w h: 交互式突出显示
C-x w i: 交互式突出显示
C-x w l: 交互式突出显示
C-x w p: 交互式突出显示
C-x w r: 交互式突出显示
C-x x g: 恢复
C-x x i: 杂项缓冲区
C-x x r: 杂项缓冲区
C-x x t: 行截断
C-x x u: 杂项缓冲区
C-x z: 重复
C-x [: 页数
C-x [ (Calendar mode): 日历单元运动
C-x [ (DocView mode): 文档视图导航
C-x \: 选择输入法
C-x ]: 页数
C-x ] (Calendar mode): 日历单元运动
C-x ] (DocView mode): 文档视图导航
C-x ^: 更改窗口
C-x `: 编译模式
C-x }: 更改窗口
C-y: 扬金
C-y (Incremental search): 搜索扬克
C-z: 退出
C-z (X windows): 帧命令
C-\: 选择输入法
C-]: 戒烟
C-^ (Incremental Search): 特殊研究
C-_: 撤消
C-_ (Dired): 标记与旗帜

D
d (Buffer Menu): 多个缓冲区
d (Calendar mode): 显示日记
d (Dired): 直接删除
D (Dired): 对文件进行操作
D (GDB Breakpoints buffer): 断点缓冲区
D (GDB speedbar): 观看表情
d (GDB threads buffer): 线程缓冲区
d (Package Menu): 套餐菜单
d (Rmail): 邮件删除
DEL (and major modes): 主要模式
DEL (Buffer Menu): 多个缓冲区
DEL (Dired): 直接删除
DEL (DocView mode): 文档视图导航
DEL (Gnus Group mode): Gnus 组缓冲区
DEL (Gnus Summary mode): Gnus 摘要缓冲区
DEL (Incremental search): 基础搜索
DEL (MS-DOS): MS-DOS 键盘
DEL (programming modes): 程序模式
DEL (Rmail): Rmail 滚动
DEL (View mode): 查看模式
DOWN: 移动点
DOWN (minibuffer history): 迷你缓冲区历史
Down-mouse-3: 菜单鼠标点击

e (Dired): 可怕的访问
e (Rmail): 邮件编辑
e (View mode): 查看模式
END: 移动点
ESC ESC ESC: 戒烟
ESC ESC ESC (Incremental Search): 基础搜索

F
f (Buffer Menu): 多个缓冲区
f (Dired): 可怕的访问
f (GDB threads buffer): 线程缓冲区
f (Rmail): 邮件回复
F1: 帮助
F10: 菜单栏
F11: 帧命令
F2 1: 两柱式
F2 2: 两柱式
F2 b: 两柱式
F2 d: 两柱式
F2 RET: 两柱式
F2 s: 两柱式
F3: 基本键盘宏
F4: 基本键盘宏

G
G (Dired): 对文件进行操作
g (Dired): 更新中
g (Package Menu): 套餐菜单
g (Rmail): Rmail 文件
g char (Calendar mode): 来自其他日历
g d (Calendar mode): 指定日期
g D (Calendar mode): 指定日期
g m (Calendar mode): 玛雅历法
g w (Calendar mode): 指定日期

H
H (Calendar mode): 写入日历文件
h (Calendar mode): 假期
H (Dired): 对文件进行操作
h (Package Menu): 套餐菜单
H (Package Menu): 套餐菜单
h (Rmail): Rmail 总结
HOME: 移动点

I (Dired): 对文件进行操作
i (Dired): Dired 中的子目录
i (Package Menu): 套餐菜单
i (Rmail): Rmail 文件
i + (Image mode): 图像模式
i - (Image mode): 图像模式
i a (Calendar mode): 特别日记条目
i b (Calendar mode): 特别日记条目
i c (Calendar mode): 特别日记条目
i c (Image mode): 图像模式
i d (Calendar mode): 添加到日记
i h (Image mode): 图像模式
i m (Calendar mode): 添加到日记
i o (Image mode): 图像模式
i r (Image mode): 图像模式
i v (Image mode): 图像模式
i w (Calendar mode): 添加到日记
i x (Image mode): 图像模式
i y (Calendar mode): 添加到日记
INSERT: 小调

J
j (Dired): 定向导航
j (Rmail): 邮件动议

K
k (Dired): 更新中
k (Rmail): 邮件标签

L
L (Dired): 对文件进行操作
l (Dired): 更新中
l (GDB threads buffer): 线程缓冲区
l (Gnus Group mode): Gnus 组缓冲区
L (Gnus Group mode): Gnus 组缓冲区
l (Help mode): 帮助模式
l (Rmail): Rmail 总结
LEFT: 移动点
LEFT, and bidirectional text: 双向编辑

中号
m (Buffer Menu): 多个缓冲区
M (Calendar mode): 月相
m (Calendar mode): 显示日记
m (Dired): 标记与旗帜
M (Dired): 对文件进行操作
m (Rmail): 邮件回复
M-!: 单壳
M-$: 拼写
M-$ (Dired): 隐藏子目录
M-%: 查询替换
M-% (Incremental search): 特殊研究
M-&: 单壳
M-': 扩展缩写
M-,: 查找标识符
M--: 论点
M-- M-c: 固定案例
M-- M-l: 固定案例
M-- M-u: 固定案例
M-.: 查找标识符
M-/: 动态缩写
M-0, tab bar: 标签栏
M-1: 论点
M-1, tab bar: 标签栏
M-9, tab bar: 标签栏
M-:: Lisp 评估
M-;: 评论命令
M-<: 移动点
M-< (Calendar mode): 移至开头或结尾
M-< (DocView mode): 文档视图导航
M-=: 职位信息
M-= (Calendar mode): 计算天数
M->: 移动点
M-> (Calendar mode): 移至开头或结尾
M-> (DocView mode): 文档视图导航
M-?: 标识符搜索
M-? (Nroff mode): 诺夫模式
M-? (Shell mode): 外壳模式
M-@: 标记对象
M-@: 
M-a: 句子
M-a (C mode): C 语言运动
M-a (Calendar mode): 移至开头或结尾
M-b: 
M-c: 案件
M-c (Incremental search): 宽松的搜索
M-d: 
M-DEL: 
M-DEL (Buffer Menu): 多个缓冲区
M-DEL (Dired): 标记与旗帜
M-DOWN: 完成命令
M-DOWN (Org Mode): 组织模式
M-Drag-mouse-1: 二次选拔
M-e: 句子
M-e (C mode): C 语言运动
M-e (Calendar mode): 移至开头或结尾
M-e (Incremental search): 重复搜索
M-f: 
M-F10: 帧命令
M-G (Dired): 子目录运动
M-g c: 移动点
M-g g: 移动点
M-g M-g: 移动点
M-g M-n: 编译模式
M-g n: 编译模式
M-g TAB: 移动点
M-h: 段落
M-i: 缩进命令
M-j: 多行注释
M-j b (Enriched mode): 丰富的理由
M-j c (Enriched mode): 丰富的理由
M-j l (Enriched mode): 丰富的理由
M-j r (Enriched mode): 丰富的理由
M-j u (Enriched mode): 丰富的理由
M-k: 句子
M-l: 案件
M-LEFT: 移动点
M-LEFT (Org Mode): 组织模式
M-m: 缩进命令
M-m (Rmail): 邮件回复
M-mouse-1: 二次选拔
M-mouse-2: 二次选拔
M-mouse-3: 二次选拔
M-n (Incremental search): 重复搜索
M-n (Log Edit mode): 日志缓冲区
M-n (Man mode): 手册页
M-n (minibuffer history): 迷你缓冲区历史
M-n (Nroff mode): 诺夫模式
M-n (Rmail): 邮件动议
M-n (Shell mode): 贝壳环
M-o b (Enriched mode): 丰富的面孔
M-o d (Enriched mode): 丰富的面孔
M-o i (Enriched mode): 丰富的面孔
M-o l (Enriched mode): 丰富的面孔
M-o o (Enriched mode): 丰富的面孔
M-o u (Enriched mode): 丰富的面孔
M-p (Incremental search): 重复搜索
M-p (Log Edit mode): 日志缓冲区
M-p (Man mode): 手册页
M-p (minibuffer history): 迷你缓冲区历史
M-p (Nroff mode): 诺夫模式
M-p (Rmail): 邮件动议
M-p (Shell mode): 贝壳环
M-q: 填充命令
M-q (C mode): 其他 C 命令
M-q (Fortran mode): 对于缩进命令
M-r: 移动点
M-r (Incremental Search): 特殊研究
M-r (Log Edit mode): 日志缓冲区
M-r (minibuffer history): 迷你缓冲区历史
M-r (Shell mode): 贝壳环
M-RET: 完成命令
M-RIGHT: 移动点
M-RIGHT (Org Mode): 组织模式
M-s ' (Incremental Search): 宽松的搜索
M-S (Enriched mode): 丰富的理由
M-s (Log Edit mode): 日志缓冲区
M-s (minibuffer history): 迷你缓冲区历史
M-s (Rmail): 邮件动议
M-s .: 符号搜索
M-s a C-s (Dired): 其他 Dired 功能
M-s a M-C-s (Dired): 其他 Dired 功能
M-s c (Incremental search): 宽松的搜索
M-s C-e (Incremental search): 搜索扬克
M-s f C-s (Dired): 定向导航
M-s f M-C-s (Dired): 定向导航
M-s h .: 交互式突出显示
M-s h f: 交互式突出显示
M-s h l: 交互式突出显示
M-s h l (Incremental Search): 特殊研究
M-s h p: 交互式突出显示
M-s h r: 交互式突出显示
M-s h r (Incremental Search): 特殊研究
M-s h u: 交互式突出显示
M-s h w: 交互式突出显示
M-s i (Incremental search): 特殊研究
M-s M-.: 搜索扬克
M-s M-<: 特殊研究
M-s M->: 特殊研究
M-s M-r (Gnus Summary mode): Gnus 摘要缓冲区
M-s M-s (Gnus Summary mode): Gnus 摘要缓冲区
M-s M-w: 单词搜索
M-s o: 其他重复搜索
M-s o (Incremental Search): 特殊研究
M-s r (Incremental Search): 特殊研究
M-s SPC (Incremental search): 宽松的搜索
M-s w: 单词搜索
M-s _: 符号搜索
M-S-x: MX
M-SPC: 删除
M-t: 转置
M-TAB: 符号完成
M-TAB (customization buffer): 更改变量
M-TAB (Incremental search): 特殊研究
M-TAB (Picture mode): 图片中的选项卡
M-TAB (Text mode): 文本模式
M-TAB, (MS-Windows): Windows 键盘
M-u: 案件
M-UP: 完成命令
M-UP (Org Mode): 组织模式
M-v: 移动点
M-v: 滚动
M-v (Calendar mode): 滚动日历
M-w: 其他杀死命令
M-x: MX
M-X: MX
M-y: 早期杀戮
M-y (Incremental search): 搜索扬克
M-z: 其他杀死命令
M-\: 删除
M-^: 缩进命令
M-^ (Fortran mode): 对于缩进命令
M-`: 菜单栏
M-{: 段落
M-{ (Calendar mode): 日历单元运动
M-{ (Dired): 标记与旗帜
M-|: 单壳
M-}: 段落
M-} (Calendar mode): 日历单元运动
M-} (Dired): 标记与旗帜
M-~: 保存命令
mouse-1: 鼠标命令
mouse-1 (mode line): 模式线鼠标
mouse-1 (on buttons): 鼠标参考
mouse-1 (scroll bar): 模式线鼠标
mouse-1 in the minibuffer (Incremental Search): 重复搜索
mouse-2: 鼠标命令
mouse-2 (GDB Breakpoints buffer): 断点缓冲区
mouse-2 (mode line): 模式线鼠标
mouse-2 (on buttons): 鼠标参考
mouse-2 in the minibuffer (Incremental search): 搜索扬克
mouse-3: 鼠标命令
mouse-3 (mode line): 模式线鼠标

N (Dired): 对文件进行操作
n (DocView mode): 文档视图导航
n (Gnus Group mode): Gnus 组缓冲区
n (Gnus Summary mode): Gnus 摘要缓冲区
n (Help mode): 帮助模式
n (Rmail): 邮件动议
next: 移动点
next: 滚动
next (Calendar mode): 滚动日历
next (DocView mode): 文档视图导航

o (Buffer Menu): 多个缓冲区
o (Calendar mode): 指定日期
o (Dired): 可怕的访问
O (Dired): 对文件进行操作
o (Occur mode): 其他重复搜索
o (Rmail): 邮件输出

p (Calendar mode): 到其他日历
P (Dired): 对文件进行操作
p (DocView mode): 文档视图导航
p (Gnus Group mode): Gnus 组缓冲区
p (Gnus Summary mode): Gnus 摘要缓冲区
p (Help mode): 帮助模式
p (Rmail): 邮件动议
p d (Calendar mode): 通用日历
PageDown: 移动点
PageDown: 滚动
PageDown (Calendar mode): 滚动日历
PageDown (DocView mode): 文档视图导航
PageUp: 移动点
PageUp: 滚动
PageUp (Calendar mode): 滚动日历
PageUp (DocView mode): 文档视图导航
prior: 移动点
prior: 滚动
prior (Calendar mode): 滚动日历
prior (DocView mode): 文档视图导航

q (Buffer Menu): 多个缓冲区
q (Calendar mode): 通用日历
q (Dired): 直接输入
Q (Dired): 对文件进行操作
q (Gnus Group mode): Gnus 组缓冲区
q (Gnus Summary mode): Gnus 摘要缓冲区
Q (Rmail summary): Rmail摘要编辑
q (Rmail summary): Rmail摘要编辑
q (Rmail): Rmail 基础知识
q (View mode): 查看模式

R (Dired): 对文件进行操作
r (GDB threads buffer): 线程缓冲区
r (Help mode): 帮助模式
r (Package Menu): 套餐菜单
r (Rmail): 邮件回复
RET: 插入文本
RET (Buffer Menu): 多个缓冲区
RET (completion in minibuffer): 完成退出
RET (Dired): 可怕的访问
RET (GDB Breakpoints buffer): 断点缓冲区
RET (GDB speedbar): 观看表情
RET (Help mode): 帮助模式
RET (Incremental search): 基础搜索
RET (Occur mode): 其他重复搜索
RET (Package Menu): 套餐菜单
RET (Shell mode): 外壳模式
RIGHT: 移动点
RIGHT, and bidirectional text: 双向编辑

S
s (Buffer Menu): 多个缓冲区
S (Buffer Menu): 多个缓冲区
S (Calendar mode): 日出日落
s (Calendar mode): 显示日记
S (Dired): 对文件进行操作
s (Dired): 更新中
s (Gnus Summary mode): Gnus 摘要缓冲区
s (Rmail): Rmail 基础知识
s (View mode): 查看模式
s 0 (Image mode): 图像模式
s o (Image mode): 图像模式
s p (Image mode): 图像模式
s s (Image mode): 图像模式
s w (Image mode): 图像模式
S-C-TAB: 标签栏
S-F10: 菜单鼠标点击
S-mouse-2: 秀秀
S-mouse-3 (FFAP): FFAP
S-SPC (Rmail): Rmail 滚动
S-TAB (customization buffer): 定制组
S-TAB (Help mode): 帮助模式
S-TAB (Org Mode): 组织模式
SPC (Calendar mode): 通用日历
SPC (completion): 完成命令
SPC (Dired): 定向导航
SPC (DocView mode): 文档视图导航
SPC (GDB Breakpoints buffer): 断点缓冲区
SPC (Gnus Group mode): Gnus 组缓冲区
SPC (Gnus Summary mode): Gnus 摘要缓冲区
SPC (Incremental search): 宽松的搜索
SPC (Rmail): Rmail 滚动
SPC (View mode): 查看模式

时间
t (Buffer Menu): 多个缓冲区
T (Buffer Menu): 多个缓冲区
t (Calendar mode): 写入日历文件
t (Dired): 标记与旗帜
T (Dired): 对文件进行操作
t (Rmail): 邮件显示
TAB (and major modes): 主要模式
TAB (completion example): 完成示例
TAB (completion): 完成命令
TAB (customization buffer): 定制组
TAB (GUD): GUD命令
TAB (Help mode): 帮助模式
TAB (indentation): 缩进
TAB (Message mode): 标题编辑
TAB (Org Mode): 组织模式
TAB (programming modes): 基本缩进
TAB (Shell mode): 外壳模式
TAB (Text mode): 文本模式
TAB, when using Chinese input methods: 输入法

U
u (Buffer Menu): 多个缓冲区
U (Buffer Menu): 多个缓冲区
u (Calendar mode): 假期
u (Dired deletion): 直接删除
u (Dired): 标记与旗帜
U (Dired): 标记与旗帜
u (Gnus Group mode): Gnus 组缓冲区
u (Package Menu): 套餐菜单
U (Package Menu): 套餐菜单
u (Rmail): 邮件删除
UP: 移动点
UP (minibuffer history): 迷你缓冲区历史

V
v (Buffer Menu): 多个缓冲区
v (Dired): 可怕的访问
v (Rmail): 邮件显示

w (Dired): 其他 Dired 功能
W (Dired): 其他 Dired 功能
w (Package Menu): 套餐菜单
w (Rmail): 邮件输出

X
x (Buffer Menu): 多个缓冲区
x (Calendar mode): 假期
x (Dired): 直接删除
X (Dired): Dired 中的 Shell 命令
x (Package Menu): 套餐菜单
x (Rmail): 邮件删除

Y (Dired): 对文件进行操作

Z
Z (Dired): 对文件进行操作


命令行选项索引

Command-Line Options Index

跳到:   +   -
索引条目 部分

+
+linenum: 行动论据

-
--background-color: 颜色 X
--basic-display: 杂项 X
--batch: 初始选项
--border-color: 颜色 X
--border-width: 边界X
--chdir: 初始选项
--color: 颜色 X
--cursor-color: 颜色 X
--daemon: 初始选项
--debug-init: 初始选项
--directory: 行动论据
--display: 初始选项
--dump-file: 初始选项
--eval: 行动论据
--execute: 行动论据
--file: 行动论据
--find-file: 行动论据
--fingerprint: 行动论据
--font: 字体X
--foreground-color: 颜色 X
--fullheight: 窗口尺寸 X
--fullscreen: 窗口尺寸 X
--fullwidth: 窗口尺寸 X
--funcall: 行动论据
--geometry: 窗口尺寸 X
--help: 行动论据
--iconic: 图标X
--init-directory: 初始选项
--insert: 行动论据
--internal-border: 边界X
--kill: 行动论据
--line-spacing: 杂项 X
--load: 行动论据
--maximized: 窗口尺寸 X
--module-assertions: 初始选项
--mouse-color: 颜色 X
--name: 资源
--no-bitmap-icon: 图标X
--no-blinking-cursor: 杂项 X
--no-build-details: 初始选项
--no-desktop: 初始选项
--no-init-file: 初始选项
--no-site-file: 初始选项
--no-site-lisp: 初始选项
--no-splash: 初始选项
--no-window-system: 初始选项
--no-x-resources: 初始选项
--quick: 初始选项
--reverse-video: 颜色 X
--script: 初始选项
--terminal: 初始选项
--title: 第十条
--user: 初始选项
--version: 行动论据
--vertical-scroll-bars: 杂项 X
--visit: 行动论据
--xrm: 资源
-bd: 颜色 X
-bg: 颜色 X
-bw: 边界X
-chdir: 初始选项
-cr: 颜色 X
-d: 初始选项
-D: 杂项 X
-daemon: 初始选项
-f: 行动论据
-fg: 颜色 X
-fh: 窗口尺寸 X
-fn: 字体X
-fs: 窗口尺寸 X
-fw: 窗口尺寸 X
-g: 窗口尺寸 X
-ib: 边界X
-l: 行动论据
-L: 行动论据
-lsp: 杂项 X
-mm: 窗口尺寸 X
-ms: 颜色 X
-nbc: 杂项 X
-nbi: 图标X
-nsl: 初始选项
-nw: 初始选项
-q: 初始选项
-Q: 初始选项
-r: 颜色 X
-rv: 颜色 X
-t: 初始选项
-T: 第十条
-u: 初始选项
-vb: 杂项 X
-x: 初始选项


命令和功能索引

Command and Function Index

跳到:   2   5  
A   B   C   D   E   F   G   H I   J   K L M N O P Q R S T U V W X Y Z                                  
索引条目 部分

2
2C-associate-buffer: 两柱式
2C-dissociate: 两柱式
2C-merge: 两柱式
2C-newline: 两柱式
2C-split: 两柱式
2C-two-columns: 两柱式

5
5x5: 娱乐项目

A
abbrev-mode: 缩写概念
abbrev-prefix-mark: 扩展缩写
abbrev-suggest-show-report: 缩写建议
abort-recursive-edit: 戒烟
activate-transient-input-method: 选择输入法
add-change-log-entry-other-window: 更改日志命令
add-change-log-entry-other-window, in Diff mode: 差异模式
add-dir-local-variable: 目录变量
add-file-local-variable: 指定文件变量
add-file-local-variable-prop-line: 指定文件变量
add-global-abbrev: 定义缩写
add-hook: 挂钩
add-mode-abbrev: 定义缩写
add-name-to-file: 复制和命名
align: 代码对齐
align-current: 代码对齐
align-entire: 代码对齐
align-highlight-rule: 代码对齐
align-regexp: 代码对齐
align-unhighlight-rule: 代码对齐
animate-birthday-present: 娱乐项目
append-next-kill: 追加击杀数
append-to-buffer: 累积文本
append-to-file: 累积文本
append-to-register: 文本寄存器
apply-macro-to-region-lines: 基本键盘宏
appt-activate: 预约
appt-add: 预约
appt-delete: 预约
apropos: 恰如其分
apropos-command: 恰如其分
apropos-documentation: 恰如其分
apropos-local-value: 恰如其分
apropos-local-variable: 恰如其分
apropos-user-option: 恰如其分
apropos-value: 恰如其分
apropos-variable: 恰如其分
ask-user-about-lock: 联锁
async-shell-command: 单壳
auto-compression-mode: 压缩文件
auto-fill-mode: 自动填充
auto-revert-mode: 自动恢复
auto-revert-tail-mode: 自动恢复
auto-save-mode: 自动保存控制

back-to-indentation: 缩进命令
backward-button: 帮助模式
backward-char: 移动点
backward-delete-char-untabify: 程序模式
backward-kill-sentence: 句子
backward-kill-word: 
backward-list: 帕伦斯移动
backward-page: 页数
backward-paragraph: 段落
backward-sentence: 句子
backward-sexp: 表达式
backward-up-list: 帕伦斯移动
backward-word: 
balance-windows: 更改窗口
beginning-of-buffer: 移动点
beginning-of-defun: 移动由 Defuns 提供
beginning-of-visual-line: 视线模式
bibtex-mode: TeX 模式
binary-overwrite-mode: 小调
blackbox: 娱乐项目
blink-cursor-mode: 光标显示
bookmark-delete: 书签
bookmark-insert: 书签
bookmark-insert-location: 书签
bookmark-jump: 书签
bookmark-load: 书签
bookmark-save: 书签
bookmark-set: 书签
bookmark-set-no-overwrite: 书签
bookmark-write: 书签
browse-url: 浏览URL
browse-url-at-mouse: 浏览URL
browse-url-at-point: 浏览URL
browse-url-of-dired-file: 其他 Dired 功能
bs-customize: 缓冲区菜单
bs-show: 缓冲区菜单
bubbles: 娱乐项目
buffer-menu: 多个缓冲区
Buffer-menu-1-window: 多个缓冲区
Buffer-menu-2-window: 多个缓冲区
Buffer-menu-backup-unmark: 多个缓冲区
Buffer-menu-bury: 多个缓冲区
Buffer-menu-delete: 多个缓冲区
Buffer-menu-delete-backwards: 多个缓冲区
Buffer-menu-execute: 多个缓冲区
Buffer-menu-mark: 多个缓冲区
Buffer-menu-not-modified: 多个缓冲区
buffer-menu-other-window: 多个缓冲区
Buffer-menu-other-window: 多个缓冲区
Buffer-menu-save: 多个缓冲区
Buffer-menu-select: 多个缓冲区
Buffer-menu-switch-other-window: 多个缓冲区
Buffer-menu-this-window: 多个缓冲区
Buffer-menu-toggle-files-only: 多个缓冲区
Buffer-menu-toggle-read-only: 多个缓冲区
Buffer-menu-unmark: 多个缓冲区
Buffer-menu-unmark-all: 多个缓冲区
Buffer-menu-unmark-all-buffers: 多个缓冲区
Buffer-menu-visit-tags-table: 多个缓冲区
bug-reference-mode: 错误参考
bug-reference-prog-mode: 错误参考
butterfly: 娱乐项目
button-describe: 主要帮助

C
c-backslash-region: 其他 C 命令
c-backward-conditional: C 语言运动
c-beginning-of-defun: C 语言运动
c-beginning-of-statement: C 语言运动
c-context-line-break: 其他 C 命令
c-end-of-defun: C 语言运动
c-end-of-statement: C 语言运动
c-fill-paragraph: 其他 C 命令
c-forward-conditional: C 语言运动
c-guess: 自定义 C 缩进
c-guess-install: 自定义 C 缩进
c-hungry-delete-backwards: 饿删除
c-hungry-delete-forward: 饿删除
c-indent-defun: C 缩进
c-indent-exp: C 缩进
c-indent-line-or-region: C 缩进
c-macro-expand: 其他 C 命令
c-mark-function: 移动由 Defuns 提供
c-set-style: 自定义 C 缩进
c-show-syntactic-information: 其他 C 命令
c-toggle-auto-newline: 电动C
c-toggle-electric-state: 电动C
c-toggle-hungry-state: 饿删除
c-ts-mode-indent-defun: C 缩进
c-ts-mode-set-style: 自定义 C 缩进
c-up-conditional: C 语言运动
calendar: 日历/日记
calendar-astro-goto-day-number: 来自其他日历
calendar-astro-print-day-number: 到其他日历
calendar-backward-day: 日历单元运动
calendar-backward-month: 日历单元运动
calendar-backward-week: 日历单元运动
calendar-backward-year: 日历单元运动
calendar-bahai-goto-date: 来自其他日历
calendar-bahai-print-date: 到其他日历
calendar-beginning-of-month: 移至开头或结尾
calendar-beginning-of-week: 移至开头或结尾
calendar-beginning-of-year: 移至开头或结尾
calendar-chinese-goto-date: 来自其他日历
calendar-chinese-print-date: 到其他日历
calendar-coptic-goto-date: 来自其他日历
calendar-coptic-print-date: 到其他日历
calendar-count-days-region: 计算天数
calendar-cursor-holidays: 假期
calendar-end-of-month: 移至开头或结尾
calendar-end-of-week: 移至开头或结尾
calendar-end-of-year: 移至开头或结尾
calendar-ethiopic-goto-date: 来自其他日历
calendar-ethiopic-print-date: 到其他日历
calendar-forward-day: 日历单元运动
calendar-forward-month: 日历单元运动
calendar-forward-week: 日历单元运动
calendar-forward-year: 日历单元运动
calendar-french-goto-date: 来自其他日历
calendar-french-print-date: 到其他日历
calendar-goto-date: 指定日期
calendar-goto-day-of-year: 指定日期
calendar-goto-today: 指定日期
calendar-hebrew-goto-date: 来自其他日历
calendar-hebrew-list-yahrzeits: 来自其他日历
calendar-hebrew-print-date: 到其他日历
calendar-islamic-goto-date: 来自其他日历
calendar-islamic-print-date: 到其他日历
calendar-iso-goto-date: 来自其他日历
calendar-iso-goto-week: 指定日期
calendar-iso-print-date: 到其他日历
calendar-julian-goto-date: 来自其他日历
calendar-julian-print-date: 到其他日历
calendar-list-holidays: 假期
calendar-lunar-phases: 月相
calendar-mark-holidays: 假期
calendar-mark-today: 日历定制
calendar-mayan-goto-long-count-date: 玛雅历法
calendar-mayan-next-calendar-round-date: 玛雅历法
calendar-mayan-next-haab-date: 玛雅历法
calendar-mayan-next-tzolkin-date: 玛雅历法
calendar-mayan-previous-haab-date: 玛雅历法
calendar-mayan-previous-tzolkin-date: 玛雅历法
calendar-mayan-print-date: 到其他日历
calendar-other-month: 指定日期
calendar-persian-goto-date: 来自其他日历
calendar-persian-print-date: 到其他日历
calendar-print-day-of-year: 通用日历
calendar-print-other-dates: 到其他日历
calendar-redraw: 通用日历
calendar-scroll-left: 滚动日历
calendar-scroll-left-three-months: 滚动日历
calendar-scroll-right: 滚动日历
calendar-scroll-right-three-months: 滚动日历
calendar-set-date-style: 日期格式
calendar-star-date: 日历定制
calendar-sunrise-sunset: 日出日落
calendar-unmark: 假期
capitalize-word: 案件
category-set-mnemonics: 视线模式
cd: 文件名
center-line: 填充命令
change-log-goto-source: 更改日志命令
change-log-merge: 更改日志命令
change-log-mode: 更改日志命令
char-category-set: 视线模式
check-parens: 括号
choose-completion: 完成命令
clean-buffer-list: 终止缓冲区
clear-rectangle: 矩形
clipboard-kill-region: 剪贴板
clipboard-kill-ring-save: 剪贴板
clipboard-yank: 剪贴板
clone-frame: 创建框架
clone-indirect-buffer: 间接缓冲区
clone-indirect-buffer-other-window: 间接缓冲区
column-number-mode: 可选模式线
comint-bol-or-process-mark: 外壳模式
comint-continue-subjob: 外壳模式
comint-copy-old-input: Shell 历史记录复制
comint-delchar-or-maybe-eof: 外壳模式
comint-delete-output: 外壳模式
comint-dynamic-list-filename…: 外壳模式
comint-dynamic-list-input-ring: 贝壳环
comint-get-next-from-history: 贝壳环
comint-history-isearch-backward-regexp: 贝壳环
comint-insert-previous-argument: 贝壳环
comint-interrupt-subjob: 外壳模式
comint-kill-input: 外壳模式
comint-magic-space: 历史参考文献
comint-next-input: 贝壳环
comint-next-prompt: Shell 历史记录复制
comint-previous-input: 贝壳环
comint-previous-prompt: Shell 历史记录复制
comint-quit-subjob: 外壳模式
comint-run: 外壳模式
comint-send-input: 外壳模式
comint-send-invisible: 外壳模式
comint-show-maximum-output: 外壳模式
comint-show-output: 外壳模式
comint-stop-subjob: 外壳模式
comint-strip-ctrl-m: 外壳模式
comint-truncate-buffer: 外壳模式
comint-write-output: 外壳模式
command-query: 禁用
comment-dwim: 评论命令
comment-kill: 评论命令
comment-line: 评论命令
comment-region: 评论命令
comment-set-column: 评论选项
compare-windows: 比较文件
compilation-next-error: 编译模式
compilation-next-file: 编译模式
compilation-previous-error: 编译模式
compilation-previous-file: 编译模式
compile: 汇编
compile (MS-DOS): MS-DOS 进程
compile-goto-error: 编译模式
completion-at-point, in programming language modes: 符号完成
completion-at-point, in Shell Mode: 外壳模式
compose-mail: 发送邮件
compose-mail-other-frame: 发送邮件
compose-mail-other-window: 发送邮件
connection-local-set-profile-variables: 连接变量
connection-local-set-profiles: 连接变量
context-menu-mode: 菜单鼠标点击
copy-dir-locals-to-file-locals: 指定文件变量
copy-dir-locals-to-file-locals-prop-line: 指定文件变量
copy-directory: 复制和命名
copy-file: 复制和命名
copy-file-locals-to-dir-locals: 目录变量
copy-matching-lines: 其他重复搜索
copy-rectangle-as-kill: 矩形
copy-rectangle-to-register: 矩形寄存器
copy-to-buffer: 累积文本
copy-to-register: 文本寄存器
count-lines-page: 页数
count-words: 职位信息
count-words-region: 职位信息
cpp-highlight-buffer: 其他 C 命令
create-fontset-from-fontset-spec: 定义字体集
cua-mode: CUA 绑定
custom-prompt-customize-unsaved-options: 保存自定义设置
Custom-save: 更改变量
Custom-set: 更改变量
customize: 轻松定制
customize-apropos: 具体定制
customize-browse: 正在浏览自定义
customize-changed: 具体定制
customize-create-theme: 创建自定义主题
customize-face: 具体定制
customize-group: 具体定制
customize-option: 具体定制
customize-saved: 具体定制
customize-themes: 自定义主题
customize-unsaved: 具体定制
cwarn-mode: 其他 C 命令
cycle-spacing: 删除

D
dabbrev-completion: 动态缩写
dabbrev-expand: 动态缩写
dbx: 启动GUD
debbugs-browse-mode: 错误参考
debug_print: 清单
decipher: 娱乐项目
default-indent-new-line: 多行注释
default-value: 当地人
define-abbrevs: 保存缩写
define-global-abbrev: 定义缩写
define-key: 初始化重新绑定
define-mail-abbrev: 邮件别名
define-mail-user-agent: 邮寄方式
define-mode-abbrev: 定义缩写
delete-backward-char: 删除
delete-blank-lines: 空行
delete-char: 删除
delete-dir-local-variable: 目录变量
delete-duplicate-lines: 删除
delete-file: 其他文件操作
delete-file-local-variable: 指定文件变量
delete-file-local-variable-prop-line: 指定文件变量
delete-frame: 帧命令
delete-horizontal-space: 删除
delete-indentation: 缩进命令
delete-other-frames: 帧命令
delete-other-windows: 更改窗口
delete-rectangle: 矩形
delete-selection-mode: 使用地区
delete-trailing-whitespace: 无用的空白
delete-whitespace-rectangle: 矩形
delete-window: 更改窗口
describe-bindings: 其他帮助
describe-categories: 正则表达式反斜杠
describe-char: 国际字符
describe-character-set: 字符集
describe-coding-system: 编码系统
describe-command: 名称帮助
describe-copying: 帮助文件
describe-distribution: 帮助文件
describe-fontset: 字体集
describe-function: 名称帮助
describe-gnu-project: 帮助文件
describe-input-method: 选择输入法
describe-key: 主要帮助
describe-key-briefly: 主要帮助
describe-keymap: 其他帮助
describe-language-environment: 语言环境
describe-mode: 其他帮助
describe-no-warranty: 帮助文件
describe-package: 套餐关键词
describe-prefix-bindings: 其他帮助
describe-repeat-maps: 重复
describe-symbol: 名称帮助
describe-syntax: 其他帮助
describe-text-properties: 编辑格式信息
describe-theme: 自定义主题
describe-variable: 名称帮助
desktop-change-dir: 保存 Emacs 会话
desktop-clear: 保存 Emacs 会话
desktop-read: 保存 Emacs 会话
desktop-revert: 保存 Emacs 会话
desktop-save: 保存 Emacs 会话
desktop-save-mode: 保存 Emacs 会话
diary: 显示日记
diary-anniversary: 特别日记条目
diary-anniversary, and sexp diary entries: 性爱日记条目
diary-astro-day-number: 性爱日记条目
diary-bahai-date: 性爱日记条目
diary-bahai-insert-entry: 非公历日记
diary-bahai-insert-monthly-entry: 非公历日记
diary-bahai-insert-yearly-entry: 非公历日记
diary-bahai-list-entries: 非公历日记
diary-bahai-mark-entries: 非公历日记
diary-block: 特别日记条目
diary-chinese-date: 性爱日记条目
diary-chinese-insert-anniversary-entry: 非公历日记
diary-chinese-insert-entry: 非公历日记
diary-chinese-insert-monthly-entry: 非公历日记
diary-chinese-insert-yearly-entry: 非公历日记
diary-chinese-list-entries: 非公历日记
diary-chinese-mark-entries: 非公历日记
diary-coptic-date: 性爱日记条目
diary-cyclic: 特别日记条目
diary-cyclic, and sexp diary entries: 性爱日记条目
diary-date: 性爱日记条目
diary-day-of-year: 性爱日记条目
diary-ethiopic-date: 性爱日记条目
diary-fancy-display: 日记展示
diary-float: 特别日记条目
diary-float, and sexp diary entries: 性爱日记条目
diary-french-date: 性爱日记条目
diary-hebrew-birthday: 性爱日记条目
diary-hebrew-date: 性爱日记条目
diary-hebrew-insert-entry: 非公历日记
diary-hebrew-insert-monthly-entry: 非公历日记
diary-hebrew-insert-yearly-entry: 非公历日记
diary-hebrew-list-entries: 非公历日记
diary-hebrew-mark-entries: 非公历日记
diary-hebrew-omer: 性爱日记条目
diary-hebrew-parasha: 性爱日记条目
diary-hebrew-rosh-hodesh: 性爱日记条目
diary-hebrew-sabbath-candles: 性爱日记条目
diary-hebrew-yahrzeit: 性爱日记条目
diary-include-other-diary-files: 精美日记展示
diary-insert-anniversary-entry: 特别日记条目
diary-insert-block-entry: 特别日记条目
diary-insert-cyclic-entry: 特别日记条目
diary-insert-entry: 添加到日记
diary-insert-monthly-entry: 添加到日记
diary-insert-weekly-entry: 添加到日记
diary-insert-yearly-entry: 添加到日记
diary-islamic-date: 性爱日记条目
diary-islamic-insert-entry: 非公历日记
diary-islamic-insert-monthly-entry: 非公历日记
diary-islamic-insert-yearly-entry: 非公历日记
diary-islamic-list-entries: 非公历日记
diary-islamic-mark-entries: 非公历日记
diary-iso-date: 性爱日记条目
diary-julian-date: 性爱日记条目
diary-lunar-phases: 性爱日记条目
diary-mail-entries: 显示日记
diary-mark-entries: 显示日记
diary-mark-included-diary-files: 精美日记展示
diary-mayan-date: 性爱日记条目
diary-offset: 特别日记条目
diary-persian-date: 性爱日记条目
diary-print-entries: 日记展示
diary-remind: 性爱日记条目
diary-show-all-entries: 显示日记
diary-simple-display: 日记展示
diary-sort-entries: 精美日记展示
diary-sunrise-sunset: 性爱日记条目
diary-view-entries: 显示日记
diff: 比较文件
diff-add-change-log-entries-other-window: 差异模式
diff-apply-hunk: 差异模式
diff-backup: 比较文件
diff-buffer-with-file: 比较文件
diff-buffers: 比较文件
diff-context->unified: 差异模式
diff-delete-trailing-whitespace: 差异模式
diff-ediff-patch: 差异模式
diff-file-kill: 差异模式
diff-file-next: 差异模式
diff-file-prev: 差异模式
diff-goto-source: 差异模式
diff-hunk-kill: 差异模式
diff-hunk-next: 差异模式
diff-hunk-prev: 差异模式
diff-ignore-whitespace-hunk: 差异模式
diff-mode: 差异模式
diff-refine-hunk: 差异模式
diff-refresh-hunk: 差异模式
diff-restrict-view: 差异模式
diff-reverse-direction: 差异模式
diff-split-hunk: 差异模式
diff-unified->context: 差异模式
digit-argument: 论点
dir-locals-set-class-variables: 目录变量
dir-locals-set-directory-class: 目录变量
dired: 直接输入
dired-at-point: FFAP
dired-change-marks: 标记与旗帜
dired-clean-directory: 标记许多文件
dired-compare-directories: 其他 Dired 功能
dired-copy-filename-as-kill: 其他 Dired 功能
dired-create-directory: 其他 Dired 功能
dired-create-empty-file: 其他 Dired 功能
dired-diff: Dired 中的比较
dired-display-file: 可怕的访问
dired-do-byte-compile: 对文件进行操作
dired-do-chgrp: 对文件进行操作
dired-do-chmod: 对文件进行操作
dired-do-chown: 对文件进行操作
dired-do-compress: 对文件进行操作
dired-do-compress-to: 对文件进行操作
dired-do-copy: 对文件进行操作
dired-do-copy-regexp: 转换文件名
dired-do-delete: 对文件进行操作
dired-do-find-regexp: 对文件进行操作
dired-do-find-regexp-and-replace: 对文件进行操作
dired-do-flagged-delete: 直接删除
dired-do-hardlink: 对文件进行操作
dired-do-hardlink-regexp: 转换文件名
dired-do-info: 对文件进行操作
dired-do-isearch: 其他 Dired 功能
dired-do-isearch-regexp: 其他 Dired 功能
dired-do-kill-lines: 更新中
dired-do-load: 对文件进行操作
dired-do-man: 对文件进行操作
dired-do-print: 对文件进行操作
dired-do-redisplay: 更新中
dired-do-relsymlink: 对文件进行操作
dired-do-relsymlink-regexp: 转换文件名
dired-do-rename: 对文件进行操作
dired-do-rename-regexp: 转换文件名
dired-do-shell-command: Dired 中的 Shell 命令
dired-do-symlink: 对文件进行操作
dired-do-symlink-regexp: 转换文件名
dired-do-touch: 对文件进行操作
dired-downcase: 转换文件名
dired-find-file: 可怕的访问
dired-find-file-other-window: 可怕的访问
dired-flag-auto-save-files: 标记许多文件
dired-flag-backup-files: 标记许多文件
dired-flag-file-deletion: 直接删除
dired-flag-files-regexp: 标记许多文件
dired-flag-garbage-files: 标记许多文件
dired-goto-file: 定向导航
dired-goto-subdir: 子目录运动
dired-hide-all: 隐藏子目录
dired-hide-details-mode: 其他 Dired 功能
dired-hide-subdir: 隐藏子目录
dired-isearch-filenames: 定向导航
dired-isearch-filenames-regexp: 定向导航
dired-jump: 直接输入
dired-jump-other-window: 直接输入
dired-mark: 标记与旗帜
dired-mark-directories: 标记与旗帜
dired-mark-executables: 标记与旗帜
dired-mark-files-containing-regexp: 标记与旗帜
dired-mark-files-regexp: 标记与旗帜
dired-mark-subdir-files: 标记与旗帜
dired-mark-symlinks: 标记与旗帜
dired-maybe-insert-subdir: Dired 中的子目录
dired-mouse-find-file-other-window: 可怕的访问
dired-next-dirline: 子目录运动
dired-next-line: 定向导航
dired-next-marked-file: 标记与旗帜
dired-next-subdir: 子目录运动
dired-number-of-marked-files: 标记与旗帜
dired-other-frame: 直接输入
dired-other-tab: 标签栏
dired-other-window: 直接输入
dired-prev-dirline: 子目录运动
dired-prev-marked-file: 标记与旗帜
dired-prev-subdir: 子目录运动
dired-previous-line: 定向导航
dired-sort-toggle-or-edit: 更新中
dired-toggle-marks: 标记与旗帜
dired-tree-down: 子目录运动
dired-tree-up: 子目录运动
dired-undo: 标记与旗帜
dired-unmark: 标记与旗帜
dired-unmark-all-files: 标记与旗帜
dired-unmark-all-marks: 标记与旗帜
dired-unmark-backward: 标记与旗帜
dired-up-directory: 可怕的访问
dired-upcase: 转换文件名
dired-view-file: 可怕的访问
dirs: 目录追踪
dirtrack-mode: 目录追踪
disable-command: 禁用
disable-theme: 自定义主题
display-battery-mode: 可选模式线
display-buffer (command): 弹出窗口
display-buffer, detailed description: 窗口选择
display-fill-column-indicator-mode: 显示边界
display-line-numbers-mode: 显示定制
display-local-help: 帮助回声
display-time: 可选模式线
dissociated-press: 娱乐项目
do-auto-save: 自动保存控制
doc-view-clear-cache: 文档视图转换
doc-view-enlarge: 文档视图导航
doc-view-first-page: 文档视图导航
doc-view-goto-page: 文档视图导航
doc-view-kill-proc: 文档视图转换
doc-view-kill-proc-and-buffer: 文档视图转换
doc-view-last-page: 文档视图导航
doc-view-minor-mode: 文档视图
doc-view-mode: 文档视图
doc-view-next-page: 文档视图导航
doc-view-open-text: 文档视图
doc-view-previous-page: 文档视图导航
doc-view-reset-slice: 文档视图切片
doc-view-scroll-down-or-previous-page: 文档视图导航
doc-view-scroll-up-or-next-page: 文档视图导航
doc-view-search: 文档视图搜索
doc-view-search-backward: 文档视图搜索
doc-view-set-slice: 文档视图切片
doc-view-set-slice-using-mouse: 文档视图切片
doc-view-show-tooltip: 文档视图搜索
doc-view-shrink: 文档视图导航
doc-view-toggle-display: 文档视图
doctex-mode: TeX 模式
doctor: 娱乐项目
dos-mode25: MS-DOS显示
dos-mode4350: MS-DOS显示
down-list: 帕伦斯移动
downcase-region: 案件
downcase-word: 案件
dunnet: 娱乐项目

edit-abbrevs: 编辑缩写
edit-kbd-macro: 编辑键盘宏
edit-tab-stops: 制表位
eldoc-doc-buffer: 编程语言文档
eldoc-mode: 编程语言文档
eldoc-print-current-symbol-info: 编程语言文档
electric-indent-mode: 缩进便利
electric-layout-mode: 程序杂项
electric-pair-mode: 匹配
electric-quote-mode: 引号
emacs-lisp-mode: Lisp 评估
emacs-version: 清单
emerge-auto-advance: Emerge 的子模式
emerge-buffers: 出现概述
emerge-buffers-with-ancestor: 出现概述
emerge-files: 出现概述
emerge-files-with-ancestor: 出现概述
emerge-skip-prefers: Emerge 的子模式
emoji-describe: 输入法
emoji-insert: 输入法
emoji-list: 输入法
emoji-search: 输入法
enable-command: 禁用
enable-theme: 自定义主题
end-of-buffer: 移动点
end-of-defun: 移动由 Defuns 提供
end-of-visual-line: 视线模式
enlarge-window: 更改窗口
enlarge-window-horizontally: 更改窗口
enriched-mode: 丰富模式
epa-dired-do-decrypt: 对文件进行操作
epa-dired-do-encrypt: 对文件进行操作
epa-dired-do-sign: 对文件进行操作
epa-dired-do-verify: 对文件进行操作
eval-buffer: Lisp 评估
eval-defun: Lisp 评估
eval-expression: Lisp 评估
eval-last-sexp: Lisp 评估
eval-print-last-sexp: Lisp交互
eval-region: Lisp 评估
eww: 电子世界
eww-open-file: 电子世界
eww-search-words: 单词搜索
exchange-point-and-mark: 设置标记
exchange-point-and-mark, in rectangle-mark-mode: 矩形
execute-extended-command: MX
exit-calendar: 通用日历
exit-recursive-edit: 递归编辑
expand-abbrev: 扩展缩写
expand-region-abbrevs: 扩展缩写

F
f90-beginning-of-block: Fortran 运动
f90-end-of-block: Fortran 运动
f90-mode: 福特兰语言
f90-next-block: Fortran 运动
f90-next-statement: Fortran 运动
f90-previous-block: Fortran 运动
f90-previous-statement: Fortran 运动
facemenu-remove-all: 编辑格式信息
facemenu-remove-face-props: 编辑格式信息
facemenu-set-background: 丰富的面孔
facemenu-set-bold: 丰富的面孔
facemenu-set-bold-italic: 丰富的面孔
facemenu-set-default: 丰富的面孔
facemenu-set-face: 丰富的面孔
facemenu-set-foreground: 丰富的面孔
facemenu-set-italic: 丰富的面孔
facemenu-set-underline: 丰富的面孔
ff-find-related-file: 其他 C 命令
ffap: FFAP
ffap-menu: FFAP
ffap-mode: FFAP
ffap-next: FFAP
fido-mode: 我完成
file-cache-add-directory: 文件名缓存
file-cache-minibuffer-complete: 文件名缓存
file-name-shadow-mode: 迷你缓冲区文件
fileloop-continue: 标识符搜索
filesets-add-buffer: 文件集
filesets-init: 文件集
filesets-remove-buffer: 文件集
fill-individual-paragraphs: 填充前缀
fill-nonuniform-paragraphs: 填充前缀
fill-paragraph: 填充命令
fill-region: 填充命令
fill-region-as-paragraph: 填充命令
find-alternate-file: 参观
find-dired: 定向并查找
find-file: 参观
find-file-at-point: FFAP
find-file-literally: 参观
find-file-other-frame: 参观
find-file-other-tab: 标签栏
find-file-other-window: 参观
find-file-read-only: 参观
find-file-read-only-other-frame: 创建框架
find-grep: Grep 搜索
find-grep-dired: 定向并查找
find-name-dired: 定向并查找
find-sibling-file: 参观
find-tag-other-window: 弹出窗口
finder-by-keyword: 套餐关键词
flush-lines: 其他重复搜索
flyspell-auto-correct-word: 拼写
flyspell-correct-word: 拼写
flyspell-correct-word-before-point: 拼写
flyspell-mode: 拼写
flyspell-prog-mode: 拼写
foldout-exit-fold: 展开
foldout-zoom-subtree: 展开
follow-mode: 跟随模式
font-lock-add-keywords: 传统字体锁定
font-lock-mode: 字体锁定
font-lock-remove-keywords: 传统字体锁定
format-decode-buffer: 丰富模式
fortran-beginning-of-block: Fortran 运动
fortran-column-ruler: Fortran 列
fortran-comment-region: Fortran 注释
fortran-end-of-block: Fortran 运动
fortran-indent-subprogram: 对于缩进命令
fortran-join-line: 对于缩进命令
fortran-mode: 福特兰语言
fortran-next-statement: Fortran 运动
fortran-previous-statement: Fortran 运动
fortran-split-line: 对于缩进命令
fortran-strip-sequence-nos: Fortran 列
fortran-window-create: Fortran 列
fortran-window-create-momentarily: Fortran 列
fortune-to-signature: 邮件娱乐
forward-button: 帮助模式
forward-char: 移动点
forward-list: 帕伦斯移动
forward-page: 页数
forward-paragraph: 段落
forward-sentence: 句子
forward-sexp: 表达式
forward-word: 
frameset-to-register: 配置寄存器
fringe-mode: 流苏

G
gdb: 启动GUD
gdb-delete-breakpoint: 断点缓冲区
gdb-display-disassembly-buffer: 其他 GDB 缓冲区
gdb-display-disassembly-for-thread: 线程缓冲区
gdb-display-io-buffer: 其他 GDB 缓冲区
gdb-display-locals-buffer: 其他 GDB 缓冲区
gdb-display-locals-for-thread: 线程缓冲区
gdb-display-memory-buffer: 其他 GDB 缓冲区
gdb-display-registers-buffer: 其他 GDB 缓冲区
gdb-display-registers-for-thread: 线程缓冲区
gdb-display-stack-for-thread: 线程缓冲区
gdb-edit-value: 观看表情
gdb-frames-select: 堆栈缓冲区
gdb-goto-breakpoint: 断点缓冲区
gdb-load-window-configuration: GDB 用户界面布局
gdb-many-windows: GDB 用户界面布局
gdb-restore-windows: GDB 用户界面布局
gdb-save-window-configuration: GDB 用户界面布局
gdb-select-thread: 线程缓冲区
gdb-toggle-breakpoint: 断点缓冲区
gdb-var-delete: 观看表情
getenv: 环境
global-auto-revert-mode: 自动恢复
global-cwarn-mode: 其他 C 命令
global-display-fill-column-indicator-mode: 显示边界
global-display-line-numbers-mode: 显示定制
global-eldoc-mode: 编程语言文档
global-font-lock-mode: 字体锁定
global-hl-line-mode: 光标显示
global-set-key: 初始化重新绑定
global-tab-line-mode: 制表线
global-text-scale-adjust: 文字比例
global-visual-line-mode: 视线模式
global-whitespace-mode: 无用的空白
global-whitespace-toggle-options: 无用的空白
glyphless-display-mode: 文字显示
gnus: Gnus 启动
gnus-group-exit: Gnus 组缓冲区
gnus-group-kill-group: Gnus 组缓冲区
gnus-group-list-all-groups: Gnus 组缓冲区
gnus-group-list-groups: Gnus 组缓冲区
gnus-group-list-killed: Gnus 组缓冲区
gnus-group-list-zombies: Gnus 组缓冲区
gnus-group-next-unread-group: Gnus 组缓冲区
gnus-group-prev-unread-group: Gnus 组缓冲区
gnus-group-read-group: Gnus 组缓冲区
gnus-group-toggle-subscription-at-point: Gnus 组缓冲区
gnus-summary-isearch-article: Gnus 摘要缓冲区
gnus-summary-next-page: Gnus 摘要缓冲区
gnus-summary-next-unread-article: Gnus 摘要缓冲区
gnus-summary-prev-page: Gnus 摘要缓冲区
gnus-summary-prev-unread-article: Gnus 摘要缓冲区
gnus-summary-search-article-backward: Gnus 摘要缓冲区
gnus-summary-search-article-forward: Gnus 摘要缓冲区
gomoku: 娱乐项目
goto-address-at-point: 转到地址模式
goto-address-mode: 转到地址模式
goto-char: 移动点
goto-followup-to: 标题编辑
goto-line: 移动点
goto-line, with an argument: 选择缓冲区
goto-line-relative: 移动点
goto-reply-to: 标题编辑
gpm-mouse-mode: 纯文本鼠标
grep: Grep 搜索
grep (MS-DOS): MS-DOS 进程
grep-find: Grep 搜索
grep-find-toggle-abbreviation: Grep 搜索
gud-cont: GUD命令
gud-def: GUD定制
gud-down: GUD命令
gud-finish: GUD命令
gud-gdb: 启动GUD
gud-gdb-complete-command: GUD命令
gud-jump: GUD命令
gud-next: GUD命令
gud-print: GUD命令
gud-refresh: GUD命令
gud-remove: GUD命令
gud-step: GUD命令
gud-stepi: GUD命令
gud-tbreak: GUD命令
gud-tooltip-mode: 调试器操作
gud-until: GUD命令
gud-up: GUD命令
gud-watch: 观看表情
guiler: 启动GUD

H
handwrite: 后记
hanoi: 娱乐项目
help-command: 帮助
help-follow: 帮助模式
help-for-help: 帮助
help-go-back: 帮助模式
help-go-forward: 帮助模式
help-goto-next-page: 帮助模式
help-goto-previous-page: 帮助模式
help-mode: 帮助模式
help-quick: 其他帮助
help-quick-toggle: 其他帮助
help-with-tutorial: 基本的
hi-lock-find-patterns: 交互式突出显示
hi-lock-mode: 交互式突出显示
hi-lock-write-interactive-patterns: 交互式突出显示
hide-ifdef-mode: 其他 C 命令
hide-sublevels: 轮廓可见性
highlight-changes-mode: 交互式突出显示
highlight-lines-matching-regexp: 交互式突出显示
highlight-phrase: 交互式突出显示
highlight-regexp: 交互式突出显示
highlight-symbol-at-point: 交互式突出显示
hl-line-mode: 光标显示
holidays: 假期
horizontal-scroll-bar-mode: 滚动条
how-many: 其他重复搜索
hs-hide-all: 秀秀
hs-hide-block: 秀秀
hs-hide-level: 秀秀
hs-minor-mode: 秀秀
hs-show-all: 秀秀
hs-show-block: 秀秀
hs-show-region: 秀秀
hs-toggle-hiding: 秀秀
hs-toggle-hiding: 秀秀
html-mode: HTML模式
htmlfontify-buffer: 印刷

ibuffer: 缓冲区菜单
icalendar-export-file: 导入日记
icalendar-export-region: 导入日记
icalendar-import-buffer: 导入日记
icalendar-import-file: 导入日记
icomplete-mode: 我完成
icomplete-vertical-mode: 我完成
ielm: Lisp交互
image-converter-add-handler: 图像模式
image-crop: 图像模式
image-cut: 图像模式
image-decrease-size: 图像模式
image-decrease-speed: 图像模式
image-dired-dired-comment-files: 图像定向
image-dired-dired-display-external: 图像定向
image-dired-dired-display-image: 图像定向
image-dired-dired-edit-comment-and-tags: 图像定向
image-dired-dired-toggle-marked-thumbs: 图像定向
image-dired-display-next: 图像定向
image-dired-display-previous: 图像定向
image-dired-display-this: 图像定向
image-dired-display-thumbs: 图像定向
image-flip-horizontally: 图像模式
image-flip-vertically: 图像模式
image-goto-frame: 图像模式
image-increase-size: 图像模式
image-increase-speed: 图像模式
image-mode: 图像模式
image-mode-copy-file-name-as-kill: 图像模式
image-mode-mark-file: 图像模式
image-mode-unmark-file: 图像模式
image-next-file: 图像模式
image-next-frame: 图像模式
image-previous-file: 图像模式
image-previous-frame: 图像模式
image-reset-speed: 图像模式
image-reverse-speed: 图像模式
image-rotate: 图像模式
image-save: 图像模式
image-toggle-animation: 图像模式
image-toggle-display: 图像模式
image-transform-fit-to-window: 图像模式
image-transform-reset-to-initial: 图像模式
image-transform-reset-to-original: 图像模式
image-transform-set-percent: 图像模式
image-transform-set-scale: 图像模式
imenu: 伊梅努
imenu-add-menubar-index: 伊梅努
increase-left-margin: 丰富的缩进
increment-register: 寄存器数量
indent-code-rigidly: 多行缩进
indent-for-tab-command: 缩进
indent-line-function: 基本缩进
indent-pp-sexp: 多行缩进
indent-region: 缩进命令
indent-relative: 缩进命令
indent-rigidly: 缩进命令
info: 其他帮助
Info-goto-emacs-command-node: 名称帮助
Info-goto-emacs-key-command-node: 主要帮助
info-lookup-file: 信息查询
info-lookup-symbol: 其他帮助
info-other-window: 其他帮助
insert-abbrevs: 保存缩写
insert-char: 插入文本
insert-file: 其他文件操作
insert-file-literally: 其他文件操作
insert-kbd-macro: 保存键盘宏
insert-register: 文本寄存器
inverse-add-global-abbrev: 定义缩写
inverse-add-mode-abbrev: 定义缩写
isearch-abort: 基础搜索
isearch-backward: 基础搜索
isearch-backward-regexp: 正则表达式搜索
isearch-cancel: 基础搜索
isearch-char-by-name: 特殊研究
isearch-complete: 特殊研究
isearch-del-char: 搜索扬克
isearch-delete-char: 基础搜索
isearch-edit-string: 重复搜索
isearch-emoji-by-name: 特殊研究
isearch-exit: 基础搜索
isearch-forward: 基础搜索
isearch-forward-regexp: 正则表达式搜索
isearch-forward-symbol: 符号搜索
isearch-forward-symbol-at-point: 符号搜索
isearch-forward-thing-at-point: 搜索扬克
isearch-forward-word: 单词搜索
isearch-help-map: 特殊研究
isearch-highlight-lines-matching-regexp: 特殊研究
isearch-highlight-regexp: 特殊研究
isearch-occur: 特殊研究
isearch-query-replace: 特殊研究
isearch-query-replace-regexp: 特殊研究
isearch-quote-char: 特殊研究
isearch-repeat-backward: 重复搜索
isearch-repeat-forward: 重复搜索
isearch-ring-advance: 重复搜索
isearch-ring-retreat: 重复搜索
isearch-toggle-case-fold: 宽松的搜索
isearch-toggle-char-fold: 宽松的搜索
isearch-toggle-input-method: 特殊研究
isearch-toggle-invisible: 特殊研究
isearch-toggle-lax-whitespace: 宽松的搜索
isearch-toggle-regexp: 特殊研究
isearch-toggle-specified-input-method: 特殊研究
isearch-toggle-symbol: 符号搜索
isearch-toggle-word: 单词搜索
isearch-transient-input-method: 特殊研究
isearch-yank-char: 搜索扬克
isearch-yank-kill: 搜索扬克
isearch-yank-line: 搜索扬克
isearch-yank-pop: 搜索扬克
isearch-yank-symbol-or-char: 搜索扬克
isearch-yank-until-char: 搜索扬克
isearch-yank-word-or-char: 搜索扬克
isearch-yank-x-selection: 搜索扬克
iso-gtex2iso: 杂项
iso-iso2gtex: 杂项
iso-iso2tex: 杂项
iso-tex2iso: 杂项
ispell: 拼写
ispell-buffer: 拼写
ispell-change-dictionary: 拼写
ispell-comment-or-string-at-point: 拼写
ispell-comments-and-strings: 拼写
ispell-complete-word: 拼写
ispell-continue: 拼写
ispell-kill-ispell: 拼写
ispell-message: 邮件杂项
ispell-region: 拼写
ispell-word: 拼写

J
jdb: 启动GUD
jump-to-register: 位置寄存器
just-one-space: 删除

K
kbd: 初始化重新绑定
kbd-macro-query: 键盘宏查询
keep-lines: 其他重复搜索
keyboard-escape-quit: 戒烟
keyboard-quit: 戒烟
keymap-global-set: 重新绑定
keymap-global-set: 初始化重新绑定
keymap-global-unset: 重新绑定
keymap-local-set: 重新绑定
keymap-local-unset: 重新绑定
keymap-set: 初始化重新绑定
keymap-substitute: 初始化示例
keymap-unset: 初始化重新绑定
kill-all-abbrevs: 定义缩写
kill-buffer: 终止缓冲区
kill-buffer-and-window: 更改窗口
kill-compilation: 汇编
kill-current-buffer: 完成命令
kill-emacs: 退出
kill-line: 线杀
kill-local-variable: 当地人
kill-matching-buffers: 终止缓冲区
kill-matching-lines: 其他重复搜索
kill-rectangle: 矩形
kill-region: 其他杀死命令
kill-ring-save: 其他杀死命令
kill-sentence: 句子
kill-sexp: 表达式
kill-some-buffers: 终止缓冲区
kill-whole-line: 线杀
kill-word: 
kmacro-add-counter: 键盘宏计数器
kmacro-bind-to-key: 保存键盘宏
kmacro-cycle-ring-next: 键盘宏环
kmacro-cycle-ring-previous: 键盘宏环
kmacro-edit-lossage: 编辑键盘宏
kmacro-edit-macro: 编辑键盘宏
kmacro-end-and-call-macro: 基本键盘宏
kmacro-end-macro: 基本键盘宏
kmacro-end-or-call-macro: 基本键盘宏
kmacro-end-or-call-macro-repeat: 键盘宏环
kmacro-insert-counter: 键盘宏计数器
kmacro-name-last-macro: 保存键盘宏
kmacro-redisplay: 基本键盘宏
kmacro-set-counter: 键盘宏计数器
kmacro-set-format: 键盘宏计数器
kmacro-start-macro: 基本键盘宏
kmacro-start-macro-or-insert-counter: 基本键盘宏
kmacro-step-edit-macro: 键盘宏步进编辑
kmacro-to-register: 键盘宏寄存器

L
latex-close-block: 乳胶编辑
latex-electric-env-pair-mode: 乳胶编辑
latex-insert-block: 乳胶编辑
latex-mode: TeX 模式
left-char: 移动点
left-char, and bidirectional text: 双向编辑
left-word: 移动点
lgrep: Grep 搜索
life: 娱乐项目
line-number-mode: 可选模式线
lisp-eval-defun: 外部 Lisp
lisp-interaction-mode: Lisp交互
list-abbrevs: 编辑缩写
list-bookmarks: 书签
list-buffers: 列表缓冲区
list-character-sets: 字符集
list-charset-chars: 字符集
list-coding-systems: 编码系统
list-colors-display: 颜色
list-command-history: 重复
list-directory: 目录
list-faces-display: 面孔
list-holidays: 假期
list-input-methods: 选择输入法
list-matching-lines: 其他重复搜索
list-packages: 套餐菜单
list-tags: 列表标识符
load: Lisp 库
load-file: Lisp 库
load-library: Lisp 库
load-theme: 自定义主题
locate: 定向并查找
locate-with-filter: 定向并查找
log-edit-done: 日志缓冲区
log-edit-generate-changelog-from-diff: 日志缓冲区
log-edit-insert-changelog: 日志缓冲区
log-edit-show-diff: 日志缓冲区
log-edit-show-files: 日志缓冲区
log-view-toggle-entry-display: VC变更日志
lossage-size: 其他帮助
lpr-buffer: 印刷
lpr-region: 印刷
lunar-phases: 月相

中号
mail-abbrev-complete-alias: 邮件别名
mail-abbrev-insert-alias: 邮件别名
mail-add-attachment: 邮件杂项
mail-fill-yanked-message: 引用邮件
mail-text: 标题编辑
make-frame-command: 创建框架
make-frame-on-display: 多显示器
make-frame-on-monitor: 多显示器
make-indirect-buffer: 间接缓冲区
make-local-variable: 当地人
make-symbolic-link: 复制和命名
make-variable-buffer-local: 当地人
man: 手册页
mark-defun: 移动由 Defuns 提供
mark-page: 页数
mark-paragraph: 段落
mark-sexp: 标记对象
mark-whole-buffer: 标记对象
mark-word: 标记对象
menu-bar-mode: 菜单栏
menu-bar-open: 菜单栏
merge-mail-abbrevs: 邮件别名
message-goto-bcc: 标题编辑
message-goto-cc: 标题编辑
message-goto-fcc: 标题编辑
message-goto-subject: 标题编辑
message-goto-to: 标题编辑
message-insert-signature: 邮件签名
message-send: 邮件发送
message-send-and-exit: 邮件发送
message-tab: 标题编辑
message-yank-original: 引用邮件
message-yank-prefix: 引用邮件
minibuffer-choose-completion: 完成命令
minibuffer-complete: 完成命令
minibuffer-complete-and-exit: 完成退出
minibuffer-complete-word: 完成命令
minibuffer-depth-indicate-mode: 迷你缓冲区编辑
minibuffer-electric-default-mode: 基本迷你缓冲区
minibuffer-inactive-mode: 迷你缓冲区编辑
minibuffer-next-completion: 完成命令
minibuffer-previous-completion: 完成命令
mml-attach-file: 邮件杂项
modify-category-entry: 视线模式
morse-region: 娱乐项目
mouse-avoidance-mode: 鼠标回避
mouse-buffer-menu: 缓冲区菜单
mouse-save-then-kill: 鼠标命令
mouse-secondary-save-then-kill: 二次选拔
mouse-set-point: 鼠标命令
mouse-set-region: 鼠标命令
mouse-set-secondary: 二次选拔
mouse-start-secondary: 二次选拔
mouse-wheel-mode: 鼠标命令
mouse-wheel-text-scale: 文字比例
mouse-yank-at-click: 鼠标命令
mouse-yank-primary: 鼠标命令
mouse-yank-secondary: 二次选拔
move-beginning-of-line: 移动点
move-end-of-line: 移动点
move-file-to-trash: 其他文件操作
move-to-column: 移动点
move-to-window-line-top-bottom: 移动点
mpuz: 娱乐项目
msb-mode: 缓冲区菜单
msdos-set-mouse-buttons: MS-DOS鼠标
multi-isearch-buffers: 其他重复搜索
multi-isearch-buffers-regexp: 其他重复搜索
multi-isearch-files: 其他重复搜索
multi-isearch-files-regexp: 其他重复搜索
multi-occur: 其他重复搜索
multi-occur-in-matching-buffers: 其他重复搜索

narrow-to-defun: 缩小范围
narrow-to-page: 缩小范围
narrow-to-region: 缩小范围
nato-region: 娱乐项目
negative-argument: 论点
next-buffer: 选择缓冲区
next-completion: 完成命令
next-error: 编译模式
next-error-follow-minor-mode: 编译模式
next-error-select-buffer: 编译模式
next-history-element: 迷你缓冲区历史
next-line: 移动点
next-line-or-history-element: 迷你缓冲区历史
next-logical-line: 视线模式
next-matching-history-element: 迷你缓冲区历史
next-window-any-frame: 其他窗口
normal-erase-is-backspace-mode: DEL 不删除
normal-mode: 选择模式
not-modified: 保存命令
nroff-backward-text-line: 诺夫模式
nroff-count-text-lines: 诺夫模式
nroff-electric-mode: 诺夫模式
nroff-forward-text-line: 诺夫模式
nroff-mode: 诺夫模式
number-to-register: 寄存器数量
nxml-mode: HTML模式

occur: 其他重复搜索
open-dribble-file: 清单
open-line: 空行
open-rectangle: 矩形
open-termscript: 清单
org-agenda: 组织组织者
org-agenda-file-to-front: 组织组织者
org-cycle: 组织模式
org-deadline: 组织组织者
org-export-dispatch: 组织创作
org-metadown: 组织模式
org-metaleft: 组织模式
org-metaright: 组织模式
org-metaup: 组织模式
org-mode: 组织模式
org-schedule: 组织组织者
org-shifttab: 组织模式
org-todo: 组织组织者
other-frame: 帧命令
other-tab-prefix: 标签栏
other-window: 其他窗口
outline-backward-same-level: 轮廓运动
outline-cycle: 轮廓可见性
outline-cycle-buffer: 轮廓可见性
outline-forward-same-level: 轮廓运动
outline-hide-body: 轮廓可见性
outline-hide-entry: 轮廓可见性
outline-hide-leaves: 轮廓可见性
outline-hide-other: 轮廓可见性
outline-hide-subtree: 轮廓可见性
outline-minor-mode: 轮廓小调模式
outline-mode: 轮廓模式
outline-next-visible-heading: 轮廓运动
outline-previous-visible-heading: 轮廓运动
outline-show-all: 轮廓可见性
outline-show-branches: 轮廓可见性
outline-show-children: 轮廓可见性
outline-show-entry: 轮廓可见性
outline-show-subtree: 轮廓可见性
outline-up-heading: 轮廓运动
overwrite-mode: 小调

package-activate-all: 包安装
package-browse-url: 套餐菜单
package-install: 包安装
package-install-file: 打包文件
package-menu-describe-package: 套餐菜单
package-menu-execute: 套餐菜单
package-menu-filter-by-archive: 套餐菜单
package-menu-filter-by-description: 套餐菜单
package-menu-filter-by-keyword: 套餐菜单
package-menu-filter-by-name: 套餐菜单
package-menu-filter-by-name-or-description: 套餐菜单
package-menu-filter-by-status: 套餐菜单
package-menu-filter-by-version: 套餐菜单
package-menu-filter-clear: 套餐菜单
package-menu-filter-marked: 套餐菜单
package-menu-filter-upgradable: 套餐菜单
package-menu-hide-package: 套餐菜单
package-menu-mark-delete: 套餐菜单
package-menu-mark-install: 套餐菜单
package-menu-mark-obsolete-for-deletion: 套餐菜单
package-menu-mark-unmark: 套餐菜单
package-menu-mark-upgrades: 套餐菜单
package-menu-quick-help: 套餐菜单
package-menu-toggle-hiding: 套餐菜单
package-quickstart-refresh: 包安装
package-recompile: 包安装
package-recompile-all: 包安装
package-report-bug: 获取包源
package-upgrade: 包安装
package-upgrade-all: 包安装
package-vc-checkout: 获取包源
package-vc-install: 获取包源
package-vc-install-from-checkout: 获取包源
package-vc-prepare-patch: 获取包源
package-vc-rebuild: 获取包源
paragraph-indent-minor-mode: 文本模式
paragraph-indent-text-mode: 文本模式
pdb: 启动GUD
perldb: 启动GUD
picture-backward-clear-column: 基本图片
picture-backward-column: 基本图片
picture-clear-column: 基本图片
picture-clear-line: 基本图片
picture-clear-rectangle: 图片中的矩形
picture-clear-rectangle-to-register: 图片中的矩形
picture-forward-column: 基本图片
picture-mode: 图片模式
picture-motion: 插入图片
picture-motion-reverse: 插入图片
picture-move-down: 基本图片
picture-move-up: 基本图片
picture-movement-down: 插入图片
picture-movement-left: 插入图片
picture-movement-ne: 插入图片
picture-movement-nw: 插入图片
picture-movement-right: 插入图片
picture-movement-se: 插入图片
picture-movement-sw: 插入图片
picture-movement-up: 插入图片
picture-newline: 基本图片
picture-open-line: 基本图片
picture-set-tab-stops: 图片中的选项卡
picture-tab: 图片中的选项卡
picture-tab-search: 图片中的选项卡
picture-yank-rectangle: 图片中的矩形
picture-yank-rectangle-from-register: 图片中的矩形
plain-tex-mode: TeX 模式
point-to-register: 位置寄存器
pong: 娱乐项目
pop-global-mark: 全球标志戒指
pr-interface: 印刷包装
prefer-coding-system: 识别编码
prepend-to-buffer: 累积文本
prepend-to-register: 文本寄存器
prettify-symbols-mode: 程序杂项
previous-buffer: 选择缓冲区
previous-completion: 完成命令
previous-history-element: 迷你缓冲区历史
previous-line: 移动点
previous-line-or-history-element: 迷你缓冲区历史
previous-logical-line: 视线模式
previous-matching-history-element: 迷你缓冲区历史
print-buffer: 印刷
print-buffer (MS-DOS): 视窗打印
print-region: 印刷
print-region (MS-DOS): 视窗打印
prog-indent-sexp: C 缩进
project-async-shell-command: 项目文件命令
project-compile: 项目文件命令
project-dired: 项目文件命令
project-eshell: 项目文件命令
project-find-dir: 项目文件命令
project-find-file: 项目文件命令
project-find-regexp: 项目文件命令
project-forget-project: 管理项目
project-kill-buffers: 项目缓冲区命令
project-list-buffers: 项目缓冲区命令
project-query-replace-regexp: 项目文件命令
project-search: 项目文件命令
project-shell: 项目文件命令
project-shell-command: 项目文件命令
project-switch-project: 切换项目
project-switch-to-buffer: 项目缓冲区命令
project-vc-dir: 项目文件命令
ps-despool: 后记
ps-print-buffer: 后记
ps-print-buffer (MS-DOS): 视窗打印
ps-print-buffer-with-faces: 后记
ps-print-region: 后记
ps-print-region-with-faces: 后记
ps-spool-buffer: 后记
ps-spool-buffer (MS-DOS): 视窗打印
ps-spool-buffer-with-faces: 后记
ps-spool-region: 后记
ps-spool-region-with-faces: 后记
pwd: 文件名

quail-set-keyboard-layout: 选择输入法
quail-show-key: 选择输入法
quail-translation-keymap: 输入法
query-replace: 查询替换
query-replace-regexp: 查询替换
quietly-read-abbrev-file: 保存缩写
quit-window: 完成命令
quit-window: 多个缓冲区
quit-window, in Dired buffers: 直接输入
quoted-insert: 插入文本

re-search-backward: 正则表达式搜索
re-search-forward: 正则表达式搜索
read-abbrev-file: 保存缩写
read-only-mode: 杂项缓冲区
rebuild-mail-abbrevs: 邮件别名
recenter: 重心调整
recenter-other-window: 其他窗口
recenter-top-bottom: 重心调整
recentf-edit-list: 文件便利
recentf-mode: 文件便利
recentf-open: 文件便利
recentf-save-list: 文件便利
recode-file-name: 文件名编码
recode-region: 文本编码
recompile: 汇编
recover-file: 恢复
recover-session: 恢复
rectangle: 矩形
rectangle-exchange-point-and-mark: 矩形
rectangle-mark-mode: 矩形
remove-hook: 挂钩
rename-buffer: 杂项缓冲区
rename-file: 复制和命名
rename-uniquely: 杂项缓冲区
repeat: 重复
repeat-complex-command: 重复
repeat-mode: 重复
replace-regexp: 正则表达式替换
replace-string: 无条件替换
report-emacs-bug: 清单
reposition-window: 重心调整
reveal-mode: 轮廓可见性
reverse-region: 排序
revert-buffer: 恢复
revert-buffer (Dired): 更新中
revert-buffer-quick: 恢复
revert-buffer-with-coding-system: 文本编码
revert-buffer-with-fine-grain: 恢复
rgrep: Grep 搜索
right-char: 移动点
right-char, and bidirectional text: 双向编辑
right-word: 移动点
rmail: 远程邮件
rmail-abort-edit: 邮件编辑
rmail-add-label: 邮件标签
rmail-beginning-of-message: Rmail 滚动
rmail-bury: Rmail 基础知识
rmail-cease-edit: 邮件编辑
rmail-continue: 邮件回复
rmail-delete-backward: 邮件删除
rmail-delete-forward: 邮件删除
rmail-edit-current-message: 邮件编辑
rmail-end-of-message: Rmail 滚动
rmail-epa-decrypt: 邮件显示
rmail-expunge: 邮件删除
rmail-expunge-and-save: Rmail 基础知识
rmail-first-message: 邮件动议
rmail-forward: 邮件回复
rmail-get-new-mail: Rmail 文件
rmail-input: Rmail 文件
rmail-kill-label: 邮件标签
rmail-last-message: 邮件动议
rmail-mail: 邮件回复
rmail-mime: 邮件显示
rmail-mime-next-item: 邮件显示
rmail-mime-previous-item: 邮件显示
rmail-mime-toggle-hidden: 邮件显示
rmail-mode: 远程邮件
rmail-next-labeled-message: 邮件标签
rmail-next-message: 邮件动议
rmail-next-same-subject: 邮件动议
rmail-next-undeleted-message: 邮件动议
rmail-output: 邮件输出
rmail-output-as-seen: 邮件输出
rmail-output-body-to-file: 邮件输出
rmail-previous-labeled-message: 邮件标签
rmail-previous-message: 邮件动议
rmail-previous-same-subject: 邮件动议
rmail-previous-undeleted-message: 邮件动议
rmail-quit: Rmail 基础知识
rmail-redecode-body: 邮件编码
rmail-reply: 邮件回复
rmail-resend: 邮件回复
rmail-retry-failure: 邮件回复
rmail-search: 邮件动议
rmail-show-message: 邮件动议
rmail-sort-by-author: 邮件排序
rmail-sort-by-correspondent: 邮件排序
rmail-sort-by-date: 邮件排序
rmail-sort-by-labels: 邮件排序
rmail-sort-by-lines: 邮件排序
rmail-sort-by-recipient: 邮件排序
rmail-sort-by-subject: 邮件排序
rmail-summary: Rmail 总结
rmail-summary-bury: Rmail摘要编辑
rmail-summary-by-labels: Rmail 总结
rmail-summary-by-recipients: Rmail 总结
rmail-summary-by-regexp: Rmail 总结
rmail-summary-by-senders: Rmail 总结
rmail-summary-by-topic: Rmail 总结
rmail-summary-quit: Rmail摘要编辑
rmail-summary-undelete-many: Rmail摘要编辑
rmail-summary-wipe: Rmail摘要编辑
rmail-toggle-header: 邮件显示
rmail-undelete-previous-message: 邮件删除
rot13-other-window: Rmail Rot13
rot13-region: Rmail Rot13
run-lisp: 外部 Lisp
run-scheme: 外部 Lisp

S
save-buffer: 保存命令
save-buffers-kill-terminal: 退出
save-some-buffers: 保存命令
scheme-mode: 外部 Lisp
scratch-buffer: Lisp交互
scroll-bar-mode: 滚动条
scroll-down-command: 滚动
scroll-down-line: 滚动
scroll-left: 水平滚动
scroll-other-window: 其他窗口
scroll-other-window-down: 其他窗口
scroll-right: 水平滚动
scroll-up-command: 滚动
scroll-up-line: 滚动
sdb: 启动GUD
search-backward: 非增量搜索
search-forward: 非增量搜索
select-frame-by-name: 文本终端
serial-term: 串口终端
server-edit: 调用 emacsclient
server-edit-abort: 调用 emacsclient
server-eval-at: Emacs服务器
server-generate-key: TCP Emacs 服务器
server-start: Emacs服务器
server-stop-automatically: Emacs服务器
set-buffer-file-coding-system: 文本编码
set-buffer-process-coding-system: 通讯编码
set-face-background: 颜色
set-face-foreground: 颜色
set-file-modes: 其他文件操作
set-file-name-coding-system: 文件名编码
set-fill-column: 填充命令
set-fill-prefix: 填充前缀
set-fontset-font: 修改字体集
set-frame-name: 文本终端
set-fringe-style: 流苏
set-goal-column: 移动点
set-input-method: 选择输入法
set-justification-center: 丰富的理由
set-justification-full: 丰富的理由
set-justification-left: 丰富的理由
set-justification-none: 丰富的理由
set-justification-right: 丰富的理由
set-keyboard-coding-system: 端子编码
set-language-environment: 语言环境
set-left-margin: 丰富的缩进
set-locale-environment: 语言环境
set-mark-command: 设置标记
set-next-selection-coding-system: 通讯编码
set-right-margin: 丰富的缩进
set-selection-coding-system: 通讯编码
set-selective-display: 选择性显示
set-terminal-coding-system: 端子编码
set-variable: 正在检查
set-visited-file-name: 保存命令
setenv: 环境
setopt: 正在检查
setq-default: 当地人
sgml-attributes: HTML模式
sgml-close-tag: HTML模式
sgml-delete-tag: HTML模式
sgml-mode: HTML模式
sgml-name-8bit-mode: HTML模式
sgml-name-char: HTML模式
sgml-skip-tag-backward: HTML模式
sgml-skip-tag-forward: HTML模式
sgml-tag: HTML模式
sgml-tag-help: HTML模式
sgml-tags-invisible: HTML模式
sgml-validate: HTML模式
shadow-initialize: 文件阴影
shell: 交互式外壳
shell-backward-command: 外壳模式
shell-command: 单壳
shell-command-on-region: 单壳
shell-dynamic-complete-command: 外壳选项
shell-forward-command: 外壳模式
shell-pushd-dextract: 外壳选项
shell-pushd-dunique: 外壳选项
shell-pushd-tohome: 外壳选项
shortdoc: 名称帮助
show-paren-local-mode: 匹配
show-paren-mode: 匹配
shrink-window-horizontally: 更改窗口
shrink-window-if-larger-than-buffer: 更改窗口
size-indication-mode: 可选模式线
slitex-mode: TeX 模式
smerge-mode: 比较文件
snake: 娱乐项目
solitaire: 娱乐项目
sort-columns: 排序
sort-fields: 排序
sort-lines: 排序
sort-numeric-fields: 排序
sort-pages: 排序
sort-paragraphs: 排序
split-line: 缩进命令
split-window-below: 分割窗口
split-window-right: 分割窗口
spook: 邮件娱乐
standard-display-8bit: 单字节模式
string-insert-rectangle: 矩形
string-rectangle: 矩形
subword-mode: 混合大小写单词
sunrise-sunset: 日出日落
superword-mode: 程序杂项
suspend-frame: 退出
switch-to-buffer: 选择缓冲区
switch-to-buffer-other-frame: 选择缓冲区
switch-to-buffer-other-tab: 标签栏
switch-to-buffer-other-window: 选择缓冲区
switch-to-completions: 完成命令

时间
tab-bar-history-back: 标签栏
tab-bar-history-forward: 标签栏
tab-bar-history-mode: 标签栏
tab-bar-mode: 标签栏
tab-close: 标签栏
tab-close-other: 标签栏
tab-last: 标签栏
tab-move: 标签栏
tab-new: 标签栏
tab-next: 标签栏
tab-previous: 标签栏
tab-recent: 标签栏
tab-rename: 标签栏
tab-select: 标签栏
tab-switch: 标签栏
tab-to-tab-stop: 缩进命令
tab-undo: 标签栏
tabify: 只是空间
table-backward-cell: 单元命令
table-capture: 表转换
table-fixed-width-mode: 基于文本的表格
table-forward-cell: 单元命令
table-generate-source: 表杂项
table-heighten-cell: 单元命令
table-insert: 表创建
table-insert-column: 表格行和列
table-insert-row: 表格行和列
table-insert-sequence: 表杂项
table-justify: 单元格对齐
table-narrow-cell: 单元命令
table-query-dimension: 表杂项
table-recognize: 表格识别
table-recognize-cell: 表格识别
table-recognize-region: 表格识别
table-recognize-table: 表格识别
table-release: 表转换
table-shorten-cell: 单元命令
table-span-cell: 单元命令
table-split-cell: 单元命令
table-split-cell-horizontally: 单元命令
table-split-cell-vertically: 单元命令
table-unrecognize: 表格识别
table-unrecognize-cell: 表格识别
table-unrecognize-region: 表格识别
table-unrecognize-table: 表格识别
table-widen-cell: 单元命令
tabulated-list-narrow-current-column: 多个缓冲区
tabulated-list-sort: 多个缓冲区
tabulated-list-widen-current-column: 多个缓冲区
tags-next-file: 列表标识符
tags-query-replace: 标识符搜索
tags-search: 标识符搜索
temp-buffer-resize-mode: 临时展示
term: 终端仿真器
term-char-mode: 期限模式
term-line-mode: 期限模式
term-pager-toggle: 期限模式
tetris: 娱乐项目
tex-bibtex-file: TeX 打印
tex-buffer: TeX 打印
tex-compile: TeX 打印
tex-file: TeX 打印
tex-insert-braces: 文本编辑
tex-insert-quote: 文本编辑
tex-kill-job: TeX 打印
tex-mode: TeX 模式
tex-print: TeX 打印
tex-recenter-output-buffer: TeX 打印
tex-region: TeX 打印
tex-terminate-paragraph: 文本编辑
tex-validate-region: 文本编辑
tex-view: TeX 打印
text-mode: 文本模式
text-scale-adjust: 文字比例
text-scale-decrease: 文字比例
text-scale-increase: 文字比例
text-scale-mode: 文字比例
text-scale-pinch: 文字比例
text-scale-set: 文字比例
theme-choose-variant: 自定义主题
thumbs-mode: 图像模式
time-stamp: 时间戳
timeclock-change: 时间间隔
timeclock-in: 时间间隔
timeclock-mode-line-display: 时间间隔
timeclock-out: 时间间隔
timeclock-reread-log: 时间间隔
timeclock-when-to-leave: 时间间隔
timeclock-workday-remaining: 时间间隔
tmm-menubar: 菜单栏
toggle-debug-on-error: 清单
toggle-frame-fullscreen: 帧命令
toggle-frame-maximized: 帧命令
toggle-frame-tab-bar: 标签栏
toggle-input-method: 选择输入法
toggle-scroll-bar: 滚动条
toggle-truncate-lines: 行截断
tool-bar-mode: 工具栏
tooltip-mode: 工具提示
top-level: 戒烟
transient-mark-mode: 禁用瞬态标记
transpose-chars: 转置
transpose-lines: 转置
transpose-paragraphs: 转置
transpose-regions: 转置
transpose-sentences: 转置
transpose-sexps: 表达式
transpose-words: 转置
tty-suppress-bold-inverse-default-colors: 显示定制

U
uncomment-region: 评论命令
undelete-frame: 帧命令
undelete-frame-mode: 帧命令
undigestify-rmail-message: 邮件文摘
undo: 撤消
undo-only: 撤消
undo-redo: 撤消
unexpand-abbrev: 扩展缩写
unforward-rmail-message: 邮件回复
unhighlight-regexp: 交互式突出显示
universal-argument: 论点
universal-coding-system-argument: 文本编码
unmorse-region: 娱乐项目
untabify: 只是空间
up-list: 文本编辑
upcase-region: 案件
upcase-word: 案件
url-handler-mode: 浏览URL
use-hard-newlines: 硬换行符和软换行符

V
vc-annotate: 旧版本
vc-create-branch: 创建分支
vc-create-tag: 修订标签
vc-delete-file: VC 删除/重命名
vc-diff: 旧版本
vc-dir: VC目录模式
vc-dir-mark: VC 目录命令
vc-dir-mark-all-files: VC 目录命令
vc-dir-mark-by-regexp: VC 目录命令
vc-dir-mark-registered-files: VC 目录命令
vc-ediff: 旧版本
vc-edit-next-command: 编辑 VC 命令
vc-ignore: VC 忽略
vc-insert-headers: 版本标头
vc-log-incoming: VC变更日志
vc-log-outgoing: VC变更日志
vc-log-search: VC变更日志
vc-next-action: 基本 VC 编辑
vc-prepare-patch: 准备补丁
vc-print-branch-log: VC变更日志
vc-print-log: VC变更日志
vc-print-root-log: VC变更日志
vc-pull: 拉/推
vc-push: 拉/推
vc-refresh-state: 版本控制
vc-region-history: VC变更日志
vc-register: 注册
vc-rename-file: VC 删除/重命名
vc-retrieve-tag: 修订标签
vc-revert: VC 撤消
vc-revision-other-window: 旧版本
vc-root-diff: 旧版本
vc-root-version-diff: 旧版本
vc-state-refresh: 版本控制
vc-switch-branch: 切换分支
vc-update-change-log: 变更日志和 VC
view-buffer: 查看模式
view-echo-area-messages: 其他帮助
view-emacs-debugging: 帮助文件
view-emacs-FAQ: 帮助文件
view-emacs-news: 帮助文件
view-emacs-problems: 帮助文件
view-emacs-todo: 帮助文件
View-exit: 查看模式
view-external-packages: 帮助文件
view-file: 查看模式
view-hello-file: 国际字符
view-lossage: 其他帮助
view-order-manuals: 帮助文件
View-quit: 查看模式
view-register: 寄存器
visit-tags-table: 选择标签表
visual-line-mode: 视线模式

w32-add-untranslated-filesystem: 文本和二进制
w32-find-non-USB-fonts: Windows 字体
w32-register-hot-key: Windows 键盘
w32-remove-untranslated-filesystem: 文本和二进制
w32-set-console-codepage: 端子编码
w32-set-ime-open-status: Windows 键盘
w32-shell-execute: Windows进程
w32-unregister-hot-key: Windows 键盘
wdired-change-to-wdired-mode: 维雷德
wdired-finish-edit: 维雷德
what-cursor-position: 职位信息
what-cursor-position, and international characters: 国际字符
what-line: 职位信息
what-page: 页数
where-is: 主要帮助
which-function-mode: 哪个功能
whitespace-mode: 无用的空白
whitespace-toggle-options: 无用的空白
widen: 缩小范围
widget-backward: 定制组
widget-complete: 更改变量
widget-describe: 主要帮助
widget-forward: 定制组
windmove-default-keybindings: 窗口便利
windmove-delete-default-keybindings: 窗口便利
windmove-display-default-keybindings: 窗口便利
windmove-right: 窗口便利
windmove-swap-states-default-keybindings: 窗口便利
window-configuration-to-register: 配置寄存器
window-divider-mode: 窗隔板
winner-mode: 窗口便利
woman: 手册页
word-search-backward: 单词搜索
word-search-forward: 单词搜索
write-abbrev-file: 保存缩写
write-file: 保存命令
write-region: 其他文件操作

X
xdb: 启动GUD
xref-etags-mode: 查找标识符
xref-find-apropos: 查找标识符
xref-find-definitions: 查找标识符
xref-find-definitions-other-frame: 查找标识符
xref-find-definitions-other-window: 查找标识符
xref-find-references: 标识符搜索
xref-find-references-and-replace: 标识符搜索
xref-go-back: 查找标识符
xref-go-forward: 查找标识符
xref-next-group: 外部参照命令
xref-next-line: 外部参照命令
xref-prev-group: 外部参照命令
xref-prev-line: 外部参照命令
xref-query-replace-in-results: 标识符搜索
xref-quit: 外部参照命令
xref-quit-and-pop-marker-stack: 外部参照命令
xref-revert-buffer: 外部参照命令
xref-select-and-show-xref: 外部参照命令
xref-show-location-at-point: 外部参照命令
xwidget-webkit-browse-history: 嵌入式 WebKit 小部件
xwidget-webkit-browse-url: 嵌入式 WebKit 小部件
xwidget-webkit-edit-mode: 嵌入式 WebKit 小部件
xwidget-webkit-isearch-mode: 嵌入式 WebKit 小部件
xwidget-webkit-mode: 嵌入式 WebKit 小部件

yank: 扬金
yank-media: 剪贴板
yank-pop: 早期杀戮
yank-rectangle: 矩形

Z
zap-to-char: 其他杀死命令
zap-up-to-char: 其他杀死命令
zone: 娱乐项目
zrgrep: Grep 搜索


变量索引

Variable Index

跳到:   A   B   C   D   E   F   G   H I   J   K L M N O P Q R S T U V W X Y                                
索引条目 部分

A
abbrev-all-caps: 扩展缩写
abbrev-file-name: 保存缩写
abbrev-suggest: 缩写建议
abbrev-suggest-hint-threshold: 缩写建议
adaptive-fill-first-line-regexp: 自适应填充
adaptive-fill-function: 自适应填充
adaptive-fill-mode: 自适应填充
adaptive-fill-regexp: 自适应填充
add-log-always-start-new-record: 更改日志命令
add-log-dont-create-changelog-file: 更改日志命令
add-log-keep-changes-together: 更改日志命令
align-default-spacing: 代码对齐
align-exclude-rules-list: 代码对齐
align-indent-before-aligning: 代码对齐
align-mode-exclude-rules-list: 代码对齐
align-mode-rules-list: 代码对齐
align-region-separate: 代码对齐
align-rules-list: 代码对齐
align-to-tab-stop: 代码对齐
ange-ftp-default-user: 远程文件
ange-ftp-gateway-host: 远程文件
ange-ftp-generate-anonymous-password: 远程文件
ange-ftp-make-backup-files: 远程文件
ange-ftp-smart-gateway: 远程文件
appt-audible: 预约
appt-delete-window-function: 预约
appt-disp-window-function: 预约
appt-display-diary: 预约
appt-display-duration: 预约
appt-display-format: 预约
appt-display-mode-line: 预约
appt-message-warning-time: 预约
appt-warning-time-regexp: 预约
apropos-do-all: 恰如其分
apropos-documentation-sort-by-scores: 恰如其分
apropos-sort-by-scores: 恰如其分
async-shell-command-buffer: 单壳
async-shell-command-display-buffer: 单壳
async-shell-command-width: 单壳
auth-source-save-behavior: 验证
auth-sources: 验证
auto-coding-alist: 识别编码
auto-coding-functions: 识别编码
auto-coding-regexp-alist: 识别编码
auto-compression-mode: 压缩文件
auto-hscroll-mode: 水平滚动
auto-mode-alist: 选择模式
auto-mode-case-fold: 选择模式
auto-revert-avoid-polling: 自动恢复
auto-revert-check-vc-info: VC模式线
auto-revert-interval: 自动恢复
auto-revert-notify-exclude-dir-regexp: 自动恢复
auto-revert-remote-files: 自动恢复
auto-revert-use-notify: 自动恢复
auto-revert-verbose: 自动恢复
auto-save-default: 自动保存控制
auto-save-file-name-transforms: 自动保存文件
auto-save-interval: 自动保存控制
auto-save-list-file-prefix: 恢复
auto-save-no-message: 自动保存
auto-save-timeout: 自动保存控制
auto-save-visited-interval: 自动保存控制
auto-save-visited-mode: 自动保存文件

backtrace-on-error-noninteractive: 初始选项
backup-by-copying: 备份复印
backup-by-copying-when-linked: 备份复印
backup-by-copying-when-mismatch: 备份复印
backup-by-copying-when-privileged-mismatch: 备份复印
backup-directory-alist: 备份
backup-enable-predicate: 备份
battery-mode-line-format: 可选模式线
bdf-directory-list: PostScript 变量
bidi-display-reordering: 双向编辑
bidi-paragraph-direction: 双向编辑
bidi-paragraph-separate-re: 双向编辑
bidi-paragraph-start-re: 双向编辑
blink-cursor-alist: 光标显示
blink-cursor-blinks: 光标显示
blink-cursor-mode: 光标显示
blink-matching-delay: 匹配
blink-matching-paren: 匹配
blink-matching-paren-distance: 匹配
bookmark-default-file: 书签
bookmark-save-flag: 书签
bookmark-search-size: 书签
bookmark-use-annotations: 书签
browse-url-browser-function: 浏览URL
browse-url-handlers: 浏览URL
browse-url-mailto-function: 浏览URL
buffer-auto-revert-by-notification: 非文件缓冲区
buffer-file-coding-system: 输出编码
buffer-read-only: 杂项缓冲区
bug-reference-auto-setup-functions: 错误参考
bug-reference-auto-setup-functions: 错误参考
bug-reference-bug-regexp: 错误参考
bug-reference-forge-alist: 错误参考
bug-reference-setup-from-irc-alist: 错误参考
bug-reference-setup-from-mail-alist: 错误参考
bug-reference-setup-from-vc-alist: 错误参考
bug-reference-url-format: 错误参考

C
c-default-style: 自定义 C 缩进
c-hungry-delete-key: 饿删除
c-mode-hook: 程序模式
c-tab-always-indent: C 缩进
c-ts-mode-indent-style: 自定义 C 缩进
cal-html-css-default: 写入日历文件
calendar-bahai-all-holidays-flag: 节日定制
calendar-christian-all-holidays-flag: 节日定制
calendar-date-display-form: 日期显示格式
calendar-date-style: 日期格式
calendar-day-header-array: 日历定制
calendar-daylight-savings-ends: 夏令时
calendar-daylight-savings-ends-time: 夏令时
calendar-daylight-savings-starts: 夏令时
calendar-daylight-time-offset: 夏令时
calendar-daylight-time-zone-name: 日出日落
calendar-hebrew-all-holidays-flag: 节日定制
calendar-holiday-marker: 日历定制
calendar-holidays: 节日定制
calendar-initial-window-hook: 日历定制
calendar-intermonth-text: 日历定制
calendar-islamic-all-holidays-flag: 节日定制
calendar-latitude: 日出日落
calendar-location-name: 日出日落
calendar-longitude: 日出日落
calendar-mark-diary-entries-flag: 显示日记
calendar-mark-holidays-flag: 假期
calendar-month-header: 日历定制
calendar-move-hook: 日历定制
calendar-remove-frame-by-deleting: 通用日历
calendar-standard-time-zone-name: 日出日落
calendar-time-display-form: 时间显示格式
calendar-time-zone: 日出日落
calendar-time-zone-style: 日出日落
calendar-today-invisible-hook: 日历定制
calendar-today-marker: 日历定制
calendar-today-visible-hook: 日历定制
calendar-view-diary-initially-flag: 显示日记
calendar-view-holidays-initially-flag: 假期
calendar-week-start-day: 移至开头或结尾
calendar-weekend-days: 移至开头或结尾
case-fold-search: 宽松的搜索
case-replace: 替换和宽松的匹配
CDPATH, environment variable: 一般变量
change-log-version-info-enabled: 更改日志命令
change-log-version-number-regexp-list: 更改日志命令
change-major-mode-with-file-name: 选择模式
char-fold-exclude: 宽松的搜索
char-fold-include: 宽松的搜索
char-fold-override: 宽松的搜索
char-fold-symmetric: 宽松的搜索
clone-indirect-buffer-hook: 间接缓冲区
coding: 指定编码
colon-double-space: 填充命令
COLORTERM, environment variable: 一般变量
column-number-indicator-zero-based: 可选模式线
comint-completion-addsuffix: 外壳选项
comint-completion-autolist: 外壳选项
comint-completion-fignore: 外壳选项
comint-completion-recexact: 外壳选项
comint-input-autoexpand: 历史参考文献
comint-input-ignoredups: 外壳选项
comint-input-ring-file-name: 贝壳环
comint-insert-previous-argument-from-end: 贝壳环
comint-move-point-for-output: 外壳选项
comint-prompt-read-only: 外壳选项
comint-scroll-show-maximum-output: 外壳选项
comint-scroll-to-bottom-on-input: 外壳选项
comint-terminfo-terminal: 外壳选项
comint-use-prompt-regexp: 外壳提示符
command-history: 重复
command-line-args: Emacs 调用
comment-column: 评论选项
comment-end: 评论选项
comment-fill-column: 评论选项
comment-indent-function: 评论选项
comment-multi-line: 多行注释
comment-padding: 评论选项
comment-start: 评论选项
comment-start-skip: 评论选项
compare-ignore-case: 比较文件
compare-ignore-whitespace: 比较文件
compilation-always-kill: 汇编
compilation-auto-jump-to-first-error: 编译模式
compilation-context-lines: 编译模式
compilation-environment: 汇编
compilation-error: 编译模式
compilation-error-regexp-alist: 编译模式
compilation-hidden-output: 编译模式
compilation-max-output-line-length: 汇编
compilation-scroll-output: 汇编
compilation-skip-threshold: 编译模式
compilation-warning: 编译模式
compile-command: 汇编
completion-auto-help: 完成选项
completion-auto-select: 完成选项
completion-category-overrides: 完成样式
completion-cycle-threshold: 完成选项
completion-ignored-extensions: 完成选项
completion-styles: 完成样式
completions-detailed: 名称帮助
completions-format: 完成选项
completions-header-format: 完成选项
completions-highlight-face: 完成选项
completions-max-height: 完成选项
completions-sort: 完成选项
COMSPEC: 其他变量
confirm-kill-emacs: 退出
confirm-kill-processes: 退出
confirm-nonexistent-file-or-buffer: 完成退出
context-menu-functions: 菜单鼠标点击
copy-directory-create-symlink: 复制和命名
create-lockfiles: 联锁
ctl-arrow: 文字显示
ctl-x-4-map: 前缀键映射
ctl-x-map: 前缀键映射
cua-enable-cua-keys: CUA 绑定
cua-mode: CUA 绑定
current-input-method: 选择输入法
current-language-environment: 语言环境
cursor-in-non-selected-windows: 光标显示
cursor-type: 光标显示
custom-buffer-done-kill: 更改变量
custom-enabled-themes: 自定义主题
custom-file: 保存自定义设置
custom-safe-themes: 自定义主题
custom-search-field: 正在浏览自定义
custom-theme-directory: 自定义主题
custom-theme-directory, saving theme files: 创建自定义主题
custom-theme-load-path: 自定义主题
cycle-spacing-actions: 删除

D
dabbrev-abbrev-char-regexp: 达布列夫定制
dabbrev-abbrev-skip-leading-regexp: 达布列夫定制
dabbrev-case-fold-search: 达布列夫定制
dabbrev-case-replace: 达布列夫定制
dabbrev-check-all-buffers: 动态缩写
dabbrev-check-other-buffers: 动态缩写
dabbrev-ignored-buffer-modes: 动态缩写
dabbrev-ignored-buffer-names: 动态缩写
dabbrev-ignored-buffer-regexps: 动态缩写
dabbrev-limit: 动态缩写
DBUS_SESSION_BUS_ADDRESS, environment variable: 一般变量
dbx-mode-hook: GUD定制
debug-on-event: 清单
debug-on-quit: 清单
default-directory: 文件名
default-frame-alist: 机架参数
default-input-method: 选择输入法
default-justification: 丰富的理由
delete-active-region: 使用地区
delete-auto-save-files: 自动保存文件
delete-by-moving-to-trash: 其他文件操作
delete-by-moving-to-trash, and Dired: 直接删除
delete-old-versions: 备份删除
delete-selection-temporary-region: 使用地区
delete-trailing-lines: 无用的空白
desktop-auto-save-timeout: 保存 Emacs 会话
desktop-clear-preserve-buffers-regexp: 保存 Emacs 会话
desktop-files-not-to-save: 保存 Emacs 会话
desktop-globals-to-clear: 保存 Emacs 会话
desktop-globals-to-save: 保存 Emacs 会话
desktop-load-locked-desktop: 保存 Emacs 会话
desktop-path: 保存 Emacs 会话
desktop-restore-eager: 保存 Emacs 会话
desktop-restore-frames: 保存 Emacs 会话
desktop-save-mode: 保存 Emacs 会话
diary-bahai-entry-symbol: 非公历日记
diary-chinese-entry-symbol: 非公历日记
diary-comment-start: 精美日记展示
diary-date-forms: 日记定制
diary-display-function: 日记展示
diary-entry-marker: 日历定制
diary-file: 日记文件格式
diary-hebrew-entry-symbol: 非公历日记
diary-include-string: 精美日记展示
diary-islamic-entry-symbol: 非公历日记
diary-list-entries-hook: 精美日记展示
diary-list-include-blanks: 日记展示
diary-mail-days: 显示日记
diary-mark-entries-hook: 精美日记展示
diary-nongregorian-listing-hook: 非公历日记
diary-nongregorian-marking-hook: 非公历日记
diary-nonmarking-symbol: 显示日记
diary-number-of-entries: 日记定制
diary-outlook-formats: 导入日记
diary-print-entries-hook: 日记展示
diary-sexp-entry-symbol: 性爱日记条目
diary-show-holidays-flag: 日记定制
diff-add-log-use-relative-names: 日志缓冲区
diff-font-lock-syntax: 差异模式
diff-jump-to-old-file: 差异模式
diff-refine: 差异模式
diff-refine: 差异模式
diff-switches: 比较文件
diff-update-on-the-fly: 差异模式
directory-abbrev-alist: 文件别名
dired-auto-revert-buffer: 更新中
dired-chown-program: 对文件进行操作
dired-confirm-shell-command: Dired 中的 Shell 命令
dired-copy-dereference: 对文件进行操作
dired-copy-preserve-time: 对文件进行操作
dired-create-destination-dirs: 对文件进行操作
dired-create-destination-dirs-on-trailing-dirsep: 对文件进行操作
dired-dwim-target: 对文件进行操作
dired-enable-globstar-in-shell: 直接输入
dired-free-space: 其他 Dired 功能
dired-garbage-files-regexp: 标记许多文件
dired-guess-shell-alist-default: Shell 命令猜测
dired-guess-shell-alist-user: Shell 命令猜测
dired-hide-details-hide-information-lines: 其他 Dired 功能
dired-hide-details-hide-symlink-targets: 其他 Dired 功能
dired-isearch-filenames: 定向导航
dired-keep-marker-copy: 对文件进行操作
dired-kept-versions: 标记许多文件
dired-kill-when-opening-new-dired-buffer: 可怕的访问
dired-listing-switches: 直接输入
dired-listing-switches (MS-DOS): MS-DOS 进程
dired-maybe-use-globstar: 直接输入
dired-mouse-drag-files: 其他 Dired 功能
dired-recursive-copies: 对文件进行操作
dired-recursive-deletes: 直接删除
dired-switches-in-mode-line: 直接输入
dired-use-ls-dired: 直接输入
dired-vc-rename-file: 对文件进行操作
dirtrack-list: 目录追踪
display-battery-mode: 可选模式线
display-fill-column-indicator-character: 显示边界
display-fill-column-indicator-column: 显示边界
display-hourglass: 显示定制
display-line-numbers: 显示定制
display-line-numbers-current-absolute: 显示定制
display-line-numbers-grow-only: 显示定制
display-line-numbers-offset: 显示定制
display-line-numbers-type: 显示定制
display-line-numbers-widen: 显示定制
display-line-numbers-width: 显示定制
display-line-numbers-width-start: 显示定制
display-raw-bytes-as-hex: 显示定制
display-time-24hr-format: 可选模式线
display-time-mail-directory: 可选模式线
display-time-mail-face: 可选模式线
display-time-mail-file: 可选模式线
display-time-use-mail-icon: 可选模式线
dnd-indicate-insertion-point: 拖放
dnd-open-file-other-window: 拖放
dnd-scroll-margin: 拖放
doc-view-cache-directory: 文档视图转换
doc-view-continuous: 文档视图导航
doc-view-imenu-enabled: 文档视图导航
doc-view-imenu-flatten: 文档视图导航
doc-view-imenu-format: 文档视图导航
doc-view-resolution: 文档视图导航
doc-view-scale-internally: 文档视图导航
doctex-mode-hook: 杂项
dos-codepage: MS-DOS 和 MULE
dos-display-scancodes: MS-DOS鼠标
dos-hyper-key: MS-DOS 键盘
dos-keypad-mode: MS-DOS 键盘
dos-printer: MS-DOS 打印
dos-ps-printer: MS-DOS 打印
dos-super-key: MS-DOS 键盘
double-click-fuzz: 鼠标按钮
double-click-time: 鼠标按钮

echo-keystrokes: 显示定制
eldoc-documentation-functions: 编程语言文档
eldoc-documentation-strategy: 编程语言文档
eldoc-echo-area-display-truncation-message: 编程语言文档
eldoc-echo-area-prefer-doc-buffer: 编程语言文档
eldoc-echo-area-use-multiline-p: 编程语言文档
eldoc-idle-delay: 编程语言文档
eldoc-print-after-edit: 编程语言文档
electric-pair-delete-adjacent-pairs: 匹配
electric-pair-open-newline-between-pairs: 匹配
electric-pair-preserve-balance: 匹配
electric-pair-skip-whitespace: 匹配
electric-quote-chars: 引号
electric-quote-comment: 引号
electric-quote-paragraph: 引号
electric-quote-replace-double: 引号
electric-quote-string: 引号
emacs-lisp-mode-hook: 程序模式
EMACSCLIENT_TRAMP, environment variable: emacsclient 选项
EMACSCOLORS: 其他变量
EMACSDATA, environment variable: 一般变量
EMACSDOC, environment variable: 一般变量
EMACSLOADPATH, environment variable: 一般变量
EMACSPATH, environment variable: 一般变量
EMACSTEST: 其他变量
emacs_dir: 其他变量
EMACS_SERVER_FILE, environment variable: TCP Emacs 服务器
EMAIL, environment variable: 一般变量
emerge-combine-versions-template: 合并出现
emerge-startup-hook: 出现的要点
enable-local-eval: 安全文件变量
enable-local-variables: 安全文件变量
enable-recursive-minibuffers: 迷你缓冲区编辑
enriched-allow-eval-in-display-props: 丰富的属性
enriched-translations: 丰富模式
eol-mnemonic-dos: 可选模式线
eol-mnemonic-mac: 可选模式线
eol-mnemonic-undecided: 可选模式线
eol-mnemonic-unix: 可选模式线
esc-map: 前缀键映射
ESHELL, environment variable: 一般变量
eval-expression-debug-on-error: Lisp 评估
eval-expression-print-length: Lisp 评估
eval-expression-print-level: Lisp 评估
eval-expression-print-maximum-character: Lisp 评估
eww-search-prefix: 单词搜索
exec-path: 
exit-language-environment-hook: 语言环境
explicit-shell-file-name: 交互式外壳
extended-command-suggest-shorter: MX

F
face-ignored-fonts: 修改字体集
fast-but-imprecise-scrolling: 滚动
ff-related-file-alist: 其他 C 命令
file-coding-system-alist: 识别编码
file-name-at-point-functions: 迷你缓冲区历史
file-name-coding-system: 文件名编码
file-preserve-symlinks-on-save: 自定义保存
fill-column: 填充命令
fill-column-indicator: 显示边界
fill-nobreak-predicate: 填充命令
fill-prefix: 填充前缀
find-file-existing-other-name: 文件别名
find-file-hook: 参观
find-file-not-found-functions: 参观
find-file-run-dired: 参观
find-file-suppress-same-file-warnings: 文件别名
find-file-visit-truename: 文件别名
find-file-wildcards: 参观
find-ls-option: 定向并查找
find-sibling-rules: 参观
focus-follows-mouse: 帧命令
foldout-mouse-modifiers: 展开
font-lock-ignore: 传统字体锁定
font-lock-maximum-decoration: 传统字体锁定
font-slant-table (MS-Windows): Windows 字体
font-weight-table (MS-Windows): Windows 字体
fortran-analyze-depth: 缩进续
fortran-break-before-delimiters: Fortran 自动填充
fortran-check-all-num…: 对于缩进变量
fortran-column-ruler-fixed: Fortran 列
fortran-column-ruler-tabs: Fortran 列
fortran-comment-indent-char: Fortran 注释
fortran-comment-indent-style: Fortran 注释
fortran-comment-line-extra-indent: Fortran 注释
fortran-comment-line-start: Fortran 注释
fortran-comment-region: Fortran 注释
fortran-continuation-indent: 对于缩进变量
fortran-continuation-string: 缩进续
fortran-directive-re: Fortran 注释
fortran-do-indent: 对于缩进变量
fortran-electric-line-number: 对于缩进数
fortran-if-indent: 对于缩进变量
fortran-line-length: Fortran 列
fortran-line-number-indent: 对于缩进数
fortran-minimum-statement-indent…: 对于缩进变量
fortran-structure-indent: 对于缩进变量
fortran-tab-mode-default: 缩进续
frame-background-mode: 面孔
frame-resize-pixelwise: 帧命令
frameset-filter-alist: 保存 Emacs 会话
fringe-mode (variable): 流苏

G
gdb-default-window-configuration-file: GDB 用户界面布局
gdb-delete-out-of-scope: 观看表情
gdb-display-source-buffer-action: GDB 用户界面布局
gdb-gud-control-all-threads: 多线程调试
gdb-many-windows: GDB 用户界面布局
gdb-max-source-window-count: GDB 用户界面布局
gdb-mi-decode-strings: 源缓冲区
gdb-mode-hook: GUD定制
gdb-non-stop-setting: 多线程调试
gdb-restore-window-configuration-after-quit: GDB 用户界面布局
gdb-show-changed-values: 观看表情
gdb-show-main: GDB 用户界面布局
gdb-show-threads-by-default: 断点缓冲区
gdb-speedbar-auto-raise: 观看表情
gdb-stack-buffer-addresses: 堆栈缓冲区
gdb-stopped-functions: 多线程调试
gdb-switch-reasons: 多线程调试
gdb-switch-when-another-stopped: 多线程调试
gdb-thread-buffer-addresses: 线程缓冲区
gdb-thread-buffer-arguments: 线程缓冲区
gdb-thread-buffer-locations: 线程缓冲区
gdb-thread-buffer-verbose-names: 线程缓冲区
gdb-use-colon-colon-notation: 观看表情
gdb-window-configuration-directory: GDB 用户界面布局
global-cwarn-mode: 其他 C 命令
global-font-lock-mode: 字体锁定
global-mark-ring-max: 全球标志戒指
global-text-scale-adjust-resizes-frames: 文字比例
grep-find-abbreviate: Grep 搜索
grep-find-ignored-directories: Grep 搜索
grep-find-ignored-directories (Dired): 对文件进行操作
grep-find-ignored-files (Dired): 对文件进行操作
grep-match-regexp: Grep 搜索
grep-regexp-alist: 编译模式
gud-gdb-command-name: GDB图形界面
gud-xdb-directories: 启动GUD
guiler-mode-hook: GUD定制

H
haiku-control-keysym: 俳句基础知识
haiku-debug-on-fatal-error: 俳句基础知识
haiku-meta-keysym: 俳句基础知识
haiku-shift-keysym: 俳句基础知识
haiku-super-keysym: 俳句基础知识
help-at-pt-display-when-idle: 帮助回声
help-clean-buttons: 帮助模式
help-enable-autoload: Lisp 库
help-enable-completion-autoload: Lisp 库
help-enable-symbol-autoload: 名称帮助
help-map: 前缀键映射
help-window-keep-selected: 帮助
help-window-select: 帮助
help-window-select, and apropos commands: 恰如其分
hi-lock-auto-select-face: 交互式突出显示
hi-lock-exclude-modes: 交互式突出显示
hi-lock-file-patterns-policy: 交互式突出显示
hide-ifdef-shadow: 其他 C 命令
highlight-nonselected-windows: 标记
HISTFILE, environment variable: 一般变量
history-delete-duplicates: 迷你缓冲区历史
history-length: 迷你缓冲区历史
holiday-bahai-holidays: 节日定制
holiday-christian-holidays: 节日定制
holiday-general-holidays: 节日定制
holiday-hebrew-holidays: 节日定制
holiday-islamic-holidays: 节日定制
holiday-local-holidays: 节日定制
holiday-oriental-holidays: 节日定制
holiday-other-holidays: 节日定制
holiday-solar-holidays: 节日定制
HOME, environment variable: 一般变量
horizontal-scroll-bar-mode: 滚动条
HOSTNAME, environment variable: 一般变量
hourglass-delay: 显示定制
hs-hide-comments-when-hiding-all: 秀秀
hs-isearch-open: 秀秀
hs-special-modes-alist: 秀秀
hscroll-margin: 水平滚动
hscroll-step: 水平滚动

icon-preference: 图标
ignored-local-variable-values: 安全文件变量
image-animate-loop: 图像模式
image-auto-resize: 图像模式
image-auto-resize-on-window-resize: 图像模式
image-crop-crop-command: 图像模式
image-crop-cut-command: 图像模式
image-cut-color: 图像模式
image-dired-external-viewer: 图像定向
image-dired-thumb-visible-marks: 图像定向
image-use-external-converter: 图像模式
imagemagick-enabled-types: 图像模式
imagemagick-types-inhibit: 图像模式
imenu-auto-rescan: 伊梅努
imenu-auto-rescan-maxout: 伊梅努
imenu-max-index-time: 伊梅努
imenu-sort-function: 伊梅努
indent-tabs-mode: 只是空间
indent-tabs-mode (Fortran mode): 缩进续
indicate-buffer-boundaries: 显示边界
indicate-empty-lines: 无用的空白
inferior-lisp-program: 外部 Lisp
INFOPATH, environment variable: 一般变量
inhibit-eol-conversion: 识别编码
inhibit-iso-escape-detection: 识别编码
inhibit-startup-buffer-menu: 行动论据
inhibit-startup-screen: 进入Emacs
initial-environment: 环境
initial-frame-alist: 机架参数
initial-scratch-message: Lisp交互
input-method-highlight-flag: 输入法
input-method-verbose-flag: 输入法
insert-default-directory: 迷你缓冲区文件
interpreter-mode-alist: 选择模式
isearch-allow-motion: 不退出 Isearch
isearch-allow-prefix: 不退出 Isearch
isearch-allow-scroll: 不退出 Isearch
isearch-hide-immediately: 搜索定制
isearch-lazy-count: 搜索定制
isearch-lazy-highlight: 搜索定制
isearch-mode-map: 特殊研究
isearch-motion-changes-direction: 不退出 Isearch
isearch-repeat-on-direction-change: 重复搜索
isearch-resume-in-command-history: 重复
isearch-wrap-pause: 重复搜索
ispell-complete-word-dict: 拼写
ispell-dictionary: 拼写
ispell-local-dictionary: 拼写
ispell-personal-dictionary: 拼写
ispell-program-name: 拼写

J
jdb-mode-hook: GUD定制
jit-lock-defer-time: 滚动

K
kept-new-versions: 备份删除
kept-old-versions: 备份删除
keyboard-coding-system: 端子编码
kill-buffer-delete-auto-save-files: 自动保存文件
kill-buffer-hook: 终止缓冲区
kill-do-not-save-duplicates: 杀死选项
kill-read-only-ok: 杀死选项
kill-ring: 杀环
kill-ring-max: 杀环
kill-transform-function: 杀死选项
kill-whole-line: 线杀
kmacro-ring-max: 键盘宏环

L
LANG, environment variable: 一般变量
large-file-warning-threshold: 参观
latex-block-names: 乳胶编辑
latex-mode-hook: 杂项
latex-run-command: TeX 打印
latin1-display: 无法显示的字符
lazy-count-prefix-format: 搜索定制
lazy-count-suffix-format: 搜索定制
lazy-highlight-initial-delay: 搜索定制
lazy-highlight-interval: 搜索定制
lazy-highlight-max-at-a-time: 搜索定制
lazy-highlight-no-delay-length: 搜索定制
LC_ALL, environment variable: 一般变量
LC_COLLATE, environment variable: 一般变量
LC_CTYPE, environment variable: 一般变量
LC_MESSAGES, environment variable: 一般变量
LC_MONETARY, environment variable: 一般变量
LC_NUMERIC, environment variable: 一般变量
LC_TIME, environment variable: 一般变量
line-move-visual: 移动点
line-number-display-limit: 可选模式线
line-number-display-limit-width: 可选模式线
lisp-body-indent: Lisp 缩进
lisp-indent-offset: Lisp 缩进
lisp-interaction-mode-hook: 程序模式
lisp-mode-hook: 程序模式
list-colors-sort: 颜色
list-directory-brief-switches: 目录
list-directory-verbose-switches: 目录
list-matching-lines-default-context-lines: 其他重复搜索
list-matching-lines-jump-to-current-line: 其他重复搜索
load-path: Lisp 库
load-prefer-newer: Lisp 库
locale-charset-language-names: 语言环境
locale-coding-system: 通讯编码
locale-language-names: 语言环境
locale-preferred-coding-systems: 语言环境
locate-command: 定向并查找
LOGNAME, environment variable: 一般变量
lpr-add-switches: 印刷
lpr-command (MS-DOS): 视窗打印
lpr-commands: 印刷
lpr-headers-switches: 印刷
lpr-headers-switches (MS-DOS): 视窗打印
lpr-printer-switch: 印刷
lpr-switches: 印刷
lpr-switches (MS-DOS): 视窗打印
ls-lisp-dirs-first: Lisp 中的 ls
ls-lisp-emulation: Lisp 中的 ls
ls-lisp-format-time-list: Lisp 中的 ls
ls-lisp-ignore-case: Lisp 中的 ls
ls-lisp-support-shell-wildcards: Lisp 中的 ls
ls-lisp-UCA-like-collation: Lisp 中的 ls
ls-lisp-use-insert-directory-program: Lisp 中的 ls
ls-lisp-use-localized-time-format: Lisp 中的 ls
ls-lisp-use-string-collate: Lisp 中的 ls
ls-lisp-verbosity: Lisp 中的 ls

中号
magic-fallback-mode-alist: 选择模式
magic-mode-alist: 选择模式
MAIL, environment variable: 一般变量
mail-citation-hook: 引用邮件
mail-default-headers: 邮件标头
mail-dont-reply-to-names: 邮件回复
mail-personal-alias-file: 邮件别名
mail-signature: 邮件签名
mail-signature-file: 邮件签名
mail-user-agent: 邮寄方式
major-mode: 主要模式
major-mode-remap-alist: 选择模式
make-backup-file-name-function: 备份名称
make-backup-files: 备份
make-pointer-invisible: 显示定制
Man-switches: 手册页
mark-even-if-inactive: 使用地区
mark-ring-max: 马克环
max-mini-window-height: 迷你缓冲区编辑
maximum-scroll-margin: 自动滚动
menu-bar-mode: 菜单栏
message-kill-buffer-on-exit: 邮件发送
message-log-max: 回声区
message-mode-hook: 邮件杂项
message-send-hook: 邮件发送
message-send-mail-function: 邮件发送
message-setup-hook: 邮件杂项
message-signature: 邮件签名
message-signature-file: 邮件签名
MH, environment variable: 一般变量
midnight-hook: 终止缓冲区
midnight-mode: 终止缓冲区
minibuffer-completion-auto-choose: 完成命令
minibuffer-default-prompt-format: 基本迷你缓冲区
minibuffer-eldef-shorten-default: 基本迷你缓冲区
minibuffer-follows-selected-frame: 基本迷你缓冲区
minibuffer-local-completion-map: 迷你缓冲区映射
minibuffer-local-filename-completion-map: 迷你缓冲区映射
minibuffer-local-map: 迷你缓冲区映射
minibuffer-local-must-match-map: 迷你缓冲区映射
minibuffer-local-ns-map: 迷你缓冲区映射
minibuffer-prompt-properties: 标准面
mode-line-in-non-selected-windows: 可选模式线
mode-require-final-newline: 自定义保存
mode-specific-map: 前缀键映射
mouse-1-click-follows-link: 鼠标参考
mouse-1-click-in-non-selected-windows: 鼠标参考
mouse-autoselect-window: 其他窗口
mouse-avoidance-mode: 鼠标回避
mouse-drag-and-drop-region: 拖放
mouse-drag-and-drop-region-cross-program: 拖放
mouse-drag-and-drop-region-cut-when-buffers-differ: 拖放
mouse-drag-and-drop-region-show-cursor: 拖放
mouse-drag-and-drop-region-show-tooltip: 拖放
mouse-drag-copy-region: 鼠标命令
mouse-drag-mode-line-buffer: 鼠标命令
mouse-highlight: 鼠标参考
mouse-scroll-min-lines: 鼠标命令
mouse-wheel-flip-direction: 鼠标命令
mouse-wheel-follow-mouse: 鼠标命令
mouse-wheel-progressive-speed: 鼠标命令
mouse-wheel-scroll-amount: 鼠标命令
mouse-wheel-scroll-amount-horizontal: 鼠标命令
mouse-wheel-tilt-scroll: 鼠标命令
mouse-yank-at-point: 鼠标命令

NAME: 其他变量
NAME, environment variable: 一般变量
native-comp-eln-load-path: Lisp 库
network-security-level: 网络安全
network-security-protocol-checks: 网络安全
next-error-find-buffer-function: 编译模式
next-error-highlight: 编译模式
next-error-highlight-no-select: 编译模式
next-error-message-highlight: 编译模式
next-line-add-newlines: 移动点
next-screen-context-lines: 滚动
NNTPSERVER, environment variable: 一般变量
nobreak-char-display: 文字显示
normal-erase-is-backspace: DEL 不删除
nroff-mode-hook: 诺夫模式
ns-alternate-modifier: Mac / GNUstep 定制
ns-auto-hide-menu-bar: Mac / GNUstep 定制
ns-command-modifier: Mac / GNUstep 定制
ns-confirm-quit: Mac / GNUstep 定制
ns-control-modifier: Mac / GNUstep 定制
ns-function-modifier: Mac / GNUstep 定制
ns-mwheel-line-height: Mac / GNUstep 定制
ns-pop-up-frames: Mac / GNUstep 事件
ns-right-alternate-modifier: Mac / GNUstep 定制
ns-right-command-modifier: Mac / GNUstep 定制
ns-right-control-modifier: Mac / GNUstep 定制
ns-standard-fontset-spec: 定义字体集
ns-use-mwheel-acceleration: Mac / GNUstep 定制
ns-use-mwheel-momentum: Mac / GNUstep 定制
ns-use-native-fullscreen: Mac / GNUstep 定制
ns-use-proxy-icon: Mac / GNUstep 定制
nsm-save-host-names: 网络安全
nsm-settings-file: 网络安全

open-paren-in-column-0-is-defun-start: 左边距括号
org-agenda-files: 组织组织者
org-publish-project-alist: 组织创作
org-todo-keywords: 组织组织者
ORGANIZATION, environment variable: 一般变量
outline-default-state: 轮廓可见性
outline-level: 大纲格式
outline-minor-mode-cycle: 轮廓小调模式
outline-minor-mode-prefix: 轮廓小调模式
outline-minor-mode-use-buttons: 轮廓小调模式
outline-mode-hook: 轮廓模式
outline-regexp: 大纲格式
overflow-newline-into-fringe: 流苏
overline-margin: 显示定制

package-archive-priorities: 包安装
package-archives: 包安装
package-check-signature: 包安装
package-directory-list: 打包文件
package-enable-at-startup: 包安装
package-install-upgrade-built-in: 包安装
package-load-list: 包安装
package-menu-async: 套餐菜单
package-menu-hide-low-priority: 包安装
package-pinned-packages: 包安装
package-quickstart: 包安装
package-unsigned-archives: 包安装
package-user-dir: 打包文件
page-delimiter: 页数
paragraph-separate: 段落
paragraph-start: 段落
PATH, environment variable: 一般变量
pdb-mode-hook: GUD定制
perldb-mode-hook: GUD定制
picture-mode-hook: 图片模式
picture-tab-chars: 图片中的选项卡
plain-tex-mode-hook: 杂项
PRELOAD_WINSOCK: 其他变量
print-region-function (MS-DOS): 视窗打印
printer-name: 印刷
printer-name, (MS-DOS/MS-Windows): 视窗打印
prog-mode-hook: 主要模式
project-kill-buffer-conditions: 项目缓冲区命令
project-kill-buffers-display-buffer-list: 项目缓冲区命令
project-list-file: 切换项目
project-prefix-map: 前缀键映射
project-switch-commands: 切换项目
ps-black-white-faces: PostScript 变量
ps-font-family: PostScript 变量
ps-font-info-database: PostScript 变量
ps-font-size: PostScript 变量
ps-landscape-mode: PostScript 变量
ps-lpr-command: PostScript 变量
ps-lpr-command (MS-DOS): 视窗打印
ps-lpr-switches: PostScript 变量
ps-lpr-switches (MS-DOS): 视窗打印
ps-multibyte-buffer: PostScript 变量
ps-number-of-columns: PostScript 变量
ps-page-dimensions-database: PostScript 变量
ps-paper-type: PostScript 变量
ps-print-color-p: PostScript 变量
ps-print-header: PostScript 变量
ps-printer-name: PostScript 变量
ps-printer-name (MS-DOS): 视窗打印
ps-use-face-background: PostScript 变量
PWD, environment variable: 一般变量

quail-activate-hook: 输入法
query-about-changed-file: 参观
query-replace-from-to-separator: 查询替换
query-replace-highlight: 查询替换
query-replace-highlight-submatches: 查询替换
query-replace-lazy-highlight: 查询替换
query-replace-show-replacement: 查询替换
query-replace-skip-read-only: 查询替换

read-buffer-completion-ignore-case: 完成选项
read-extended-command-predicate: MX
read-file-name-completion-ignore-case: 完成选项
read-mail-command: 邮寄方式
read-quoted-char-radix: 插入文本
recenter-positions: 重心调整
recenter-redisplay: 重心调整
recentf-mode: 文件便利
redisplay-skip-fontification-on-input: 滚动
regexp-search-ring-max: 正则表达式搜索
register-preview-delay: 寄存器
register-separator: 文本寄存器
remote-file-name-inhibit-locks: 联锁
repeat-exit-key: 重复
repeat-exit-timeout: 重复
replace-lax-whitespace: 替换和宽松的匹配
replace-regexp-lax-whitespace: 替换和宽松的匹配
REPLYTO, environment variable: 一般变量
require-final-newline: 自定义保存
resize-mini-windows: 迷你缓冲区编辑
revert-buffer-quick-short-answers: 恢复
revert-buffer-with-fine-grain-max-seconds: 恢复
revert-without-query: 恢复
rmail-automatic-folder-directives: 邮件输出
rmail-delete-after-output: 邮件输出
rmail-delete-message-hook: 邮件删除
rmail-displayed-headers: 邮件显示
rmail-edit-mode-hook: 邮件编辑
rmail-enable-mime: 邮件显示
rmail-enable-mime-composing: 邮件回复
rmail-file-coding-system: 邮件编码
rmail-file-name: Rmail 基础知识
rmail-highlighted-headers: 邮件显示
rmail-ignored-headers: 邮件显示
rmail-inbox-list: Rmail 文件
rmail-mail-new-frame: 邮件回复
rmail-mbox-format: 邮件收件箱
rmail-mime-prefer-html: 邮件显示
rmail-mode-hook: 远程邮件
rmail-movemail-flags: 远程邮箱
rmail-movemail-program: 移动邮件
rmail-movemail-search-path: 移动邮件
rmail-nonignored-headers: 邮件显示
rmail-output-file-alist: 邮件输出
rmail-output-reset-deleted-flag: 邮件输出
rmail-preserve-inbox: 邮件收件箱
rmail-primary-inbox-list: 邮件收件箱
rmail-redisplay-summary: Rmail摘要编辑
rmail-remote-password: 远程邮箱
rmail-remote-password-required: 远程邮箱
rmail-retry-ignored-headers: 邮件回复
rmail-secondary-file-directory: Rmail 文件
rmail-secondary-file-regexp: Rmail 文件
rmail-summary-line-count-flag: Rmail 总结
rmail-summary-scroll-between-messages: Rmail摘要编辑
rmail-summary-window-size: Rmail 总结

S
safe-local-eval-forms: 安全文件变量
safe-local-variable-values: 安全文件变量
save-abbrevs: 保存缩写
save-interprogram-paste-before-kill: 剪贴板
save-some-buffers-default-predicate: 保存命令
SAVEDIR, environment variable: 一般变量
scheme-mode-hook: 程序模式
script-representative-chars: 修改字体集
scroll-all-mode: 窗口便利
scroll-bar-adjust-thumb-portion: 滚动条
scroll-bar-height: 滚动条
scroll-bar-mode: 滚动条
scroll-bar-width: 滚动条
scroll-conservatively: 自动滚动
scroll-down: 滚动
scroll-down-aggressively: 自动滚动
scroll-error-top-bottom: 滚动
scroll-margin: 自动滚动
scroll-minibuffer-conservatively: 自动滚动
scroll-preserve-screen-position: 滚动
scroll-step: 自动滚动
scroll-up: 滚动
scroll-up-aggressively: 自动滚动
sdb-mode-hook: GUD定制
search-exit-option: 不退出 Isearch
search-highlight: 搜索定制
search-highlight-submatches: 搜索定制
search-invisible: 轮廓可见性
search-nonincremental-instead: 搜索定制
search-ring-max: 重复搜索
search-slow-speed: 搜索定制
search-slow-window-lines: 搜索定制
search-upper-case: 宽松的搜索
search-whitespace-regexp: 宽松的搜索
select-active-regions: 初选
select-enable-clipboard: 剪贴板
select-enable-primary: 剪贴板
selective-display-ellipses: 选择性显示
send-mail-function: 邮件发送
sendmail-coding-system: 输出编码
sentence-end: 句子
sentence-end-double-space: 句子
sentence-end-without-period: 句子
server-auth-dir: TCP Emacs 服务器
server-auth-key: TCP Emacs 服务器
server-client-instructions: 调用 emacsclient
server-host: TCP Emacs 服务器
server-kill-new-buffers: 调用 emacsclient
server-name: Emacs服务器
server-port: TCP Emacs 服务器
server-temp-file-regexp: 调用 emacsclient
server-use-tcp: TCP Emacs 服务器
server-window: 调用 emacsclient
set-language-environment-hook: 语言环境
set-mark-command-repeat-pop: 马克环
sgml-xml-mode: HTML模式
SHELL, environment variable: 一般变量
shell-cd-regexp: 目录追踪
shell-command-buffer-name: 单壳
shell-command-buffer-name-async: 单壳
shell-command-default-error-buffer: 单壳
shell-command-dont-erase-buffer: 单壳
shell-command-prompt-show-cwd: 单壳
shell-command-regexp: 外壳模式
shell-completion-execonly: 外壳选项
shell-completion-fignore: 外壳选项
shell-file-name: 单壳
shell-popd-regexp: 目录追踪
shell-prompt-pattern: 外壳提示符
shell-pushd-regexp: 目录追踪
shift-select-mode: 班次选择
show-paren-context-when-offscreen: 匹配
show-paren-highlight-openparen: 匹配
show-paren-predicate: 匹配
show-paren-style: 匹配
show-paren-when-point-in-periphery: 匹配
show-paren-when-point-inside-paren: 匹配
show-trailing-whitespace: 无用的空白
slitex-mode-hook: 杂项
small-temporary-file-directory: 备份
SMTPSERVER, environment variable: 一般变量
sort-fold-case: 排序
sort-numeric-base: 排序
split-height-threshold: 窗口选择
split-width-threshold: 窗口选择
split-window-keep-point: 分割窗口
standard-fontset-spec: 定义字体集
standard-indent: 丰富的缩进
suggest-key-bindings: MX
system-uses-terminfo: 外壳选项

时间
tab-always-indent: 缩进便利
tab-bar-close-last-tab-choice: 标签栏
tab-bar-close-tab-select: 标签栏
tab-bar-new-tab-choice: 标签栏
tab-bar-new-tab-to: 标签栏
tab-bar-select-tab-modifiers: 标签栏
tab-bar-show: 标签栏
tab-bar-tab-hints: 标签栏
tab-bar-tab-name-function: 标签栏
tab-first-completion: 缩进便利
tab-stop-list: 制表位
tab-width: 文字显示
table-cell-horizontal-chars: 表定义
table-cell-intersection-char: 表定义
table-cell-vertical-char: 表定义
table-detect-cell-alignment: 单元格对齐
tags-apropos-additional-actions: 查找标识符
tags-case-fold-search: 标识符搜索
tags-file-name: 选择标签表
tags-table-list: 选择标签表
TEMP, environment variable: 一般变量
temp-buffer-max-height: 临时展示
temp-buffer-max-width: 临时展示
temporary-file-directory: 备份
TERM, environment variable: 一般变量
TERM, environment variable, and display bugs: 清单
TERM, environment variable, in compilation mode: 编译外壳
TERM, environment variable, in sub-shell: 外壳选项
term-file-aliases: 终端初始化
term-file-prefix: 终端初始化
TERMCAP, environment variable: 一般变量
tex-bibtex-command: TeX 打印
tex-default-mode: TeX 模式
tex-directory: TeX 打印
tex-dvi-print-command: TeX 打印
tex-dvi-view-command: TeX 打印
tex-main-file: TeX 打印
tex-mode-hook: 杂项
tex-print-file-extension: TeX 打印
tex-run-command: TeX 打印
tex-shell-hook: 杂项
tex-start-commands: TeX 打印
tex-start-options: TeX 打印
text-mode-hook: 文本模式
timeclock-ask-before-exiting: 时间间隔
timeclock-file: 时间间隔
timeclock-mode-line-display: 时间间隔
TMP, environment variable: 一般变量
TMPDIR, environment variable: 一般变量
tool-bar-mode: 工具栏
tool-bar-style: 工具栏
tooltip-delay: 工具提示
tooltip-frame-parameters: 工具提示
tooltip-hide-delay: 工具提示
tooltip-short-delay: 工具提示
tooltip-x-offset: 工具提示
tooltip-y-offset: 工具提示
track-eol: 移动点
tramp-histfile-override: 贝壳环
treesit-defun-tactic: 移动由 Defuns 提供
treesit-font-lock-feature-list: 基于解析器的字体锁定
treesit-font-lock-level: 基于解析器的字体锁定
treesit-max-buffer-size: 参观
truncate-lines: 行截断
truncate-partial-width-windows: 分割窗口
tty-menu-open-use-tmm: 菜单栏
tty-setup-hook: 终端初始化
TZ, environment variable: 一般变量

U
underline-minimum-offset: 显示定制
undo-limit: 撤消
undo-outer-limit: 撤消
undo-strong-limit: 撤消
unibyte-display-via-language-environment: 单字节模式
uniquify-buffer-name-style: 统一
use-dialog-box: 对话框
use-file-dialog: 对话框
use-system-tooltips: 工具提示
USER, environment variable: 一般变量
user-full-name: 邮件标头
user-mail-address: 邮件标头
user-mail-address, in init file: 初始化示例
user-mail-address, initialization: 一般变量

V
vc-annotate-background-mode: 旧版本
vc-annotate-switches: 旧版本
vc-backend-header: 版本标头
vc-command-messages: 一般风险投资选项
vc-consult-headers: 版本标头
vc-cvs-global-switches: CVS 选项
vc-cvs-stay-local: CVS 选项
vc-default-patch-addressee: 准备补丁
vc-diff-switches: 旧版本
vc-directory-exclusion-list: VC 目录缓冲区
vc-directory-exclusion-list: 项目文件命令
vc-follow-symlinks: 一般风险投资选项
vc-handled-backends: 定制VC
vc-log-mode-hook: 日志缓冲区
vc-log-show-limit: VC变更日志
vc-make-backup-files: 一般风险投资选项
vc-prepare-patches-separately: 准备补丁
vc-revert-show-diff: VC 撤消
vc-static-header-alist: 版本标头
vc-suppress-confirm: 一般风险投资选项
version-control: 备份名称
VERSION_CONTROL, environment variable: 一般变量
view-read-only: 杂项缓冲区
visible-bell: 显示定制
visible-cursor: 光标显示
visual-order-cursor-movement: 双向编辑

w32-alt-is-meta: Windows 键盘
w32-apps-modifier: Windows 键盘
w32-capslock-is-shiftlock: Windows 键盘
w32-charset-info-alist: Windows 字体
w32-enable-caps-lock: Windows 键盘
w32-enable-num-lock: Windows 键盘
w32-fixed-font-alist: Windows 字体
w32-get-true-file-attributes: Windows 文件
w32-grab-focus-on-raise: Windows 杂项
w32-lwindow-modifier: Windows 键盘
w32-mouse-button-tolerance: Windows鼠标
w32-non-USB-fonts: Windows 字体
w32-pass-alt-to-system: Windows 键盘
w32-pass-extra-mouse-buttons-to-system: Windows鼠标
w32-pass-lwindow-to-system: Windows 键盘
w32-pass-rwindow-to-system: Windows 键盘
w32-pipe-buffer-size: Windows进程
w32-pipe-read-delay: Windows进程
w32-quote-process-args: Windows进程
w32-recognize-altgr: Windows 键盘
w32-rwindow-modifier: Windows 键盘
w32-scroll-lock-modifier: Windows 键盘
w32-standard-fontset-spec: 定义字体集
w32-swap-mouse-buttons: Windows鼠标
w32-unicode-filenames: 文件名编码
w32-use-visible-system-caret: Windows 杂项
w32-use-w32-font-dialog: Windows 字体
WAYLAND_DISPLAY: 其他变量
what-cursor-show-names: 职位信息
which-func-modes: 哪个功能
whitespace-big-indent-regexp: 无用的空白
whitespace-line-column: 无用的空白
whitespace-style: 无用的空白
window-divider-default-bottom-width: 窗隔板
window-divider-default-places: 窗隔板
window-divider-default-right-width: 窗隔板
window-min-height: 更改窗口
window-min-width: 更改窗口
window-resize-pixelwise: 分割窗口
winner-boring-buffers: 窗口便利
winner-boring-buffers-regexp: 窗口便利
winner-dont-bind-my-keys: 窗口便利
winner-ring-size: 窗口便利
word-wrap-by-category: 视线模式
word-wrap-whitespace-mode: 视线模式
write-region-inhibit-fsync: 自定义保存

X
x-gtk-file-dialog-help-text: 对话框
x-gtk-show-hidden-files: 对话框
x-gtk-use-native-input: 单字节模式
x-input-coding-system: X 编码
x-mouse-click-focus-ignore-position: 鼠标命令
x-select-enable-clipboard-manager: 剪贴板
x-select-request-type: 通讯编码
x-stretch-cursor: 光标显示
x-underline-at-descent-line: 显示定制
xdb-mode-hook: GUD定制
xref-auto-jump-to-first-definition: 查找标识符
xref-auto-jump-to-first-xref: 标识符搜索
xref-prompt-for-identifier: 查找标识符

yank-pop-change-selection: 剪贴板


概念索引

Concept Index

跳到:   #   $   (   *   -   ./   7   8   ?   _ ~ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z      
                                                   
索引条目 部分

#
#,在自动保存文件名中 自动保存文件

$
$在文件名中 文件名

(在最左边的列中 左边距括号

*
*留言*缓冲 回声区

-
–/—/.-./.../。 娱乐项目

.#, 锁定文件名: 联锁
.dir-locals.el文件 目录变量
.emacs 文件 初始化文件
.mailrc文件 邮件别名
.newsrc文件 Gnus 启动

/
// 在文件名中 迷你缓冲区文件

7
7z 文件档案

8
8位显示 单字节模式
8位输入 单字节模式

'' 显示中 国际字符

_
_emacs初始化文件,MS-Windows 视窗主页

,在备份文件的名称中 备份名称
〜/.authinfo文件 验证
〜/.authinfo.gpg文件 验证
~/.config/emacs/init.el 文件 初始化文件
~/.emacs 文件 初始化文件
〜/.emacs.d/%backup%〜: 备份名称
〜/.emacs.d/gtkrc文件 GTK资源
〜/.gtkrc-2.0文件 GTK资源
~/.netrc 文件 验证
~/.Xdefaults文件 资源
~/.Xresources文件 资源

A
A 和 B 缓冲区(出现) 出现概述
A- 修改键
缩写文件 保存缩写
缩写模式 缩写概念
缩写 缩写
异常钩子 挂钩
中止递归编辑 戒烟
重音字符 单字节模式
可访问部分 缩小范围
积累分散的文本 累积文本
操作选项(命令行) Emacs 调用
激活标记 标记
活跃区域 标记
活动文本 帮助回声
自适应填充 自适应填充
添加文件,VC 注册
添加到 Dired 中的 Kill Ring 中 其他 Dired 功能
addpm,MS-Windows 安装程序 MS-Windows 注册表
调整缓冲区字体大小 文字比例
调整全局字体大小 文字比例
激进的滚动 自动滚动
闹钟 预约
对齐排除规则 代码对齐
对齐代码 代码对齐
评论对齐 评论命令
对齐规则 代码对齐
对齐部分 代码对齐
Alt键(MS-Windows) Windows 键盘
Alt键调用菜单 (Windows) Windows 键盘
Alt 键,充当 Meta 用户输入
Alt、修饰键 修改键
Alt-TAB与(MS-Windows)M-TAB Windows 键盘
ALTERNATE_EDITOR环境变量 emacsclient 选项
AltGr键(MS-Windows) Windows 键盘
ange-ftp: 远程文件
动画 娱乐项目
动画图像 图像模式
匿名FTP 远程文件
在环中追加杀戮 追加击杀数
预约通知 预约
恰如其分 恰如其分
apropos 搜索结果,按分数排序 恰如其分
阿拉伯语 语言环境
 文件档案
存档模式 文件档案
参数(命令行) Emacs 调用
命令的参数 论点
方向键 移动点
ASCII 用户输入
ASCII(语言环境) 语言环境
ASCII 艺术 文本
汇编模式 汇编模式
汇编模式 汇编模式
天文日数 日历系统
程序符号的即时文档 编程语言文档
附加框架(速度栏) 速度条
属性(Rmail) 邮件标签
模式线的属性,改变 可选模式线
自动压缩模式 压缩文件
自动填充模式 自动填充
自动恢复模式 自动恢复
自动保存模式 自动保存
自动保存远程文件 自动保存文件
自动加载 Lisp 库
自动加载 Lisp 库 初始化示例
自动滚动 自动滚动
自动版本备份 CVS 选项
避免鼠标妨碍您的打字 鼠标回避
awk模式 程序模式
AWK模式 C 模式

后端(版本控制) 版本控制系统
反向引用,在正则表达式中 正则表达式反斜杠
反向引用,在正则表达式替换中 正则表达式替换
背景颜色 面孔
背景颜色,命令行参数 颜色 X
菜单背景(X 资源) 资源表
背景模式,开启xterm 一般变量
背景语法高亮 字体锁定
BACKSPACE对比DEL DEL 不删除
回溯 崩溃
错误报告的回溯 清单
备份文件 备份
备份文件名 备份名称
MS-DOS 上的备份文件名 MS-DOS 文件名
备份文件,选择主要模式 选择模式
备份和用户 ID 备份复印
远程文件的备份 远程文件
巴哈伊日历 日历系统
平衡表达 表达式
气球帮助 帮助回声
基础缓冲区 间接缓冲区
段落的基本方向 双向编辑
basic,完成样式 完成样式
批处理模式 初始选项
电池状态(模式线上) 可选模式线
集市 版本控制系统
白俄罗斯语: 语言环境
孟加拉语 语言环境
bidi 格式化控制字符 双向编辑
双向编辑 双向编辑
捆绑 命令
绑定键盘宏 保存键盘宏
绑定键 重新绑定
空行 空行
程序中的空行 多行注释
闪烁的光标 光标显示
闪烁光标禁用,命令行参数 杂项 X
身体线条(轮廓模式) 大纲格式
书签注释 书签
书签 书签
边框颜色,命令行参数 颜色 X
边框(X 窗口系统) 边界X
无聊 娱乐项目
绑定分支(Bazaar VCS) 拉/推
零列中的大括号和字体 传统字体锁定
大括号,移动 帕伦斯移动
分支(版本控制) 分支机构
巴西葡萄牙语: 语言环境
浏览网址 浏览URL
气泡 娱乐项目
缓冲区内容 缓冲器
缓冲区定义索引 伊梅努
缓冲区列表,可定制 缓冲区菜单
缓冲区菜单 多个缓冲区
缓冲区大小显示 可选模式线
缓冲区大小,最大值 缓冲器
缓冲区文本乱码 文字乱码
缓冲区本地钩子 挂钩
缓冲区 缓冲器
错误标准 错误标准
错误参考 错误参考
错误报告,清单 清单
错误报告,原则 了解错误报告
错误跟踪器 已知问题
错误 虫子
构建细节 初始选项
建设计划 建筑
内置包 套餐菜单
内置包 包裹状态
保加利亚语: 语言环境
缅甸语 语言环境
蝴蝶 娱乐项目
按钮按下事件 鼠标按钮
纽扣 鼠标参考
按钮(自定义缓冲区) 定制组
缓冲区位置的按钮 编辑格式信息
绕过初始化和默认值.el文件 初始选项
字节码 Lisp 库
字节编译几个文件(在 Dired 中) 对文件进行操作
: 版本控制系统

C
C编辑 程式
C模式 C 模式
C#模式 程序模式
C++类浏览器,标签 标签 表格
C++模式 C 模式
C- 用户输入
文件名缓存 文件名缓存
日历 日历/日记
日历和 HTML 写入日历文件
日历和乳胶 写入日历文件
日历布局 日历定制
日历周数 日历定制
日历,一周的第一天 移至开头或结尾
调用 Lisp 函数,命令行参数 行动论据
骆驼香烟盒 混合大小写单词
蜡烛点燃时间 性爱日记条目
单词大写 案件
大小写转换 案件
替换命令中的大小写折叠 替换和宽松的匹配
搜索中的大小写折叠 宽松的搜索
案件已完成 完成选项
替换命令中的大小写保留 替换和宽松的匹配
区分大小写和完成 完成选项
区分大小写和搜索 宽松的搜索
区分大小写和标签搜索 标识符搜索
字符类别 正则表达式反斜杠
CBZ 文件 文档视图
单元格,对于基于文本的表格 表定义
居中 填充命令
集中版本控制 版本控制系统存储库
 语言环境
更改缓冲区 选择缓冲区
更改 Emacs 目录 初始选项
更改日志 变更日志
更改日志模式 更改日志命令
更改、撤消 撤消
基于变更集的版本控制 VCS 变更集
更改文件组(在 Dired 中) 对文件进行操作
更改文件所有者(在 Dired 中) 对文件进行操作
更改文件权限(在 Dired 中) 对文件进行操作
更改文件时间(在 Dired 中) 对文件进行操作
字符模式(终端仿真器) 终端仿真器
正则表达式中的字符类 正则表达式
搜索中的字符等效性 宽松的搜索
替换命令中的字符折叠 替换和宽松的匹配
搜索中的字符折叠 宽松的搜索
字符集(键盘) 用户输入
点 处字符的字符集 国际字符
字符集,在正则表达式中 正则表达式
字符语法 初始化语法
字符(文本中) 文字显示
特定字符集中的字符 字符集
属于特定语言的字符 正则表达式反斜杠
没有字体字形的字符 文字显示
字符,按名称或代码点插入 插入文本
字符集 字符集
流行 Emacs 命令备忘单 其他帮助
检查文件 风险投资概念
检查拼写 拼写
检查语法 飞美
报告错误之前的清单 清单
中国人 语言环境
中国日历 日历系统
选择主要模式 选择模式
选择次要模式 选择模式
密码 娱乐项目
引用邮件 引用邮件
CKJ 字符 修改字体集
类浏览器,C++ 标签 表格
清晰类型 Windows 字体
点击事件 鼠标按钮
客户端框架 emacsclient 选项
客户端字体 字体
剪贴板 剪贴板
剪贴板管理器 剪贴板
计时时间 时间间隔
关闭缓冲区 终止缓冲区
关闭文件 终止缓冲区
CMake模式 程序模式
代码对齐 代码对齐
代码页,MS-DOS MS-DOS 和 MULE
字符的代码点 修改字体集
Emacs 提交的编码标准 编码标准
编码系统 编码系统
碰撞 联锁
黑白打印机上的颜色模拟 PostScript 变量
颜色名称 颜色
窗口的颜色,来自命令行 颜色 X
配色方案 自定义主题
列号模式 可选模式线
列(和矩形) 矩形
列(缩进) 缩进
列,拆分 两柱式
康特模式 外壳模式
comint-highlight-input 交互式外壳
comint-highlight-prompt 交互式外壳
命令 命令
命令历史记录 重复
命令行参数 Emacs 调用
命令在*外部参考*缓冲区 外部参照命令
评论 评论
对自定义设置的评论 更改变量
通用 Lisp 外部 Lisp
比较文件(在 Dired 中) Dired 中的比较
比较 3 个文件 ( diff3) 比较文件
比较文件 比较文件
编译缓冲区,将点保留在末尾 汇编
编译错误 汇编
编译模式 编译模式
编译模式面临 编译模式
MS-DOS下编译 MS-DOS 进程
完整密钥 按键
完成 完成
补全(Lisp 符号) 符号完成
完成(符号名称) 符号完成
完成替代方案 完成
完成清单 完成命令
完成风格 完成样式
完成后,遍历候选人 迷你缓冲区历史
组成字符 单字节模式
压缩文件(在 Dired 中) 对文件进行操作
压缩 压缩文件
会议模式 程序模式
在迷你缓冲区中确认 完成退出
冲突,VC 合并
连接到远程主机 远程主机
连接局部变量 连接变量
缓冲区的内容 缓冲器
上下文菜单 菜单鼠标点击
续行 延续线
为 Emacs 做出贡献 贡献
控制 用户输入
控制字符 用户输入
显示控制字符 文字显示
将文本转换为大写或小写 案件
科普特历 日历系统
复制 剪切和粘贴
复制/粘贴到主要选择/从主要选择复制/粘贴 (macOS) Mac / GNUstep 基础知识
复制文件 复制和命名
复制文件(在 Dired 中) 对文件进行操作
复制文本 扬金
版权转让 版权转让
CORBA IDL 模式 C 模式
核心转储 崩溃
纠正拼写 拼写
CPerl模式 程序模式
崩溃报告 崩溃
崩溃 自动保存
崩溃,俳句 俳句基础知识
创建一个基于文本的表格 表创建
创建文件 参观
创建框架 创建框架
克罗地亚语 语言环境
裁剪图像 图像模式
密码分析 娱乐项目
CSS模式 程序模式
中船集团 版本控制系统
CUA 键绑定 CUA 绑定
弯引号 引号
大引号和终端功能 文字显示
大引号,插入 插入文本
当前缓冲区 缓冲器
模式行中的当前函数名称 哪个功能
当前消息(Rmail) Rmail 基础知识
当前的项目 项目文件命令
光标 观点
光标颜色,命令行参数 颜色 X
cursor 面孔
光标在非选定窗口中 光标显示
光标位置 职位信息
光标位置,在 MS-DOS 上 文本和二进制
光标运动 移动点
MS-DOS 上的光标形状 MS-DOS显示
光标,闪烁 光标显示
光标,视觉顺序运动 双向编辑
弯曲的引号 引号
曲线报价和终端功能 文字显示
弯曲的引号,插入 插入文本
自定义主题 自定义主题
自定义主题,创建 创建自定义主题
可定制变量 轻松定制
定制 定制化
定制缓冲区 轻松定制
定制组 定制组
menu面部定制 标准面
自定义面孔 脸部定制
自定义 Lisp 缩进 Lisp 缩进
自定义变量 更改变量
 剪切和粘贴
剪切和粘贴 词汇表
剪切文本 删除和杀掉
简历 VC目录模式
CVS 版本控制系统
CVS目录模式 VC目录模式
C警告模式 其他 C 命令
循环可见性,在大纲模式下 轮廓可见性
西里尔文 语言环境
捷克语: 语言环境

D
守护进程,Emacs Emacs服务器
一年中的某一天: 通用日历
夏令时 夏令时
数据库X 调试器
停用标记 标记
死亡角色 单字节模式
调试包 已知问题
调试器 调试器
调试 Emacs、技巧和技巧 清单
调试X问题 资源表
分散版本控制 版本控制系统存储库
解码邮件消息(Rmail) 邮件编码
解码 X 上的非ASCII键盘输入 通讯编码
减小缓冲区字体大小 文字比例
解密文件(在 Dired 中) 对文件进行操作
默认参数 基本迷你缓冲区
默认目录 迷你缓冲区文件
缓冲区的默认目录 文件名
default face: 面孔
默认文件名 文件名
默认搜索模式 搜索定制
默认值.el文件,未加载 初始选项
默认值.el,默认初始化文件 初始化文件
定义键盘宏 键盘宏
解乐趣 移动由 Defuns 提供
DEL不删除 DEL 不删除
DEL对比BACKSPACE DEL 不删除
删除选择模式 使用地区
删除窗口 更改窗口
删除自动保存文件 标记许多文件
删除空行 空行
删除字符和行 擦除
删除文件(在 Dired 中) 直接删除
删除基于文本的表格中的行和列 表格行和列
删除一些备份文件 标记许多文件
删除窗口 更改窗口
删除 删除和杀掉
删除(文件) 其他文件操作
删除(Rmail) 邮件删除
取消引用符号链接 对文件进行操作
桌面配置 保存 Emacs 会话
守护进程模式下的桌面恢复 保存 Emacs 会话
桌面快捷方式,MS-Windows Windows启动
确定性构建 初始选项
天成文 语言环境
Emacs 终端 I/O 设备 初始选项
对话框 对话框
Dialog X 资源(Lucid 小部件) 清醒资源
日记 日记
日记缓冲区 日记展示
日记文件 日记文件格式
差异模式 差异模式
摘要消息 邮件文摘
定向窗口选择 窗口便利
缓冲区名称中的目录 统一
目录标题行 子目录运动
目录列表 目录
MS-DOS 上的目录列表 MS-DOS 进程
目录名称缩写 文件别名
目录跟踪 目录追踪
MS-Windows 上 Emacs 启动的目录 Windows启动
目录局部变量 目录变量
迪雷 迪雷德
Dired 和版本控制 其他 Dired 功能
直接排序 更新中
直接排序顺序,在 MS-Windows/MS-DOS 上 Lisp 中的 ls
Dired 和 MS-Windows/MS-DOS Lisp 中的 ls
土轨模式 目录追踪
禁用桌面配置恢复 保存 Emacs 会话
禁用窗口系统 初始选项
禁用命令 禁用
禁用远程文件 远程文件
DISPLAY环境变量 显示X
Emacs 框架的显示 初始选项
显示行号 显示定制
显示名称(X 窗口系统) 显示X
显示缓冲区大小 可选模式线
显示当前行号 可选模式线
显示服务器 多显示器
显示,不正确 屏幕乱码
分布式版本控制 版本控制系统存储库
DNS模式 程序模式
Dockerfile模式 程序模式
DocTeX 模式 TeX 模式
文档查看器(DocView) 文档视图
程序符号的文档 编程语言文档
文档字符串 主要帮助
文档查看模式 文档视图
从 Emacs 运行的 DOS 应用程序 Windows进程
DOS 代码页 MS-DOS 和 MULE
DOS 风格的行尾显示 识别编码
文件从 DOS 到 Unix 的转换 文本和二进制
双击 鼠标按钮
文件名中的双斜杠 迷你缓冲区文件
向下事件 鼠标按钮
小写文件名 转换文件名
拖放 拖放
拖放, Dired 其他 Dired 功能
拖动事件 鼠标按钮
巨大的变化 恢复
运球文件 清单
DSSSL 模式 程序模式
邓尼特 娱乐项目
荷兰语 语言环境
DVI 文件 文档视图

早期初始化文件 早期初始化文件
早期初始化.el文件 早期初始化文件
浏览 标签 表格
回声区域 回声区
回显区域消息 回声区
回声 回声区
EDE(Emacs开发环境) EDE
调试 清单
可编辑字段(自定义缓冲区) 定制组
编辑二进制文件 编辑二进制文件
图片模式编辑 基本图片
编辑级别,递归 递归编辑
EDITOR环境变量 Emacs服务器
八位字符集 国际字符
电子文档模式 编程语言文档
电动压痕模式 缩进便利
电动配对模式 匹配
电力报价模式 引号
伊丽莎 娱乐项目
Emacs 作为服务器 Emacs服务器
Emacs开发环境 EDE
Emacs 图标,一个 gnu 图标X
Emacs初始化文件 初始化文件
Emacs Lisp 模式 Lisp 评估
Emacs Lisp 包存档 套餐
emacs-internal,编码系统 编码系统
emacs22,完成样式 完成样式
emacs客户端 Emacs服务器
emacsclient调用 调用 emacsclient
emacsclient选项 emacsclient 选项
emacsclient,在 MS-Windows 上 Windows启动
emacsclient.exe Windows启动
emacsclientw.exe Windows启动
emacs_backtrace.txt文件,MS-Windows 崩溃
电子邮件 发送邮件
嵌入式小部件 嵌入式 WebKit 小部件
出现 出现
紧急逃生 紧急逃生
表情符号输入 输入法
暂时启用瞬态标记模式 禁用瞬态标记
字符编码 国际的
加密文件,选择主要模式 选择模式
加密邮件(在 Rmail 中读取) 邮件显示
加密文件(在 Dired 中) 对文件进行操作
加密 网络安全
行结束约定,模式行指示 模式线
行尾转换 编码系统
MS-DOS/MS-Windows 上的行尾转换 文本和二进制
英语 语言环境
丰富模式 丰富的文本
丰富文本 丰富的文本
进入Emacs 进入Emacs
输入密码 密码
环境变量 环境
环境变量(macOS) Mac / GNUstep 基础知识
子shell的环境变量 交互式外壳
文件名中的环境变量 文件名
EPUB 文件 文档视图
等效字符序列 宽松的搜索
擦除字符和线条 擦除
错误日志 汇编
错误信息 回声区
初始化文件中的错误 初始选项
ESC更换Meta钥匙 用户输入
文件中的转义序列 识别编码
escape-glyph 文字显示
ESHELL环境变量 交互式外壳
世界语 语言环境
电子标签 标签 表格
etags程序 创建标签表
埃塞俄比亚 语言环境
埃塞俄比亚日历: 日历系统
欧洲字符集 单字节模式
评估表达式,命令行参数 行动论据
评估,Emacs Lisp Lisp 评估
macOS 上的事件 Mac / GNUstep 事件
退出增量搜索 基础搜索
退出 退出
退出递归编辑 递归编辑
扩展 Dired 中的子目录 Dired 中的子目录
扩展(缩写) 缩写
C 宏的扩展 其他 C 命令
环境变量的扩展 文件名
表达 表达式
删除(Rmail) 邮件删除

F
面对点 国际字符
脸部颜色,设置 颜色
面孔 面孔
用于突出显示查询替换的面孔 查询替换
用于突出显示搜索匹配项的面孔 基础搜索
模式线的面 标准面
文本模式菜单的面孔 标准面
MS-DOS 下的面孔 MS-DOS显示
面孔,定制 脸部定制
合并失败 比较文件
后备模式 指定文件变量
FB2 文件 文档视图
反馈邮件 邮件发送
FFAP 次要模式 FFAP
狗模式 我完成
文件档案 文件档案
文件比较(在 Dired 中) Dired 中的比较
文件数据库(定位) 定向并查找
文件日期 联锁
文件目录 目录
文件局部变量 文件变量
文件锁定 联锁
文件管理 迪雷德
文件模式 其他文件操作
文件名缓存 文件名缓存
文件名 文件名
MS-Windows 上的文件名 Windows 文件
MS-DOS 下的文件名 MS-DOS 文件名
Windows 95/NT 下的文件名 MS-DOS 文件名
包含非ASCII字符的文件名 文件名编码
文件名、MS-Windows 上的无效字符 Windows 文件
文件名,引用特殊字符 引用的文件名
文件通知 自动恢复
文件所有权和备份 备份复印
文件权限 其他文件操作
文件选择对话框 参观
文件选择对话框,如何禁用 对话框
文件阴影 文件阴影
文件真实姓名 文件别名
更改日志条目中的文件版本 更改日志命令
文件,大小较大时发出警告 参观
基于文件的版本控制 VCS 变更集
文件名完成,在 MS-Windows 上 Windows 文件
文件名编码,MS-Windows 文件名编码
文件 文件
添加到 VCS 的文件 注册
文件、访问和保存 参观
文件集 文件集
文件集,VC 基本 VC 编辑
文件集,VC,在 Dired 缓冲区中 版本控制
填写前缀 填充前缀
填充文字 填充
寻找 文件名缓存
find和迪雷德 定向并查找
找到符号的定义 查找标识符
通过文件名查找信息手册 其他帮助
查找对符号的引用 查找标识符
取景器 套餐关键词
在点查找文件 FFAP
查找包含正则表达式匹配的文件(在 Dired 中) 标记与旗帜
在文本中查找字符串 搜索
防火墙,以及访问远程文件 远程文件
修复错误解码的邮件消息 邮件编码
标记文件(在 Dired 中) 直接删除
将许多文件标记为删除(在 Dired 中) 标记许多文件
flex,完成样式 完成样式
飞语模式 拼写
折叠编辑 展开
跟随模式 跟随模式
按照符号链接 对文件进行操作
字体抗锯齿(MS Windows) Windows 字体
字体后端选择(俳句) 俳句字体
字体后端选择(MS-Windows) Windows 字体
菜单字体(X 资源) 资源表
字体锁定模式 字体锁定
字体查找,MS-Windows Windows 字体
字体名称(X 窗口系统) 字体X
点处字符的字体 国际字符
字体属性(MS Windows) Windows 字体
字体脚本(MS Windows) Windows 字体
脸部字体大小default,增大或减小 文字比例
字体规范(MS Windows) Windows 字体
字体 Unicode 子范围 (MS Windows) Windows 字体
通过 tree-sitter 进行字体锁定 基于解析器的字体锁定
字体配置 字体
字体 字体
字体和面孔 脸部定制
PostScript 打印字体 PostScript 变量
各种脚本的字体 字体集
字体,在 MS-DOS 下模拟 MS-DOS显示
字体,如何忽略 修改字体集
字体集 字体集
字体集,修改 修改字体集
前景色,命令行参数 颜色 X
菜单前景(X 资源) 资源表
换页符 页数
Fortran 77 和 Fortran 90、95、2003、2008 福特兰语言
Fortran 延续行 缩进续
Fortran 固定形式和自由形式 福特兰语言
Fortran模式 福特兰语言
幸运饼干 邮件娱乐
转发消息 邮件回复
框架 屏幕
框架焦点策略,MS-Windows Windows 杂项
MS-DOS 下的帧大小 MS-DOS显示
帧大小,指定默认值 机架参数
框架标题,命令行参数 第十条
 镜框
MS-DOS 上的帧 MS-DOS显示
框架集 配置寄存器
框架集,保存在寄存器中 配置寄存器
法语 语言环境
法国大革命日历 日历系统
fringe 标准面
边缘 流苏
边缘和延续线 延续线
边缘和未使用的线条指示 无用的空白
边缘,用于调试 源缓冲区
FTP 远程文件
全高,命令行参数 窗口尺寸 X
全屏,命令行参数 窗口尺寸 X
全角,命令行参数 窗口尺寸 X
功能键 键位图
函数,移动到开头或结尾 移动由 Defuns 提供
文件名的未来历史记录 迷你缓冲区历史

G
游戏 娱乐项目
伽马校正(X 资源) 资源表
显示乱码 屏幕乱码
乱码文本 文字乱码
网关和远程文件访问ange-ftp 远程文件
广东发展局 调试器
GDB 用户界面布局 GDB 用户界面布局
Emacs 窗口的几何形状 窗口尺寸 X
几何,命令行参数 窗口尺寸 X
格鲁吉亚语 语言环境
德语 语言环境
获取有关密钥的帮助 基本帮助
Ghostscript,用于 PostScript 打印 视窗打印
git 版本控制系统
包的 git 来源 获取包源
眼镜模式 混合大小写单词
全局自动恢复模式 自动恢复
全局键盘映射 键位图
全球标记 CUA 绑定
全局标记环 全球标志戒指
全局替代 代替
globstar,在 Dired 中 直接输入
词汇表 词汇表
无字形字符 文字显示
glyphless-char 文字显示
'gnu.emacs.帮助' 新闻组 服务
牛羚 牛羚
GNU步骤 Mac 操作系统/GNUstep
去莫库 娱乐项目
转到地址模式 转到地址模式
图形字符 插入文本
希腊语 语言环境
公历 其他日历
分组,用正则表达式 正则表达式反斜杠
不断增长的迷你缓冲区 迷你缓冲区编辑
GTK字体图案 字体
GTK输入法 单字节模式
GTK+ 资源 GTK资源
GTK+ 风格 GTK风格
GTK+ 小部件类 Emacs 中的 GTK 名称
GTK+ 小部件名称 GTK 小部件名称
Emacs 中的 GTK+ 小部件名称 Emacs 中的 GTK 名称
GUD交互缓冲区 调试器操作
GUD库 调试器
GUD 工具提示模式 调试器操作
猜测文件的 shell 命令(在 Dired 中) Shell 命令猜测
吉耶梅茨 引号
古吉拉特语 语言环境
压缩 压缩文件

H
H- 修改键
俳句 俳句
俳句应用 俳句基础知识
俳句调试器 俳句基础知识
俳句安装 俳句基础知识
俳句键盘映射 俳句基础知识
俳句工具提示 俳句基础知识
 国际的
笔迹 后记
韩文 国际的
硬链接(创建) 复制和命名
硬链接(在 Dired 中) 对文件进行操作
硬链接(访问) 文件别名
硬换行 硬换行符和软换行符
硬拷贝 印刷
标题(TeX 模式) TeX 打印
标题行(定向) 子目录运动
header-line 标准面
header-line-highlight 标准面
(邮件消息的)标题 邮件标头
标题行(大纲模式) 大纲格式
希伯来语 语言环境
希伯来历 日历系统
迷你缓冲区的高度 迷你缓冲区编辑
水平滚动条的高度 滚动条
帮助 帮助
帮助缓冲区 帮助
帮助使用 Emacs 服务
帮助模式 帮助模式
GTK+ 文件选择器中的帮助文本 对话框
帮助,查看网页 帮助模式
'帮助-gnu-emacs' 邮件列表 服务
十六进制编辑 编辑二进制文件
十六进制模式 编辑二进制文件
 版本控制系统
高锁定模式 交互式突出显示
隐藏文件,在 GTK+ 文件选择器中 对话框
隐藏 ifdef 模式 其他 C 命令
隐藏显示模式 秀秀
在 Dired 中隐藏详细信息 其他 Dired 功能
隐藏子目录(Dired) 隐藏子目录
突出显示更改模式 交互式突出显示
突出显示当前行 光标显示
通过匹配突出显示 交互式突出显示
突出显示文本行 交互式突出显示
突出显示匹配的括号 匹配
突出显示短语 交互式突出显示
突出显示区域 禁用瞬态标记
突出显示点处的符号 交互式突出显示
印地语 国际的
命令历史 重复
迷你缓冲区输入的历史记录 迷你缓冲区历史
webkit 缓冲区的历史 嵌入式 WebKit 小部件
历史参考 历史参考文献
假期形式 节日定制
假期 假期
MS-Windows 上的主目录 视窗主页
主目录简写 迷你缓冲区文件
MS-DOS 下的 HOME 目录 MS-DOS 文件名
homoglyph 文字显示
 挂钩
水平滚动条 滚动条
水平滚动条模式 滚动条
水平滚动 水平滚动
沙漏指针显示 显示定制
HTML模式 HTML模式
饥饿删除(C 模式) 饿删除
大块头,差异 差异模式
Hyper(在 MS-DOS 下) MS-DOS 键盘
Hyper,修饰键 修改键
超级链接 帮助模式
超链接 鼠标参考

i日历支持 导入日记
我完成模式 我完成
I完整垂直模式 我完成
图标模式 程序模式
图标化 退出
图标(X 窗口系统) 图标X
图标,在可点击的按钮上 图标
图标、工具栏 工具栏
标识符,查找 的定义 查找标识符
IDL模式 C 模式
IDLWAVE 模式 程序模式
忽略大小写 词汇表
忽略字体 修改字体集
忽略文件名,完成后 完成选项
图像动画 图像模式
图像调整大小 图像模式
图像旋转 图像模式
image-dired: 图像定向
image-dired模式 图像定向
ImageMagick 支持 图像模式
图像,查看 图像模式
IMAP 邮箱 远程邮箱
IME、MS-Windows Windows 键盘
原位子目录(Dired) Dired 中的子目录
收件箱文件 邮件收件箱
不正确的字体 传统字体锁定
增加缓冲区字体大小 文字比例
增量搜索 增量搜索
增量搜索,编辑搜索字符串 重复搜索
增量搜索,退出 基础搜索
增量搜索,转到第一个或最后一个出现的位置 特殊研究
增量搜索,特殊键帮助 特殊研究
增量搜索、输入法干扰 输入法
缩进 缩进
注释缩进 评论命令
程序的缩进 程序缩进
缓冲区定义索引 伊梅努
间接缓冲区 间接缓冲区
间接缓冲区和轮廓 轮廓视图
劣质工艺 汇编
MS-DOS 下的劣质进程 MS-DOS 进程
信息 其他帮助
初始化文件 初始化文件
初始化文件.emacs在 MS-Windows 上 视窗主页
init 文件,MS-DOS 下的默认名称 MS-DOS 文件名
初始化文件,未加载 初始选项
初始选项(命令行) Emacs 调用
initials,完成样式 完成样式
输入事件 用户输入
输入项,isearch 基础搜索
输入法样式,X 资源表
输入方法 输入法
输入法,本机 单字节模式
输入法,X 资源表
用键盘输入 用户输入
inputStyle(X资源) 资源表
按名称或代码点插入字符 输入法
插入文件内容,命令行参数 行动论据
插入 Unicode 字符 插入文本
插入的子目录(Dired) Dired 中的子目录
插入空行 空行
插入表情符号 输入法
插入匹配的括号 匹配
在基于文本的表格中插入行和列 表格行和列
插入 插入文本
INSIDE_EMACS环境变量 交互式外壳
集成开发环境 EDE
交互式突出显示 交互式突出显示
交互式编辑搜索字符串 重复搜索
内部边框宽度,命令行参数 边界X
国际人物.emacs: 初始化非 ASCII
来自 DOS/Windows 系统的国际文件 编码系统
国际脚本 国际的
国际支持(MS-DOS) MS-DOS 和 MULE
互联网搜索 单词搜索
PostScript 打印的 Intlfonts PostScript 变量
Intlfonts包,安装 字体集
看不见的线 轮廓模式
不可见文本和查询替换 查询替换
不可见文本,搜索 特殊研究
调用(命令行参数) Emacs 调用
从 Windows 资源管理器调用 Emacs Windows启动
国际音标 语言环境
我搜索 增量搜索
isearch 基础搜索
isearch 输入项 基础搜索
isearch 多个缓冲区 其他重复搜索
i搜索多个文件 其他重复搜索
isearch-fail 搜索错误
isearch-move财产 不退出 Isearch
isearch-scroll财产 不退出 Isearch
伊斯兰历 日历系统
ISO 商业日历 日历系统
ISO 拉丁字符集 单字节模式
iso-ascii图书馆 单字节模式
iso-transl图书馆 单字节模式
ispell程序 拼写
问题跟踪器 已知问题
意大利语 语言环境

J
日本人 语言环境
罐子 文件档案
Java 类档案 文件档案
Java模式 C 模式
JavaScript 模式 程序模式
加多宝 调试器
JSON模式 程序模式
儒略历 日历系统
儒略日数字 日历系统
即时(JIT)字体锁定 字体锁定
理由 填充命令
基于文本的表格的理由 单元格对齐
理由风格 丰富的理由

K
卡纳达语 语言环境
Kerberos POP3 身份验证 远程邮箱
钥匙 按键
键绑定 按键绑定
密钥重新绑定,永久 初始化重新绑定
密钥重新绑定,本次会话 重新绑定
按键顺序 按键
键序列语法 初始化重新绑定
键盘输入 用户输入
键盘宏 键盘宏
键盘宏,在寄存器中 键盘宏寄存器
键盘快捷键 词汇表
键盘,MS-Windows Windows 键盘
键位图 键位图
键盘 功能键
键盘按键(MS-Windows) Windows 键盘
密钥被窗口管理器窃取 用户输入
保留键 按键绑定
高棉语 语言环境
杀死 DOS 应用程序 Windows进程
杀环 扬金
杀死缓冲区 终止缓冲区
杀死字符和台词 擦除
杀死 Emacs 退出
杀戮表情 表达式
杀死文本的矩形区域 矩形
杀戮文本 删除和杀掉
杀死未保存的缓冲区 终止缓冲区
避头尾换行规则 自动填充
已知的错误和问题 已知问题
韩国人 语言环境

L
标签(Rmail) 邮件标签
语言环境,MS-DOS 上自动选择 MS-DOS 和 MULE
语言环境 语言环境
老挝语 语言环境
大型编程项目,维护 维护
乳胶模式 TeX 模式
拉丁语 语言环境
Latin-1 TeX 编码 杂项
拉脱维亚语: 语言环境
从跟踪器启动 Emacs 俳句基础知识
宽松的搜索 宽松的搜索
替换命令中的空格匹配不严格 替换和宽松的匹配
搜索中的宽松空间匹配 宽松的搜索
惰性突出显示自定义 搜索定制
惰性搜索突出显示 重复搜索
lazy-highlight 搜索定制
lazy-highlight面,替换 查询替换
离开 Emacs 退出
图书馆 Lisp 库
生活 娱乐项目
行结尾 编码系统
线路模式(终端仿真器) 终端仿真器
行号命令 职位信息
行号显示 可选模式线
行间距(X 资源) 资源表
行间距,命令行参数 杂项 X
行截断 行截断
线截断和边缘 延续线
换行 延续线
line-number 显示定制
行,突出显示 交互式突出显示
链接 鼠标参考
链接(自定义缓冲区) 定制组
Lisp 字符语法 初始化语法
Lisp 编辑 程式
口齿不清模式 外部 Lisp
Lisp 对象语法 初始化语法
Lisp 字符串语法 初始化语法
Lisp 符号补全 符号完成
lisp-indent-function财产 Lisp 缩进
列出命令 帕伦斯移动
列出当前缓冲区 列表缓冲区
列出系统字体 字体
立陶宛语 语言环境
加载另一个用户的初始化文件 初始选项
Emacs Lisp 的加载路径 Lisp 库
加载 Lisp 代码 Lisp 库
自动加载 Lisp 库 初始化示例
加载 Lisp 库,命令行参数 行动论据
加载多个文件(在 Dired 中) 对文件进行操作
本地键盘映射 本地键盘映射
局部变量 当地人
文件中的局部变量 文件变量
局部变量,适用于目录中的所有文件 目录变量
局部变量,适用于所有远程连接 连接变量
区域设置,日期格式 时间戳
语言环境 语言环境
点的位置 职位信息
锁定文件模式 联锁
锁定(CVS) CVS 选项
锁定文件 联锁
锁定,非严格(RCS) RCS 和 SCCS
基于锁定的版本 版本控制系统合并
轨迹 编译模式
日志编辑模式 日志缓冲区
日志文件,类型 日志文件的类型
记录击键 清单
逻辑线 延续线
逻辑顺序 双向编辑
Windows 95/NT 下 DOS 框中的长文件名 MS-DOS 文件名
在文档中寻找主题 帮助
丢失选择模式 初选
MS-DOS 下 lpr 的用法 视窗打印
LRM 双向编辑
ls仿真 Lisp 中的 ls
Lucid Widget X 资源 清醒资源
lz 文件档案

中号
中号-: 用户输入
M-TAB与(MS-Windows)Alt-TAB Windows 键盘
M4模式 程序模式
麦金塔电脑 Mac 操作系统/GNUstep
Macintosh 行尾转换 编码系统
苹果系统 Mac 操作系统/GNUstep
C 中的宏扩展 其他 C 命令
邮件 发送邮件
邮件(在模式线路上) 可选模式线
邮件别名 邮件别名
MAIL环境变量 邮件收件箱
邮件方式 邮寄方式
邮件签名 邮件签名
邮件撰写方法 邮寄方式
邮件客户端 邮件发送
MAILHOST环境变量 远程邮箱
mailrc文件 邮件别名
主边框宽度,命令行参数 边界X
维护大型程序 维护
主要模式 主要模式
制作 汇编
生成文件模式 程序模式
用文字字符制作图片 图片模式
马拉雅拉姆语: 语言环境
手册页 手册页
手册页和本地文件变量 指定文件变量
操纵段落 段落
操纵句子 句子
操纵文本 文本
手册页,在 MS-DOS/MS-Windows 上 手册页
手动版本备份 CVS 选项
手册,包括 其他帮助
标记 标记
标记矩形 矩形
标记环 马克环
标记可执行文件(在 Dired 中) 标记与旗帜
标记许多文件(在 Dired 中) 标记与旗帜
标记文本部分 标记对象
标记子目录(在 Dired 中) 标记与旗帜
标记符号链接(在 Dired 中) 标记与旗帜
匹配(面孔名称) 其他重复搜索
匹配括号 匹配
匹配括号和大括号,移动到 帕伦斯移动
最大化的命令行参数 窗口尺寸 X
超出最大缓冲区大小,错误消息 参观
玛雅历法 玛雅历法
玛雅历法轮 玛雅历法
玛雅历法 日历系统
玛雅哈卜历 玛雅历法
玛雅长数 玛雅历法
玛雅卓尔金日历 玛雅历法
mbox 文件 邮件收件箱
内存已满 内存已满
菜单栏 菜单栏
菜单栏(X 资源) 资源表
使用键盘访问菜单栏 菜单栏
菜单栏外观 标准面
菜单栏模式 菜单栏
menu脸,如果定制则没有效果 标准面
菜单 X 资源(Lucid 小部件) 清醒资源
菜单 X 资源(Motif 小部件) 主题资源
水银 版本控制系统
合并缓冲区(出现) 出现概述
合并文件中的邮件 (Rmail) Rmail 文件
合并,失败 比较文件
合并变更 合并
合并文件 出现
基于合并的版本 版本控制系统合并
信息 发送邮件
留言模式 邮件命令
消息模式发送邮件 邮寄方式
消息号码(Rmail) Rmail 基础知识
从回显区域保存的消息 回声区
梅塔 用户输入
元(MS-DOS 下) MS-DOS 键盘
元命令和单词 
元字体模式 程序模式
MH邮件接口 邮寄方式
微软Office文件 文档视图
微软Windows 微软Windows
午夜模式 终止缓冲区
哑剧 邮件杂项
MIME 消息 (Rmail) 邮件显示
迷你缓冲区 迷你缓冲区
迷你缓冲区确认 完成退出
文件名的迷你缓冲区默认值 迷你缓冲区历史
迷你缓冲电动默认模式 基本迷你缓冲区
迷你缓冲区历史记录 迷你缓冲区历史
迷你缓冲区历史记录,搜索 Isearch迷你缓冲区
迷你缓冲区键盘映射 迷你缓冲区映射
minibuffer-prompt 标准面
最小化 退出
启动时最小化一帧 图标X
次要模式键盘映射 本地键盘映射
小调 小调
错误,改正 修理它
次要模式的模式命令 小调
模式挂钩 主要模式
模式挂钩和主要模式 程序模式
模式线 模式线
模式行 (MS-DOS) MS-DOS 和 MULE
模式线,3D外观 可选模式线
模式线、鼠标 模式线鼠标
模式,缩写 缩写概念
模式,存档 文件档案
模式,自动压缩 压缩文件
模式,自动填充 自动填充
模式,自动恢复 自动恢复
模式,自动保存 自动保存
模式,AWK C 模式
模式,C C 模式
模式,C++ C 模式
模式,列号 可选模式线
模式,Comint 外壳模式
模式,编译 编译模式
模式,CORBA IDL C 模式
模式,删除选择 使用地区
模式,Dirtrack 目录追踪
模式,显示填充列指示器 显示边界
模式,DocTeX TeX 模式
模式,文档视图 文档视图
模式,电动压痕 缩进便利
模式,电力报价 引号
模式,Emacs Lisp Lisp 评估
模式,丰富 丰富的文本
模式,飞语 拼写
模式,遵循 跟随模式
模式,字体锁定 字体锁定
模式,Fortran 福特兰语言
模式,眼镜 混合大小写单词
模式,全局自动恢复 自动恢复
模式,转到地址 转到地址模式
模式,GUD 工具提示 调试器操作
模式,十六进制 编辑二进制文件
模式,隐藏显示 秀秀
模式,HTML HTML模式
模式,Java C 模式
模式,乳胶 TeX 模式
模式,Lisp 外部 Lisp
模式,日志编辑 日志缓冲区
模式,邮件 邮寄方式
模式,主要 主要模式
模式,菜单栏 菜单栏
模式,消息 邮件命令
模式,迷你缓冲电动默认 基本迷你缓冲区
模式,次要 小调
模式,鼠标滚轮 鼠标命令
模式,最高有效位 缓冲区菜单
模式,nXML HTML模式
模式,目标 C C 模式
模式,发生 其他重复搜索
模式,发生编辑 其他重复搜索
模式,组织 组织模式
模式,概要 轮廓模式
模式,覆盖 小调
模式,段落缩进文本 文本模式
模式,派克 C 模式
模式、方案 外部 Lisp
模式,滚动条 滚动条
模式,全部滚动 窗口便利
模式,语义 语义学
模式,SGML HTML模式
模式,外壳 外壳模式
模式,SliTeX TeX 模式
模式,标签栏 标签栏
模式,焦油 文件档案
模式,期限 期限模式
模式,TeX TeX 模式
模式,文本 文本模式
模式,大拇指 图像模式
模式,工具栏 工具栏
模式,瞬态标记 禁用瞬态标记
模式,视图 查看模式
模式,视线 视线模式
模式,空白 无用的空白
模式,窗口分隔符 窗隔板
模式,获胜者 窗口便利
模式,XML HTML模式
mode-line 标准面
mode-line-buffer-id 标准面
mode-line-highlight 标准面
mode-line-inactive 标准面
编辑程序的模式 挂钩
编程语言模式 程序模式
修改日期 时间戳
修改(缓冲区) 参观
修改键自定义(俳句) 俳句基础知识
修饰键 用户输入
修饰键 (macOS) Mac / GNUstep 基础知识
修饰键和系统键映射(俳句) 俳句基础知识
键盘不支持修饰键 修改键
修饰键和键重新绑定 修改键
模块2模式 程序模式
模块验证 初始选项
月亮,月相 月相
摩尔斯电码 娱乐项目
Motif Widget X 资源 主题资源
增量搜索期间的运动命令 不退出 Isearch
鼠标回避 鼠标回避
鼠标按钮事件 鼠标按钮
鼠标按钮(它们的作用) 鼠标命令
鼠标输入 鼠标输入
鼠标放在模式线上 模式线鼠标
鼠标指针 显示定制
鼠标指针颜色,命令行参数 颜色 X
鼠标支持 纯文本鼠标
MS-DOS 下的鼠标支持 MS-DOS鼠标
鼠标滚轮 鼠标命令
鼠标滚轮次要模式 鼠标命令
鼠标和 MS-Windows Windows鼠标
鼠标,拖动 鼠标命令
鼠标,使用以下命令选择文本 鼠标命令
鼠标,设置按钮数量 MS-DOS鼠标
移动到函数的开头或结尾 移动由 Defuns 提供
移动邮件 远程邮箱
movemail程序 移动邮件
移动 移动点
移动文件(在 Dired 中) 对文件进行操作
在日历内移动 日历运动
移动点 移动点
移动文本 扬金
移动光标 移动点
MS-DOS 行尾转换 编码系统
MS-DOS 的特点 操作系统
MS-Windows 代码页 MS-DOS 和 MULE
MS-Windows 键盘快捷键 Windows 键盘
MS-Windows 和主要选择 初选
MS-Windows、Emacs 的特点 微软Windows
最高有效位模式 缓冲区菜单
骡子 词汇表
多字节字符 国际的
多个显示器 多显示器
多个源文件搜索和替换 标识符搜索
轮廓的多个视图 轮廓视图
Emacs 中的多个窗口 视窗
多缓冲区 isearch 其他重复搜索
多文件 isearch 其他重复搜索
多用途互联网邮件扩展 邮件杂项
GDB中的多线程调试 多线程调试

备份文件的名称 备份名称
缩小范围 缩小范围
缩小和行号显示 可选模式线
本机编译 Lisp 库
嵌套 defun 移动由 Defuns 提供
'净使用',并在 MS-Windows 上打印 视窗打印
网络安全管理员 网络安全
网络打印机 (MS-Windows) 视窗打印
新队 插入文本
换行符,硬换行符和软换行符 硬换行符和软换行符
新闻阅读器 牛羚
下一个错误跟随模式 编译模式
NFS 和退出 戒烟
 词汇表
no-conversion,编码系统 编码系统
nobreak-space 文字显示
ASCII字符.emacs: 初始化非 ASCII
ASCII键,绑定 初始化非 ASCII
不间断连字符 文字显示
不间断空格 文字显示
非贪婪正则表达式匹配 正则表达式
窗口中的非整数行数 可选模式线
未选择的窗口,模式线外观 可选模式线
GDB 中不间断调试 多线程调试
非严格锁定(RCS) RCS 和 SCCS
非增量搜索 非增量搜索
普通钩子 挂钩
诺夫 诺夫模式
ns-打开文件事件 Mac / GNUstep 事件
ns-打开文件行事件 Mac / GNUstep 事件
ns-打开临时文件事件 Mac / GNUstep 事件
ns 断电事件 Mac / GNUstep 事件
ns-show-prefs 事件 Mac / GNUstep 事件
美国国家安全局 邮件娱乐
国家标准局 网络安全
缓冲区中的行数 显示定制
数字参数 论点
nXML模式 HTML模式

目标C模式 C 模式
过时的命令 MX
发生编辑模式 其他重复搜索
发生方式 其他重复搜索
八进制转义 文字显示
八度模式 程序模式
奥马尔计数 性爱日记条目
OOM 杀手 内存已满
奥帕斯卡模式 程序模式
打开文件 参观
最左列中的左括号 左边距括号
打开文档文件 文档视图
对 Dired 中的文件进行操作 对文件进行操作
对标记区域的操作 使用地区
选项(命令行) Emacs 调用
组织议程 组织组织者
组织导出 组织创作
组织模式 组织模式
组织者 组织模式
奥里亚语 语言环境
内存不足 内存已满
内存不足杀手,GNU/Linux 内存已满
外边框宽度,命令行参数 边界X
大纲模式 轮廓模式
具有多个视图的大纲 轮廓视图
覆盖在字符位置 编辑格式信息
覆盖字符终端颜色支持 颜色 X
过度滚动 滚动条
包裹式搜索 重复搜索
覆盖模式 小调
OXPS 文件 文档视图

包裹 套餐
包存档 套餐
包开发源码 获取包源
包目录 打包文件
包文件 打包文件
套餐菜单 套餐菜单
包装要求 包安装
包裹安全 包安装
包签名 包安装
包装规格 获取包源
包裹状态 包裹状态
页面 页数
Term 模式下的分页 期限模式
段落,基本方向 双向编辑
段落缩进文本模式 文本模式
段落 段落
帕拉莎,每周 性爱日记条目
括号,显示匹配项 匹配
括号,移过 帕伦斯移动
零列中的括号和字体 传统字体锁定
括号内的分组 帕伦斯移动
基于解析器的字体锁定 基于解析器的字体锁定
部分完成 完成样式
partial-completion,完成样式 完成样式
粘贴 剪切和粘贴
粘贴 扬金
补丁,应用 差异模式
补丁,编辑 差异模式
补丁,发送 发送补丁
PCL-CVS : VC目录模式
数据库 调试器
PDF 文件 文档视图
待定,在增量搜索中 正则表达式搜索
每个缓冲区变量 当地人
每个连接的局部变量 连接变量
每个目录的局部变量 目录变量
Perl模式 程序模式
佩尔数据库 调试器
波斯语 语言环境
波斯历 日历系统
月相 月相
短语,突出显示 交互式突出显示
图片模式和矩形 图片中的矩形
图片 图片模式
派克模式 C 模式
捏合缩放 文字比例
将 Emacs 固定到 Windows 任务栏 Windows启动
策划师 组织模式
观点 观点
点位置 职位信息
点位置,在 MS-DOS 上 文本和二进制
抛光 语言环境
乒乓球比赛 娱乐项目
POP3 邮箱 远程邮箱
Emacs 框架的位置和大小 窗口尺寸 X
PostScript 文件 文档视图
PostScript 模式 程序模式
增量搜索期间的前缀参数命令 不退出 Isearch
前缀参数 论点
前缀键 按键
预处理器突出显示 其他 C 命令
漂亮的打印机 程序缩进
防止命令退出增量搜索 不退出 Isearch
寄存器预览 寄存器
主要 Rmail 文件 Rmail 基础知识
主要选择 初选
当活动区域发生变化时,主要选择 设置标记
印刷 印刷
打印字符 文字显示
打印文件(在 Dired 中) 对文件进行操作
印刷包装 印刷包装
在 MS-DOS 下打印 MS-DOS 进程
编程模式 挂钩
程序构建 建筑
节目编辑 程式
程序函数和变量,文档查找 编程语言文档
项目后端 项目
项目根 项目
项目 项目
序言模式 程序模式
迅速的 基本迷你缓冲区
提示符,外壳 外壳提示符
PS 文件 文档视图
从上游 (VC) 拉取更改 拉/推
旁遮普语 语言环境
将更改推送到上游 (VC) 拉/推
谜题 娱乐项目
Python模式 程序模式

查询替换 查询替换
query-replace 查询替换
戒烟 戒烟
退出(在搜索中) 搜索错误
退出 Emacs 退出
在 MS-DOS 上退出 MS-DOS 键盘
引号 引号
引用 插入文本
引用文件名 引用的文件名

压缩包 文件档案
原始字节 国际字符
raw-text,编码系统 编码系统
RCS 版本控制系统
只读缓冲区 杂项缓冲区
只读文本,杀死 杀死选项
阅读邮件 远程邮件
永久重新绑定密钥 初始化重新绑定
重新绑定密钥,本次会话 重新绑定
重新绑定主要模式键 初始化重新绑定
重新绑定鼠标按钮 鼠标按钮
重新绑定非ASCII 初始化非 ASCII
恢复崩溃的会话 崩溃后
长方形 矩形
矩形突出显示 CUA 绑定
矩形和图片模式 图片中的矩形
矩形区域 矩形
递归复制 对文件进行操作
递归删除 直接删除
递归编辑级别 递归编辑
递归编辑,无法退出 卡住递归
回收站 其他文件操作
重做 撤消
刷新显示的文件 更新中
正则表达式 正则表达式
正则表达式搜索 正则表达式搜索
地区 标记
区域突出显示 禁用瞬态标记
区域矩形 矩形
注册文件 风险投资概念
寄存器 寄存器
注册表,设置环境变量(MS-Windows) MS-Windows 注册表
注册表,设置资源(MS-Windows) 资源
正则表达式 正则表达式
相关文件 其他 C 命令
重新加载文件 保存 Emacs 会话
记住编辑会话 保存 Emacs 会话
远程文件访问 远程文件
远程主机 远程主机
远程主机,调试 启动GUD
远程存储库(CVS) CVS 选项
删除缩进 缩进命令
重命名文件 复制和命名
重命名文件(在 Dired 中) 对文件进行操作
重命名版本控制文件 VC 删除/重命名
重复命令 重复
替代品 代替
回复帖子: 邮件回复
报告 Emacs 错误,如何 了解错误报告
报告 Emacs 中的错误 清单
存储库 风险投资概念
重读文件 恢复
保留键绑定 按键绑定
调整图像大小 图像模式
调整窗口大小 更改窗口
调整迷你缓冲区的大小 迷你缓冲区编辑
调整窗口大小 更改窗口
解决冲突 合并
GTK+ 的资源文件 GTK资源
资源名称,命令行参数 资源
资源值,命令行参数 资源
资源 资源
恢复会话 保存 Emacs 会话
限制 缩小范围
重试失败的消息 邮件回复
POP3 收件箱中的顺序相反 远程邮箱
反相视频,命令行参数 颜色 X
修订 风险投资概念
修订版 ID 风险投资概念
版本控制中的修订 ID 高级 Cx vv
修订标签 修订标签
RGB 三元组 颜色
从右到左的文本 双向编辑
风险变量 安全文件变量
RLM 双向编辑
邮件 远程邮件
Rmail文件排序 邮件排序
罗马尼亚语 语言环境
罗什·霍德什 性爱日记条目
rot13 代码 Rmail Rot13
旋转图像 图像模式
红宝石模式 程序模式
runemacs.exe Windows启动
运行一个钩子 挂钩
文件的运行信息(在 Dired 中) 对文件进行操作
运行 Lisp 函数 建筑
在文件上运行 man(在 Dired 中) 对文件进行操作
俄语 语言环境

S
s- 修改键
保存的回声区域消息 回声区
保存设置 更改变量
将缓冲区名称保存在寄存器中 文件和缓冲区寄存器
将文件名保存在寄存器中 文件和缓冲区寄存器
保存文件 参观
将帧配置保存在寄存器中 配置寄存器
将键盘宏保存在寄存器中 键盘宏寄存器
保存键盘宏 保存键盘宏
将号码保存在寄存器中 寄存器数量
在寄存器中保存位置 位置寄存器
将矩形保存在寄存器中 矩形寄存器
保存会话 保存 Emacs 会话
将文本保存在寄存器中 文本寄存器
将窗口配置保存在寄存器中 配置寄存器
SCCS 版本控制系统
方案模式 外部 Lisp
屏幕 屏幕
屏幕显示错误 屏幕乱码
屏线 延续线
屏幕阅读器软件,MS-Windows Windows 杂项
脚本模式 初始选项
角色脚本 修改字体集
滚动条(X 资源) 资源表
滚动条模式 滚动条
全部滚动模式 窗口便利
scroll-bar 滚动条
scroll-command财产 滚动
scroll-command属性和增量搜索 不退出 Isearch
滚动条宽度(X 资源) 资源表
滚动 滚动
增量搜索期间滚动命令 不退出 Isearch
在日历中滚动 滚动日历
一起滚动窗口 窗口便利
深圳发展局 调试器
在多个文件中搜索并替换(在 Dired 中) 对文件进行操作
在多个源文件中搜索和替换 标识符搜索
搜索定制 搜索定制
慢速终端上的搜索显示 搜索定制
搜索正则表达式 正则表达式搜索
互联网搜索关键字 单词搜索
搜索已知错误 已知问题
搜索模式,默认 搜索定制
搜索多个文件(在 Dired 中) 对文件进行操作
搜索环 重复搜索
搜索,改变方向 重复搜索
搜索,包裹 重复搜索
搜索,环绕 重复搜索
搜索和替换命令 代替
搜索 搜索
搜索 Dired 缓冲区 定向导航
有效地搜索文档 帮助
在 Rmail 中搜索 邮件动议
在 webkit 缓冲区中搜索 嵌入式 WebKit 小部件
通过 Dired 搜索多个文件 其他 Dired 功能
二次选择 二次选拔
secondary-selection 二次选拔
手册页的部分 手册页
安全 主机安全
显示丰富文本时的安全性 丰富的属性
全选 标记对象
选定的缓冲区 缓冲器
选定的窗口 基本窗口
在其他窗口中选择缓冲区 弹出窗口
选择,主要 初选
选择性显示 选择性显示
选择性撤消 撤消
自我文档 帮助
语义模式 语义学
语义包 语义学
发送邮件 发送邮件
发送 GNU Emacs 补丁 发送补丁
发送邮件 邮件发送
句子 句子
服务器文件 TCP Emacs 服务器
服务器,使用 Emacs 作为 Emacs服务器
服务器端字体 字体
设置缓冲区字体大小 文字比例
正则表达式中的替代字符集 正则表达式
文件集 文件集
设置标记 标记
设置变量 正在检查
设置 轻松定制
设置,如何保存 更改变量
性别 表达式
sexp 日记条目 性爱日记条目
SGML模式 HTML模式
影子簇 文件阴影
shadow 标准面
影子文件 文件阴影
外壳命令 
shell 命令, Dired Dired 中的 Shell 命令
外壳完成 外壳模式
SHELL环境变量 单壳
外壳模式 外壳模式
shell 脚本和本地文件变量 指定文件变量
Shell 脚本模式 程序模式
版本控制中的货架 VC 目录命令
班次选择 班次选择
显示Paren模式 匹配
显示隐藏子目录(Dired) 隐藏子目录
害羞组,在正则表达式中 正则表达式反斜杠
签名文件(在 Dired 中) 对文件进行操作
模拟模式 程序模式
模拟鼠标中键 Windows鼠标
同时编辑 联锁
僧伽罗语 语言环境
站点初始化文件 初始化文件
站点 Lisp目录 初始化文件
站点 Lisp文件,未加载 初始选项
站点启动.el文件,未加载 初始选项
站点启动.el、站点启动文件 初始化文件
文件大小,访问时警告 参观
迷你缓冲区的大小 迷你缓冲区编辑
文件名中重复斜杠 迷你缓冲区文件
SliTeX 模式 TeX 模式
斯洛伐克语: 语言环境
斯洛文尼亚语: 语言环境
合并模式 比较文件
邮件发送 邮件发送
 娱乐项目
套接字激活、systemd、Emacs Emacs服务器
软连字符 文字显示
软换行符 硬换行符和软换行符
纸牌: 娱乐项目
排序 排序
对日记条目进行排序 精美日记展示
排序 Dired 缓冲区 更新中
排序 Rmail 文件 邮件排序
西班牙语 语言环境
具体版本控制系统 高级 Cx vv
规范,对于源包 获取包源
从命令行指定默认字体 字体X
指定转储文件 初始选项
指定行尾转换 文本编码
为 Emacs 框架指定全屏 窗口尺寸 X
速度栏 速度条
对活动区域进行拼写检查 拼写
拼写、检查和更正 拼写
启动画面 初始选项
拆分列 两柱式
拆分表格单元格 单元命令
SQL模式 程序模式
源代码 版本控制系统
源代码 版本控制系统
SSH 远程主机
SSL 网络安全
字符终端上的标准颜色 颜色 X
标准面孔 标准面
标准字体集 定义字体集
启动目录,MS-Windows Windows启动
启动图标化,命令行参数 图标X
启动 Emacs 进入Emacs
在 MS-Windows 上启动 Emacs Windows启动
启动TLS 网络安全
启动(命令行参数) Emacs 调用
启动(初始化文件) 初始化文件
启动字体集 定义字体集
启动消息 初始选项
启动屏幕 进入Emacs
版本控制中的隐藏内容 VC 目录命令
字符串替换 代替
字符串语法 初始化语法
陷入递归编辑 卡住递归
样式(用于缩进) 自定义 C 缩进
正则表达式中的子表达式 正则表达式反斜杠
Dired 中的子目录 Dired 中的子目录
MS-Windows 上的子进程 Windows进程
订阅群组 Gnus 组缓冲区
子外壳 
substring,完成样式 完成样式
子树(大纲模式) 轮廓可见性
颠覆 版本控制系统
子字模式 混合大小写单词
摘要(Rmail) Rmail总结
求和时间间隔 时间间隔
日出和日落 日出日落
超级(在 MS-DOS 下) MS-DOS 键盘
超级,修饰键 修改键
暂停 退出
C、C++ 中的可疑结构 其他 C 命令
SVN 版本控制系统
瑞典语: 语言环境
开关缓冲器 选择缓冲区
开关(命令行) Emacs 调用
符号搜索 符号搜索
符号,突出显示 交互式突出显示
符号链接(和版本控制) 一般风险投资选项
符号链接(在 Dired 中创建) 对文件进行操作
符号链接(创建) 复制和命名
符号链接(访问) 文件别名
同步窗口 跟随模式
同步X模式 资源表
语法高亮和着色 字体锁定
正则表达式的语法 正则表达式
系统范围的包 打包文件
系统单元文件 Emacs服务器

时间
时间 词汇表
标签栏(X 资源) 资源表
标签栏模式 标签栏
标签行 制表线
制表位 制表位
tab-line 标准面
表创建 表创建
工作台尺寸 表杂项
HTML 和 LaTeX 的表 表杂项
表模式 基于文本的表格
表识别 表格识别
表格到文本 表转换
标签 缩进
选项卡,在选项卡栏上 标签栏
标签 外部参照
标签和标签表 标签 表格
版本控制标签 修订标签
标签,C++ 标签 表格
基于标签的补全 符号完成
泰越: 语言环境
塔吉克语 语言环境
泰米尔语: 语言环境
焦油模式 文件档案
TCL模式 程序模式
TCP Emacs 服务器 TCP Emacs 服务器
远程登录 远程主机
泰卢固语 语言环境
临时窗口 临时展示
期限模式 期限模式
终端模拟器,鼠标支持 纯文本鼠标
终端,串行 串口终端
术语脚本文件 清单
俄罗斯方块 娱乐项目
TeX 编码 杂项
TeX 模式 TeX 模式
TEXEDIT环境变量 Emacs服务器
TEXINPUTS环境变量 TeX 打印
文本 文本
MS-DOS/MS-Windows 上的文本和二进制文件 文本和二进制
文本按钮 鼠标参考
文本颜色,来自命令行 颜色 X
文本光标 光标显示
文本模式 文本模式
点 处的文本属性 国际字符
字符的文本属性 编辑格式信息
文本终端 文本终端
文本到表格 表转换
基于文本的表格 基于文本的表格
基于文本的表格,拆分单元格 单元命令
文本/丰富的 MIME 格式 丰富的文本
泰语 语言环境
藏语 语言环境
波形符() 位于备份文件名末尾 备份名称
时间(模式线上) 可选模式线
时间间隔,求和 时间间隔
时间戳 时间戳
时钟 时间间隔
时间日志文件 时间间隔
传输层安全 网络安全
TLS 加密(Rmail) 远程邮箱
待办事项 组织组织者
切换标记(在 Dired 中) 标记与旗帜
TOML模式 程序模式
工具栏(X资源) 资源表
工具栏模式 工具栏
工具栏位置 工具栏
工具栏样式 工具栏
工具提示帮助 帮助回声
工具提示 工具提示
工具提示(俳句) 俳句基础知识
顶层 模式线
触摸屏事件 鼠标输入
河内塔 娱乐项目
传统字体锁定 传统字体锁定
尾随空格 无用的空白
补丁中的尾随空格 差异模式
trailing-whitespace 无用的空白
流浪汉 远程文件
瞬态标记模式 禁用瞬态标记
传输层安全 网络安全
表达式的转置 表达式
垃圾 其他文件操作
tree-sitter 库,支持的主要模式 程序模式
三击 鼠标按钮
Emacs 故障排除 损失
文件的真实名称 文件别名
截断 行截断
俳句中的 tty Emacs 俳句基础知识
TTY 菜单界面 标准面
土耳其语: 语言环境
两个目录(在 Dired 中) 对文件进行操作
两列编辑 两柱式
日志文件类型 日志文件的类型
打字稿模式 程序模式
拼写错误,修复 修理它

U
乌克兰语 语言环境
不平衡的括号和引号 括号
解压缩 压缩文件
undecided,编码系统 编码系统
取消删除(Rmail) 邮件删除
未消化 邮件文摘
无法显示的字符 国际字符
撤消 撤消
撤消限制 撤消
撤消窗口配置更改 窗口便利
单字节操作 单字节模式
统一码 国际字符
Unicode 字符,插入 插入文本
Unicode 排序算法 (UCA),以及ls-lisp.el: Lisp 中的 ls
唯一的缓冲区名称 统一
取消标记文件(在 Dired 中) 标记与旗帜
未保存的缓冲区,杀死 终止缓冲区
未保存的自定义,提醒保存 保存自定义设置
取消订阅群组 Gnus 组缓冲区
未翻译的文件系统 文本和二进制
未使用的行 无用的空白
解压缩档案 文件档案
大写文件名 转换文件名
更新 Dired 缓冲区 更新中
上游存储库 拉/推
上游源代码,用于包 获取包源
URL,在帮助中查看 帮助模式
网址 浏览URL
URL,激活 转到地址模式
新闻组新闻 牛羚
远程文件访问的用户名 远程文件
用户选项 轻松定制
用户选项,更改 更改变量
使用 Nextstep 服务 (macOS) Mac / GNUstep 事件
UTF-8 语言环境

V
多变的 变量
variable-pitch 标准面
变量,变化 更改变量
风险投资 版本控制
VC变更日志 VC变更日志
Dired 缓冲区中的 VC 命令 版本控制
VC目录缓冲区 VC目录模式
VC 文件集 基本 VC 编辑
VC 日志缓冲区,命令如下 VC变更日志
VC模式线路指示灯 VC模式线
vc-log缓冲区 VC变更日志
验证文件的数字签名(在 Dired 中) 对文件进行操作
Verilog模式 程序模式
版本控制 版本控制
版本控制日志 日志文件的类型
版本控制状态 VC模式线
VERSION_CONTROL环境变量 备份名称
垂直边框 滚动条
垂直滚动条 滚动条
垂直滚动条,命令行参数 杂项 X
vertical-border 标准面
VHDL模式 程序模式
越南语: 语言环境
查看模式 查看模式
查看帮助中的网页 帮助模式
大纲视图 轮廓视图
访问文件 参观
访问文件,命令行参数 行动论据
视线 延续线
视线模式 视线模式
视觉顺序 双向编辑

观察 GDB 中的表达式 观看表情
定向模式 维雷德
网址 浏览URL
网页,在帮助中查看 帮助模式
webkit 小部件 嵌入式 WebKit 小部件
周,他们从哪一天开始 移至开头或结尾
威尔士语 语言环境
Emacs bug 的构成是什么 错误标准
滚轮向下,鼠标事件 鼠标命令
向左滚轮,鼠标事件 鼠标命令
右轮,鼠标事件 鼠标命令
滚轮向上,鼠标事件 鼠标命令
空白字符 缩进
空白模式 无用的空白
空格,尾随 无用的空白
宽块光标 光标显示
扩大 缩小范围
缓冲区位置的小部件 编辑格式信息
Emacs 框架的宽度和高度 窗口尺寸 X
垂直滚动条的宽度 滚动条
文件名中的通配符 参观
风动套餐 窗口便利
窗口配置更改,撤消 窗口便利
窗口分隔模式 窗隔板
窗口管理器,密钥被盗 用户输入
Windows 剪贴板支持 MS-DOS鼠标
Emacs 中的窗口 视窗
Windows系统菜单 Windows 键盘
窗口,同步 跟随模式
Windows-1255 语言环境
获胜者模式 窗口便利
字处理 丰富的文本
单词搜索 单词搜索
自动换行 视线模式
 
单词、大小写转换 案件
工作文件 风险投资概念
工作树 风险投资概念
全球资讯网 浏览URL
包裹搜索 重复搜索
包装 延续线
所见即所得 丰富的文本

X
X 剪切和粘贴 初选
X 默认文件 字体
X输入法编码系统 X 编码
X 输入法编码系统,覆盖 X 编码
X输入法(X资源) 资源表
X 逻辑字体说明 字体
X资源 资源
X资源文件 字体
俳句上的 X 资源 俳句基础知识
X 资源,未加载 初始选项
X选择 初选
XDB 调试器
XDG_CONFIG_HOME 初始化文件
XIM(X 资源) 资源表
XIM、X 输入法 单字节模式
XLFD 字体
XML 架构 HTML模式
XPS 文件 文档视图
外部参考 外部参照
外部参照后端 外部参照
外部参照模式 外部参照命令
xterm 纯文本鼠标
x小部件 嵌入式 WebKit 小部件
Xwidget-WebKit模式 嵌入式 WebKit 小部件
xwidget-webkit-编辑模式 嵌入式 WebKit 小部件

y 或 n 提示 是或否提示
年份 来自其他日历
yahrzeits 和 sexp 日记条目 性爱日记条目
猛拉 扬金
猛拉以前的杀戮 早期杀戮
是或否提示 是或否提示

Z
压缩 文件档案
Zmacs模式 禁用瞬态标记
区域 娱乐项目
动物园 文件档案


脚注

Footnotes

(1)

本手册本身包含在 GNU 自由文档许可证中。该许可证在精神上与通用公共许可证类似,但更适合文档。请参阅GNU 自由文档许可证

This manual is itself covered by the GNU Free Documentation License. This license is similar in spirit to the General Public License, but is more suitable for documentation. See GNU Free Documentation License.

(2)

“点”这个词来自于“',这是 TECO(最初的 Emacs 的编写语言)中用于访问编辑位置的命令。

The term “point” comes from the character ‘.’, which was the command in TECO (the language in which the original Emacs was written) for accessing the editing position.

(3)

我们之所以称其为Altas Meta,是因为历史原因。

We refer to Alt as Meta for historical reasons.

(4)

设置inhibit-startup-screen站点启动.el不起作用,因为启动屏幕是在阅读之前设置的站点启动.el。请参阅Emacs 初始化文件有关信息,站点启动.el

Setting inhibit-startup-screen in site-start.el doesn’t work, because the startup screen is set up before reading site-start.el. See The Emacs Initialization File, for information about site-start.el.

(5)

ASCII 中没有字符;通常,在文本终端上键入会给出字符。该键也绑定到,因此除非您不幸拥有一个行为不同的文本终端,否则您不妨考虑 为。C-SPCC-SPCC-@set-mark-commandC-@C-SPC

There is no C-SPC character in ASCII; usually, typing C-SPC on a text terminal gives the character C-@. This key is also bound to set-mark-command, so unless you are unlucky enough to have a text terminal that behaves differently, you might as well think of C-@ as C-SPC.

(6)

除了 之外C-/,该undo命令还绑定到C-x u因为这对于初学者来说更容易记住:'' 代表“撤消”。这也是必然的,因为在某些文本终端上C-_打字实际上会输入.C-/C-_

Aside from C-/, the undo command is also bound to C-x u because that is more straightforward for beginners to remember: ‘u’ stands for “undo”. It is also bound to C-_ because typing C-/ on some text terminals actually enters C-_.

(7)

如果您的文件系统不支持符号链接,则使用常规文件。

If your file system does not support symbolic links, a regular file is used.

(8)

Nextstep 上工具包创建的工具提示的前景色和背景色也可以通过设置foregroundbackground框架参数来自 定义tooltip-frame-parameters

The foreground and background colors of toolkit-created tooltips on Nextstep can also be customized by setting the foreground and background frame parameters that are part of tooltip-frame-parameters.

(9)

它还指定为 MIME '文本/*' 机构和其他网络传输环境中。它与 SGML 参考语法 record-start/record-end 格式不同,Emacs 不直接支持后者。

It is also specified for MIME ‘text/*’ bodies and in other network transport contexts. It is different from the SGML reference syntax record-start/record-end format, which Emacs doesn’t support directly.

(10)

如果您在 X 上运行 Emacs,您可能需要使用以下命令通知 X 服务器新安装的字体的位置:

If you run Emacs on X, you may need to inform the X server about the location of the newly installed fonts with commands such as:

xset fp+ /usr/local/share/emacs/fonts
 xset fp 重新散列
 xset fp+ /usr/local/share/emacs/fonts
 xset fp rehash
(11)

更具体地说,是“派生”自的模式 prog-mode(请参阅Emacs Lisp 参考手册中的派生模式)。

More specifically, the modes which are “derived” from prog-mode (see Derived Modes in The Emacs Lisp Reference Manual).

(12)

弯曲单引号字符为 U+2018左单引号和 U+2019右单引号;弯曲的双引号是 U+201C左双引号和 U+201D右双引号。在无法显示这些字符的文本终端上,信息阅读器可能会将它们显示为打字机 ASCII 引号字符。

The curved single quote characters are U+2018 LEFT SINGLE QUOTATION MARK and U+2019 RIGHT SINGLE QUOTATION MARK; the curved double quotes are U+201C LEFT DOUBLE QUOTATION MARK and U+201D RIGHT DOUBLE QUOTATION MARK. On text terminals which cannot display these characters, the Info reader might show them as the typewriter ASCII quote characters.

(13)

它已被替换为 '幻灯片' 文档类,它是 LaTeX 自带的。

It has been replaced by the ‘slides’ document class, which comes with LaTeX.

(14)

“sexp”这个词用来指代 Lisp 中的表达式。

The word “sexp” is used to refer to an expression in Lisp.

(15)

“ElDoc”这个名字是一个历史意外:这种模式是从支持 Emacs Lisp 缓冲区开始的。

The name “ElDoc” is a historical accident: this mode started by supporting Emacs Lisp buffers.

(16)

在图形显示器上,该键通常由窗口管理器保留用于切换图形窗口,因此您应该键入或。 M-TABC-M-iESC TAB

On graphical displays, the M-TAB key is usually reserved by the window manager for switching graphical windows, so you should type C-M-i or ESC TAB instead.

(17)

正则表达式和语法表。

Regular expressions and syntax tables.

(18)

标签标识符引用的同义词。基于etags包的命令和功能传统上使用具有此含义的“标签”,本小节遵循该传统。

A tag is a synonym for identifier reference. Commands and features based on the etags package traditionally use “tag” with this meaning, and this subsection follows that tradition.

(19)

美国国家安全局。

The US National Security Agency.

(20)

此功能要求 Emacs 构建为libxml2 支持或您已安装 Lynx 浏览器。

This capability requires that Emacs be built with libxml2 support or that you have the Lynx browser installed.

(21)

文档类型所需的外部工具必须可用,并且 Emacs 必须在图形框架中运行并具有 PNG 图像支持。如果这些要求没有得到满足,Emacs 就会退回到另一个主要模式。

The needed external tools for the document type must be available, and Emacs must be running in a graphical frame and have PNG image support. If these requirements is not fulfilled, Emacs falls back to another major mode.

(22)

您不应该暂停 shell 进程。暂停 shell 的子作业是完全不同的事情 - 这是正常做法,但您必须使用 shell 来继续子作业;这个命令不会这样做。

You should not suspend the shell process. Suspending a subjob of the shell is a completely different matter—that is normal practice, but you must use the shell to continue the subjob; this command won’t do it.

(23)

有些程序使用不同的环境变量;例如,要让 TeX 使用 'emacs客户端',将TEXEDIT环境变量设置为'emacsclient +%d %s'。

Some programs use a different environment variable; for example, to make TeX use ‘emacsclient’, set the TEXEDIT environment variable to ‘emacsclient +%d %s’.

(24)

在 MS-DOS 上,该文件的名称应该是_dir-locals.el,由于 DOS 文件系统的限制。如果文件系统限制为 8+3 个文件名,则文件名将被操作系统截断为 _dir-loc.el

On MS-DOS, the name of this file should be _dir-locals.el, due to limitations of the DOS filesystems. If the filesystem is limited to 8+3 file names, the name of the file will be truncated by the OS to _dir-loc.el.

(25)

在 MS-Windows 上,没有一个目录被所有程序视为用户的“主目录”。 Emacs 使用相关目录之一作为您的主目录的等效目录;有关详细信息, 请参阅 MS-Windows 上的主目录和启动目录。

On MS-Windows, there’s no single directory considered by all programs as “the home directory” of the user. Emacs uses one of the pertinent directories as the equivalent of your home directory; see HOME and Startup Directories on MS-Windows, for the details.

(26)

该选项对 MS-Windows 没有影响。

This option has no effect on MS-Windows.

(27)

在这里和下面,每当​​我们说“冒号分隔的目录列表”时,它都涉及 Unix 和 GNU/Linux 系统。在 MS-DOS 和 MS-Windows 上,目录由分号分隔,因为 DOS/Windows 文件名可能在驱动器号后包含冒号。

Here and below, whenever we say “colon-separated list of directories”, it pertains to Unix and GNU/Linux systems. On MS-DOS and MS-Windows, the directories are separated by semi-colons instead, since DOS/Windows file names might include a colon after a drive letter.

(28)

旧版本的 Emacs 不检查应用程序数据目录。

Older versions of Emacs didn’t check the application data directory.

(29)

有一个已知的例外情况:Windows-L锁定工作站的组合由较低级别的系统处理。因此,w32-register-hot-key无法覆盖此组合键 - 它始终锁定计算机。

There is one known exception: The combination Windows-L that locks the workstation is handled by the system on a lower level. For this reason, w32-register-hot-key cannot override this key combination - it always locks the computer.

(30)

请注意,'净使用' 命令要求使用 Windows 样式的反斜杠键入 UNC 共享名,而 的值 printer-name可以使用正斜杠或反斜杠进行设置。

Note that the ‘net use’ command requires the UNC share name to be typed with the Windows-style backslashes, while the value of printer-name can be set with either forward- or backslashes.

(31)

通常,一种特定的代码页会被烧入显示内存,而其他代码页可以通过修改系统配置文件来安装,例如配置系统,然后重新启动。虽然有第三方软件允许在不重新启动的情况下更改代码页,但我们在此描述了普通 MS-DOS 系统的行为方式。

Normally, one particular codepage is burnt into the display memory, while other codepages can be installed by modifying system configuration files, such as CONFIG.SYS, and rebooting. While there is third-party software that allows changing the codepage without rebooting, we describe here how a stock MS-DOS system behaves.

(32)

ISO 8859 的标准 Emacs 编码系统不太适合此目的,因为 DOS 代码页通常与标准 ISO 字符代码不匹配。例如,字母 'C'('C' with cedilla) 在标准 Latin-1 字符集中具有代码 231,但相应的 DOS 代码页 850 使用此字形的代码 135。

The standard Emacs coding systems for ISO 8859 are not quite right for the purpose, because typically the DOS codepage does not match the standard ISO character codes. For example, the letter ‘ç’ (‘c’ with cedilla) has code 231 in the standard Latin-1 character set, but the corresponding DOS codepage 850 uses code 135 for this glyph.

(33)

这里的措辞很不小心。其目的是没有人需要付费才能 获得使用 GNU 系统的许可。但这些话并没有明确说明这一点,人们常常将其解释为 GNU 的副本应该始终以很少的费用或免费的方式分发。这从来都不是本意。随后,宣言提到了公司提供分销服务以获取利润的可能性。后来我学会了仔细区分自由意义上的“免费”和价格意义上的“免费”。自由软件是用户可以自由分发和更改的软件。一些用户可能会免费获得副本,而其他用户则需要付费才能获得副本 - 如果资金有助于支持改进软件,那就更好了。重要的是,每个拥有副本的人都可以自由地与他人合作使用它。

The wording here was careless. The intention was that nobody would have to pay for permission to use the GNU system. But the words don’t make this clear, and people often interpret them as saying that copies of GNU should always be distributed at little or no charge. That was never the intent; later on, the manifesto mentions the possibility of companies providing the service of distribution for a profit. Subsequently I have learned to distinguish carefully between “free” in the sense of freedom and “free” in the sense of price. Free software is software that users have the freedom to distribute and change. Some users may obtain copies at no charge, while others pay to obtain copies—and if the funds help support improving the software, so much the better. The important thing is that everyone who has a copy has the freedom to cooperate with others in using it.

(34)

这是我未能仔细区分“免费”这两种不同含义的另一个地方。现在的说法并不虚假——您可以从您的朋友或通过网络免费获得 GNU 软件的副本。但这确实暗示了错误的想法。

This is another place I failed to distinguish carefully between the two different meanings of “free.” The statement as it stands is not false—you can get copies of GNU software at no charge, from your friends or over the net. But it does suggest the wrong idea.

(35)

现在存在几家这样的公司。

Several such companies now exist.

(36)

自由软件基金会的大部分资金来自分销服务,尽管它是一个慈善机构而不是一家公司。如果没有人 选择通过向 FSF 订购来获取副本,那么 FSF 将无法开展其工作。但这并不意味着专有限制有理由迫使每个用户付费。如果所有用户中的一小部分从 FSF 订购副本,就足以维持 FSF 的运转。所以我们请求用户选择以这种方式支持我们。你尽了自己的职责吗?

The Free Software Foundation raises most of its funds from a distribution service, although it is a charity rather than a company. If no one chooses to obtain copies by ordering from the FSF, it will be unable to do its work. But this does not mean that proprietary restrictions are justified to force every user to pay. If a small fraction of all the users order copies from the FSF, that is sufficient to keep the FSF afloat. So we ask users to choose to support us in this way. Have you done your part?

(37)

一组计算机公司最近筹集资金来支持 GNU C 编译器的维护。

A group of computer companies recently pooled funds to support maintenance of the GNU C Compiler.

(38)

在八十年代,我还没有意识到谈论“知识产权”的“问题”是多么令人困惑。这个词显然是有偏见的。更微妙的是,它将提出截然不同问题的各种不同法律混为一谈。如今,我敦促人们完全拒绝“知识产权”一词,以免导致其他人认为这些法律构成了一个连贯的问题。明确的方法是分别讨论专利、版权和商标。有关该术语如何传播混乱和偏见的更多解释,请参阅 https://www.gnu.org/philosophy/not-ipr.xhtml。

In the 80s I had not yet realized how confusing it was to speak of “the issue” of “intellectual property.” That term is obviously biased; more subtle is the fact that it lumps together various disparate laws which raise very different issues. Nowadays I urge people to reject the term “intellectual property” entirely, lest it lead others to suppose that those laws form one coherent issue. The way to be clear is to discuss patents, copyrights, and trademarks separately. See https://www.gnu.org/philosophy/not-ipr.xhtml for more explanation of how this term spreads confusion and bias.

(39)

随后我们发现需要区分“自由软件”和“自由软件”。 “免费软件”一词​​是指您可以自由重新分发的软件,但通常您不能自由地研究和更改源代码,因此大多数都不是自由软件。请参阅 https://www.gnu.org/philosophy/words-to-avoid.html了解更多说明。

Subsequently we have discovered the need to distinguish between “free software” and “freeware”. The term “freeware” means software you are free to redistribute, but usually you are not free to study and change the source code, so most of it is not free software. See https://www.gnu.org/philosophy/words-to-avoid.html for more explanation.